public override void Accept(BinaryExpression binop) { if (binop.Operation == BinaryOperation.Assign && binop.Left is NameExpression) { NameExpression name = binop.Left as NameExpression; if (!symbolTable.IsSymbolDefined(name.Value)) { symbolTable.AddSymbol(name.Value); } } binop.VisitChildren(this); }
public override void Accept(BinaryExpression binop) { if (binop.Operation == BinaryOperation.Assign) { if (binop.Left is NameExpression) { NameExpression ident = (NameExpression)binop.Left; if (!symbolTable.IsSymbolDefined(ident.Value)) { symbolTable.AddSymbol(ident.Value); } } } binop.Right.Visit(this); }
public override void Accept(NameExpression ident) { if (symbolTable.IsSymbolDefined(ident.Value)) { Symbol sym = symbolTable.GetSymbol(ident.Value); if (sym.Type == SymbolType.Local) { methodBuilder.EmitInstruction(ident.Location, Opcode.LoadLocal, sym.Index); } else { methodBuilder.EmitInstruction(ident.Location, Opcode.LoadGlobal, methodBuilder.Module.DefineConstant(new IodineName(ident.Value))); } } else { methodBuilder.EmitInstruction(ident.Location, Opcode.LoadGlobal, methodBuilder.Module.DefineConstant(new IodineName(ident.Value))); } }