void Resolver::visit(NameLValue& lvalue, int dummy) { // Look up the variable in this procedure. gc<ResolvedName> resolved = findLocal(lvalue.name()); // TODO(bob): Report error if variable is immutable. if (!resolved.isNull()) { lvalue.setResolved(resolved); return; } // See if it's a closure. int closure = resolveClosure(lvalue.name()); if (closure != -1) { // TODO(bob): Report error if variable is immutable. gc<ResolvedName> resolved = new ResolvedName(-1); resolved->makeClosure(closure); lvalue.setResolved(resolved); return; } // Not a local variable. See if it's a top-level one. int module = compiler_.getModuleIndex(module_); int index = module_.findVariable(lvalue.name()); if (index != -1) { lvalue.setResolved(new ResolvedName(module, index)); return; } compiler_.reporter().error(lvalue.pos(), "Variable '%s' is not defined.", lvalue.name()->cString()); // Put a fake slot in so we can continue and report more errors. lvalue.setResolved(new ResolvedName(0)); }
void ExprCompiler::visit(NameLValue& lvalue, int value) { compileAssignment(lvalue.pos(), lvalue.resolved(), value, false); }