Collect error messages per-translation unit.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of SourcePawn.
7 * SourcePawn is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * SourcePawn. If not, see http://www.gnu.org/licenses/.
19 #include "../Strings.h"
21 #include "../TypeManager.h"
22 #include "NameBinding.h"
24 #include "ConstantEvaluator.h"
25 #include "../Spaces-inl.h"
26 #include "../Heap-inl.h"
30 // Create symbol tables and symbols for every scope and declaration. For type
31 // declarations and methods, we also pre-allocate a Type object, so that
32 // circular dependencies between types will work.
33 class NamePopulator : public AstVisitor
36 // This class is analagous to a Scope, however, it allows us to create
37 // scopes lazily. If a scope is requested, and the current environment
38 // has no scope, then a scope is created. If no scope is ever requested,
39 // a scope does not need to be created.
43 SymbolEnv(SymbolEnv **prevp, Scope *scope = NULL)
57 void setScope(Scope *scope) {
61 SymbolEnv *prev() const {
80 FunctionScope(FunctionScope **prevp)
90 ReturnStatus returns() const {
93 void returns(ReturnStatus status) {
98 FunctionScope **prevp_;
100 ReturnStatus status_;
104 NamePopulator(Zone *zone, CompileContext &cc, TranslationUnit *unit)
115 ImportScope *importScope = ImportScope::New(pool_);
119 // At the import level, we declare system types.
120 if (!declareSystemTypes(importScope))
123 GlobalScope *globalScope = GlobalScope::New(pool_, importScope);
127 unit_->setImportScope(importScope);
128 unit_->setGlobalScope(globalScope);
130 SymbolEnv env(&env_, globalScope);
132 for (size_t i = 0; i < unit_->tree()->statements()->length(); i++) {
133 Statement *stmt = unit_->tree()->statements()->at(i);
140 bool declareSystemType(ImportScope *scope, const char *name, Handle<Type> type) {
141 Local<String> tag(zone_, zone_->makeSymbol(name));
145 TypeSymbol *sym = new (pool_) TypeSymbol(scope, tag, type);
146 return scope->addSymbol(sym);
149 bool declareSystemType(ImportScope *scope, const char *name, PrimitiveType prim) {
150 Local<Type> primitive(zone_, zone_->types()->getPrimitive(prim));
152 return declareSystemType(scope, name, primitive);
155 bool declareSystemTypes(ImportScope *scope) {
156 if (!declareSystemType(scope, "float", PrimitiveType_Float))
158 if (!declareSystemType(scope, "_", PrimitiveType_Int32))
160 if (!declareSystemType(scope, "int", PrimitiveType_Int32))
162 if (!declareSystemType(scope, "bool", PrimitiveType_Bool))
164 if (!declareSystemType(scope, "char", PrimitiveType_Char))
167 Local<Type> voidType(zone_, zone_->types()->getVoid());
168 if (!declareSystemType(scope, "void", voidType))
174 void visitVariableDeclaration(VariableDeclaration *node) {
175 Scope *scope = env_->scope();
176 if (!scope || scope->kind() != Scope::GLOBAL) {
177 if ((scope = getOrCreateBlockScope()) == NULL)
181 if (scope->kind() == Scope::GLOBAL) {
182 // The symbol must be added now, since it could be an export.
183 VariableSymbol *sym = new (pool_) VariableSymbol(scope, node->name(), node->pos());
184 node->setSymbol(sym);
186 if (!registerName(scope, sym))
189 // We ensure the scope will exist at the name binding phase, but
190 // we don't actually register the variable symbol yet. Otherwise,
191 // when binding the initializer, we could encounter:
194 // And we don't necessarily want this to bind.
197 if (node->initialization())
198 node->initialization()->accept(this);
200 void visitEnumStatement(EnumStatement *node) {
201 Local<String> name(zone_, node->name());
202 Local<Type> type(zone_);
204 type = zone_->types()->newEnum(name);
206 type = zone_->types()->getPrimitive(PrimitiveType_Int32);
211 Scope *scope = getGlobalOrCreateBlockScope();
216 TypeSymbol *sym = new (pool_) TypeSymbol(scope, name, type);
217 if (!registerName(scope, sym))
222 for (size_t i = 0; i < node->entries()->length(); i++) {
223 EnumStatement::Entry &entry = node->entries()->at(i);
224 BoxedPrimitive box = BoxedPrimitive::Int(value);
226 if (!EvaluateForConstant(entry.expr, &box) || box.type() != PrimitiveType_Int32) {
227 cc_.reportError(entry.expr->pos(), Message_EnumFieldNotConstant);
231 assert(box.type() == PrimitiveType_Int32);
235 ConstantSymbol *sym = new (pool_) ConstantSymbol(scope, entry.name, entry.pos, type, box);
236 if (!registerName(scope, sym))
242 void visitFunctionStatement(FunctionStatement *node) {
243 // We create function types ahead of time, not for any particular
244 // reason. It makes things consistent with FunctionTypeStatement,
245 // which actually does produce a type.
246 Local<FunctionType> type(zone_, FunctionType::New(zone_, node->name(), node->token()));
250 assert(env_->scope());
252 // Function statements are always named, so add the name to the outer scope.
253 FunctionSymbol *sym = new (pool_) FunctionSymbol(env_->scope(), node->name(), node->pos(), type);
254 if (!registerName(env_->scope(), sym))
257 if (node->token() == TOK_PUBLIC ||
258 node->token() == TOK_FORWARD ||
259 node->token() == TOK_NATIVE)
261 // We're in the global scope, for sure.
262 assert(env_->scope()->kind() == Scope::GLOBAL);
263 GlobalScope *globals = (GlobalScope *)env_->scope();
264 if (!globals->addPublic(sym))
268 node->setSymbol(sym);
270 // Scope for the function's arguments.
271 SymbolEnv argEnv(&env_);
272 if (!registerArguments(node->signature()))
275 // Scope for function body.
276 SymbolEnv localEnv(&env_);
277 FunctionScope fun(&fun_);
279 node->body()->accept(this);
281 // Function statements have quirky semantics around their return
282 // type. For reasonable compatibility with SP1, we use the following
283 // heuristics for when no explicit type is declared.
284 if (!node->signature().returnType()) {
285 Local<Type> type(zone_);
286 if (node->token() == TOK_FORWARD || node->token() == TOK_NATIVE) {
287 // If the function type is a native or forward, we always
288 // assume it returns an int32.
289 type = zone_->types()->getPrimitive(PrimitiveType_Int32);
290 } else if (fun.returns() != ValueReturn) {
291 // This function never returns a value, so mark it as
293 type = zone_->types()->getVoid();
295 // No need to NULL check here, we'll catch OOM later.
296 node->sym()->type()->setReturnType(type);
299 node->setScopes(argEnv.scope(), localEnv.scope());
301 void visitStructureStatement(StructureStatement *node) {
304 void visiFunctionTypeStatementt(FunctionTypeStatement *node) {
308 void visitNameProxy(NameProxy *name) {
310 void visitAssignment(Assignment *node) {
311 node->lvalue()->accept(this);
312 node->expression()->accept(this);
314 void visitBinaryExpression(BinaryExpression *node) {
315 node->left()->accept(this);
316 node->right()->accept(this);
318 void visitReturnStatement(ReturnStatement *node) {
319 if (node->expression())
320 fun_->returns(ValueReturn);
322 fun_->returns(VoidReturn);
324 void visitForStatement(ForStatement *node) {
325 SymbolEnv env(&env_);
327 if (node->initialization())
328 node->initialization()->accept(this);
329 if (node->condition())
330 node->condition()->accept(this);
332 node->update()->accept(this);
333 node->body()->accept(this);
335 node->setScope(env.scope());
337 void visitBlockStatement(BlockStatement *node) {
338 if (node->type() == TOK_NEW) {
339 // Don't create a symbol environment for this block, since it
340 // was created solely to house multiple variable decls.
341 for (size_t i = 0; i < node->statements()->length(); i++)
342 node->statements()->at(i)->accept(this);
344 assert(node->type() == TOK_LBRACE);
346 SymbolEnv env(&env_);
348 for (size_t i = 0; i < node->statements()->length(); i++)
349 node->statements()->at(i)->accept(this);
351 if (node->type() == TOK_NEW) {
352 assert(!env.scope());
356 node->setScope(env.scope());
359 void visitIntegerLiteral(IntegerLiteral *node) {
361 void visitExpressionStatement(ExpressionStatement *node) {
362 node->expression()->accept(this);
364 void visitCallExpression(CallExpression *node) {
365 node->callee()->accept(this);
366 for (size_t i = 0; i < node->arguments()->length(); i++)
367 node->arguments()->at(i)->accept(this);
369 void visitIfStatement(IfStatement *node) {
370 node->ifTrue()->accept(this);
372 node->ifFalse()->accept(this);
374 void visitIndexExpression(IndexExpression *node) {
375 node->left()->accept(this);
376 node->right()->accept(this);
378 void visitFloatLiteral(FloatLiteral *node) {
380 void visitWhileStatement(WhileStatement *node) {
381 node->condition()->accept(this);
382 node->body()->accept(this);
384 void visitBreakStatement(BreakStatement *node) {
386 void visitContinueStatement(ContinueStatement *node) {
388 void visitStringLiteral(StringLiteral *node) {
390 void visitIncDecExpression(IncDecExpression *node) {
391 node->expression()->accept(this);
393 void visitUnaryExpression(UnaryExpression *node) {
394 node->expression()->accept(this);
396 void visitTernaryExpression(TernaryExpression *node) {
399 void visitBooleanLiteral(BooleanLiteral *node) {
401 void visitFieldExpression(FieldExpression *node) {
403 void visitSwitchStatement(SwitchStatement *node) {
404 if (node->defaultCase())
405 node->defaultCase()->accept(this);
407 for (size_t i = 0; i < node->cases()->length(); i++)
408 node->cases()->at(i)->statement()->accept(this);
410 void visitArrayLiteral(ArrayLiteral *node) {
412 void visitImportStatement(ImportStatement *node) {
416 Scope *getGlobalOrCreateBlockScope() {
418 assert(env_->scope()->kind() == Scope::BLOCK ||
419 env_->scope()->kind() == Scope::GLOBAL);
420 return env_->scope();
422 return getOrCreateBlockScope();
424 Scope *getOrCreateBlockScope() {
426 assert(env_->scope()->kind() == Scope::BLOCK);
427 return env_->scope();
430 LocalScope *scope = LocalScope::New(pool_);
434 env_->setScope(scope);
438 bool registerName(Scope *scope, Symbol *sym) {
442 if (Symbol *other = scope->localLookup(sym->name())) {
443 // Report, but allow errors to continue.
444 cc_.reportError(sym->pos(), Message_RedeclaredName,
445 sym->name()->chars(),
451 return scope->addSymbol(sym);
454 bool registerArguments(const FunctionSignature &sig) {
455 if (!sig.parameters()->length())
458 ArgumentScope *argScope = ArgumentScope::New(pool_);
461 env_->setScope(argScope);
463 for (size_t i = 0; i < sig.parameters()->length(); i++) {
464 Parameter *param = sig.parameters()->at(i);
465 VariableSymbol *sym = new (pool_) VariableSymbol(argScope, param->name(), param->pos());
466 if (!registerName(env_->scope(), sym))
468 param->setSymbol(sym);
476 PoolAllocator &pool_;
478 TranslationUnit *unit_;
484 ke::PopulateNamesAndTypes(Zone *zone, CompileContext &cc, TranslationUnit *unit)
486 AutoEnterCompileContext enter(cc, unit);
487 NamePopulator populator(zone, cc, unit);
491 static const int INFER_ARRAY_SIZE = 0;
492 static const int EVAL_ARRAY_SIZE = -1;
493 static const int DYNAMIC_ARRAY_SIZE = -2;
495 class NameBinder : public AstVisitor
501 AutoLinkScope(AutoLinkScope **prevp, Scope *scope)
509 scope_->setParent(prev_->scope());
514 assert(*prevp_ == this);
518 Scope *scope() const {
523 AutoLinkScope **prevp_;
524 AutoLinkScope *prev_;
529 NameBinder(Zone *zone, CompileContext &cc, TranslationUnit *unit)
539 // Start with the import scope, and collect all imported names.
540 AutoLinkScope importScope(&link_, unit_->importScope());
542 for (size_t i = 0; i < unit_->tree()->imports()->length(); i++)
543 unit_->tree()->imports()->at(i)->accept(this);
545 // Next, enter the global scope and walk all statements.
546 AutoLinkScope globalScope(&link_, unit_->globalScope());
547 for (size_t i = 0; i < unit_->tree()->statements()->length(); i++) {
548 Statement *stmt = unit_->tree()->statements()->at(i);
553 void visitVariableDeclaration(VariableDeclaration *node) {
554 // Bind the initializer before registering the declaration, so that we
555 // can error on bogus initializers (new x = x).
556 if (node->initialization())
557 node->initialization()->accept(this);
559 Local<Type> type(zone_, bindType(node->type(), node->quals()));
563 // We don't allow array typedefs yet.
564 assert(!type->isArray());
567 int dims[MAX_ARRAY_DEPTH];
568 int levels = evaluateDimensions(node->pos(), type, node->dims(), dims);
572 // Do some extra inference based on the initializer, if present.
573 Expression *init = node->initialization();
575 if (init->isArrayLiteral() && init->toArrayLiteral()->isFixed()) {
576 Local<Type> contained(zone_, type->isArray()
577 ? ArrayType::cast(type)->contained()
579 if (!inferFixedArrayDimensions(init->toArrayLiteral(), contained, dims, levels))
581 } else if (init->isStringLiteral()) {
582 dims[levels - 1] = init->toStringLiteral()->string()->length() + 1;
586 // If we got extra dimensions, we need to build a new type.
588 if ((type = buildArrayType(type, node->quals(), dims, node->dims()->length())) == NULL)
593 // If we're in global scope, and we received a |const| qualifier, then
594 // we extend this to array references as well. This is to sort of mimic
595 // SP1 functionality, but also means that you cannot have changeable
596 // const pointers in global scope.
597 if ((node->quals() & TypeQual_Const) &&
599 link_->scope()->kind() == Scope::GLOBAL)
601 if ((type = zone_->types()->qualify(type, TypeQual_Const)) == NULL)
605 // If the node already has a symbol (meaning it was a global), then
606 // we don't have to do anything more.
608 assert(node->sym()->scope()->kind() == Scope::GLOBAL);
609 node->sym()->setType(type);
613 VariableSymbol *sym = new (pool_) VariableSymbol(link_->scope(), node->name(), node->pos(), type);
614 node->setSymbol(sym);
616 if (Symbol *other = link_->scope()->localLookup(sym->name())) {
617 // Report, but allow errors to continue.
618 cc_.reportError(sym->pos(), Message_RedeclaredName,
619 sym->name()->chars(),
625 link_->scope()->addSymbol(sym);
627 void visitEnumStatement(EnumStatement *node) {
629 void visitFunctionStatement(FunctionStatement *node) {
630 AutoLinkScope argScope(&link_, node->argScope());
631 AutoLinkScope varScope(&link_, node->varScope());
633 Local<FunctionType> type(zone_, node->sym()->type());
634 if (!fillFunctionType(type, node->signature()))
638 node->body()->accept(this);
640 void visitStructureStatement(StructureStatement *node) {
643 void visitFunctionTypeStatement(FunctionTypeStatement *node) {
647 void visitNameProxy(NameProxy *proxy) {
648 Scope *scope = link_->scope();
649 Symbol *sym = scope->lookup(proxy->name());
651 cc_.reportError(proxy->pos(), Message_IdentifierNotFound, proxy->name()->chars());
654 void visitAssignment(Assignment *node) {
655 node->lvalue()->accept(this);
656 node->expression()->accept(this);
658 void visitBinaryExpression(BinaryExpression *node) {
659 node->left()->accept(this);
660 node->right()->accept(this);
662 void visitReturnStatement(ReturnStatement *node) {
663 node->expression()->accept(this);
665 void visitForStatement(ForStatement *node) {
666 AutoLinkScope scope(&link_, node->scope());
668 if (node->initialization())
669 node->initialization()->accept(this);
670 if (node->condition())
671 node->condition()->accept(this);
673 node->update()->accept(this);
674 node->body()->accept(this);
676 void visitBlockStatement(BlockStatement *node) {
677 AutoLinkScope scope(&link_, node->scope());
678 for (size_t i = 0; i < node->statements()->length(); i++)
679 node->statements()->at(i)->accept(this);
681 void visitIntegerLiteral(IntegerLiteral *node) {
683 void visitExpressionStatement(ExpressionStatement *node) {
684 node->expression()->accept(this);
686 void visitCallExpression(CallExpression *node) {
687 node->callee()->accept(this);
688 for (size_t i = 0; i < node->arguments()->length(); i++)
689 node->arguments()->at(i)->accept(this);
691 void visitIfStatement(IfStatement *node) {
692 node->condition()->accept(this);
693 node->ifTrue()->accept(this);
695 node->ifFalse()->accept(this);
697 void visitIndexExpression(IndexExpression *node) {
698 node->left()->accept(this);
699 node->right()->accept(this);
701 void visitFloatLiteral(FloatLiteral *node) {
703 void visitWhileStatement(WhileStatement *node) {
704 node->condition()->accept(this);
705 node->body()->accept(this);
707 void visitBreakStatement(BreakStatement *node) {
709 void visitContinueStatement(ContinueStatement *node) {
711 void visitStringLiteral(StringLiteral *node) {
713 void visitIncDecExpression(IncDecExpression *node) {
714 node->expression()->accept(this);
716 void visitUnaryExpression(UnaryExpression *node) {
718 node->tag()->accept(this);
719 node->expression()->accept(this);
721 void visitTernaryExpression(TernaryExpression *node) {
722 node->condition()->accept(this);
723 node->left()->accept(this);
724 node->right()->accept(this);
726 void visitBooleanLiteral(BooleanLiteral *node) {
728 void visitFieldExpression(FieldExpression *node) {
729 node->left()->accept(this);
731 void visitSwitchStatement(SwitchStatement *node) {
732 node->expression()->accept(this);
733 node->defaultCase()->accept(this);
734 for (size_t i = 0; i < node->cases()->length(); i++) {
735 // We don't test case expressions because they are literals.
736 Case *c = node->cases()->at(i);
737 c->statement()->accept(this);
740 void visitArrayLiteral(ArrayLiteral *node) {
741 for (size_t i = 0; i < node->expressions()->length(); i++)
742 node->expressions()->at(i)->accept(this);
744 void visitImportStatement(ImportStatement *node) {
745 if (node->suffix() == TOK_STAR) {
746 // Import every name.
749 GlobalScope *other = node->source()->globalScope();
750 Symbol *sym = other->findPublic(node->name());
752 cc_.reportError(node->pos(), Message_CannotResolveImport, node->name()->chars());
755 link_->scope()->addSymbol(sym);
760 int evaluateDimensions(const SourcePosition &pos, Handle<Type> typeArg, ExpressionList *exprs, int dims[MAX_ARRAY_DEPTH]) {
762 Local<Type> type(zone_, typeArg);
763 while (type->isArray()) {
764 ArrayType *atype = ArrayType::cast(type);
765 dims[level] = atype->isFixedLength()
766 ? atype->fixedLength()
767 : DYNAMIC_ARRAY_SIZE;
768 type = atype->contained();
775 if (level + exprs->length() > MAX_ARRAY_DEPTH) {
776 cc_.reportError(pos, Message_MaximumArrayDepth);
780 bool hadEmptySize = false;
781 for (size_t i = 0; i < exprs->length(); i++) {
782 Expression *expr = exprs->at(i);
784 dims[i] = INFER_ARRAY_SIZE;
790 if (EvaluateForConstant(expr, &box) && box.type() == PrimitiveType_Int32) {
791 int size = box.toInt();
793 cc_.reportError(expr->pos(), Message_BadArraySize);
802 cc_.reportError(expr->pos(), Message_BadDynamicInitializer);
806 dims[i] = EVAL_ARRAY_SIZE;
809 return level + exprs->length();
812 // This function computes missing dimension sizes based on a literal
813 // initializer. We don't really handle any size rules here; we just
814 // do a really dumb inference.
815 bool inferFixedArrayDimensions(ArrayLiteral *lit, Handle<Type> contained, int dims[MAX_ARRAY_DEPTH], int levels) {
816 for (int i = 0; i < levels; i++) {
817 if (dims[i] == EVAL_ARRAY_SIZE || dims[i] == DYNAMIC_ARRAY_SIZE) {
818 // The following are invalid:
819 // new x[<expr>] = {...}
820 // new Type:x = {...} // where Type is a non-fixed array type
821 cc_.reportError(lit->pos(), Message_CannotInitializeEvalArray);
825 if (dims[i] == INFER_ARRAY_SIZE) {
826 // Character arrays are always dynamic when inferred from string literals.
827 if (i == levels - 1 && contained->isChar())
828 dims[i] = DYNAMIC_ARRAY_SIZE;
830 dims[i] = lit->expressions()->length();
833 if (i != levels - 1) {
834 // Fixed array literals are guaranteed to have at least one expression.
835 Expression *next = lit->expressions()->at(0);
836 if (!next->isArrayLiteral()) {
837 // Whelp... this array is just malformed. Not the best error message
839 cc_.reportError(next->pos(), Message_ArraySizeCannotBeDetermined);
842 lit = next->toArrayLiteral();
849 ArrayType *buildArrayType(Handle<Type> contained, TypeQualifiers quals, int dims[MAX_ARRAY_DEPTH], size_t postlevels) {
850 Local<Type> type(zone_, contained);
852 for (size_t i = postlevels - 1; i < postlevels; i--) {
853 int size = dims[i] > 0
855 : ArrayType::DYNAMIC_ARRAY_SIZE;
857 if ((type = zone_->types()->newArray(contained, size)) == NULL)
859 if ((type = zone_->types()->qualify(type, quals)) == NULL)
862 return ArrayType::cast(type);
865 bool fillFunctionType(Handle<FunctionType> fun, const FunctionSignature &sig) {
866 Local<Type> type(zone_);
867 if (!fun->returnType()) {
868 if ((type = bindType(sig.returnType(), TypeQual_None)) == NULL)
870 fun->setReturnType(type);
876 Local<FixedArray> params(zone_, FixedArray::New(zone_, sig.parameters()->length(), Heap::Tenure_Old));
880 for (size_t i = 0; i < sig.parameters()->length(); i++) {
881 Parameter *param = sig.parameters()->at(i);
882 if ((type = bindType(param->type(), param->quals())) == NULL)
885 assert(!type->isArray());
888 int dims[MAX_ARRAY_DEPTH];
889 int levels = evaluateDimensions(param->pos(), type, param->dims(), dims);
893 // If we got extra dimensions, we need to build a new type.
894 // Unlike variables, we do not infer anything about array
895 // sizes from its default initializer.
897 if ((type = buildArrayType(type, param->quals(), dims, param->dims()->length())) == NULL)
901 if (ArrayType::cast(type)->innermost()->isVoid()) {
902 cc_.reportError(param->type()->pos(), Message_CannotDeclareVoid);
907 if (param->reference()) {
908 if (!type->isPod()) {
909 cc_.reportError(param->pos(), Message_ArrayCantBeReference);
912 if (param->quals() & TypeQual_Const) {
913 cc_.reportError(param->pos(), Message_CannotConstReference);
916 if ((type = zone_->types()->getReference(type, false)) == NULL)
919 if (param->quals() & TypeQual_Const) {
920 if (!type->isArray() && !type->isStruct()) {
921 cc_.reportError(param->pos(), Message_InvalidConstOnFormal);
926 if (type->isVoid()) {
927 cc_.reportError(param->type()->pos(), Message_CannotDeclareVoid);
931 params->set(zone_, i, type);
932 param->sym()->setType(type);
935 fun->setParameterTypes(params);
940 Type *bindType(Expression *expr, TypeQualifiers quals) {
941 Local<Type> type(zone_);
944 // If no type was declared, we return int32.
945 type = zone_->types()->getPrimitive(PrimitiveType_Int32);
949 NameProxy *proxy = expr->asNameProxy();
952 Symbol *sym = proxy->sym();
956 if (!sym->isType()) {
957 cc_.reportError(expr->pos(), Message_IdentifierIsNotAType, sym->name()->chars());
964 return zone_->types()->qualify(type, quals);
969 PoolAllocator &pool_;
971 TranslationUnit *unit_;
972 AutoLinkScope *link_;
976 ke::BindNamesAndTypes(Zone *zone, CompileContext &cc, TranslationUnit *unit)
978 AutoEnterCompileContext enter(cc, unit);
979 NameBinder binder(zone, cc, unit);