// Adds a new Key Value Pair to the current scope public bool Insert(String name, Ast.Stmt def) { KeyValuePair <String, Ast.Stmt> ins = new KeyValuePair <String, Ast.Stmt>(name, def); this.m_symbolTable[m_symbolTable.Count - 1].TryAdd(name, def); Console.WriteLine(ins); return(true); }
// Stmt public void Visit(Ast.Stmt stmt) { switch (stmt) { case Ast.Stmt.Assign a: Visit(a); break; case Ast.Stmt.While w: Visit(w); break; case Ast.Stmt.Seq s: Visit(s); break; case Ast.Stmt.IfThenElse i: Visit(i); break; case Ast.Stmt.Vardef v: Visit(v); break; case Ast.Stmt.Funcdef f: Visit(f); break; case Ast.Stmt.Expr e: Visit(e); break; case Ast.Stmt.Return r: Visit(r); break; } }
private void ExecuteStmt(Ast.Stmt stmt, ScriptEnv env) { var runner = _stmtRunners[stmt.GetType()]; runner(stmt, env); }