internal override void Accept(NodeVar var) { builder.currentLineNumber = var.StartLine; var.vars.ForEach(def => { if (def.Value == null) builder.OpNull(); else def.Value.Visit(this); builder.OpKStore(def.Key); if (!var.isResultRequired) builder.OpPop(); }); }
internal virtual void Accept(NodeVar var) { builder.currentLineNumber = var.StartLine; var.vars.ForEach(def => { if (def.Value != null) def.Value.Visit(this); else builder.OpNull(); uint local; builder.AddLocal(def.Key, out local); builder.OpLStore(local); if (!var.isResultRequired) builder.OpPop(); }); }
void ASTVisitor.Accept(NodeVar value) { Accept(value); }
private Node ParseVar() { // The first token we'll have is 'var', so skip it. var var = new NodeVar(Location); Advance(); // Now, let's get us some variables! while (true) { if (!TokensRemain) { log.Error(tokens[-1].location, "End of file reached, expected a variable declaration."); break; } // Variables are all identifiers, so do that. string name; ExpectIdentifier(out name, ""); Node value = null; // Vars don't have to be assigned to initially, they default to null. // Initialization? if (Check(ASSIGN)) { Advance(); value = Expression(); } // Add it to our var list var.vars.Add(new KeyValuePair<string, Node>(name, value)); // If there's a comma, we expect another definition: if (Check(COMMA)) Advance(); else break; } return var; }