public void Visit(Ast.Stmt.Vardef v) { this.m_symbolTable.Insert(v.Item.Formal.Name, v); if (v.Item.Expr != null) { Visit(v.Item.Expr.Value); } }
public void Visit(Ast.Stmt.Vardef v) { if (v.Item.Expr != null) { Visit(v.Item.Expr.Value); if (v.Item.Formal.Type != v.Item.Expr.Value.ActualType) { m_errorList.Add("Type Error: Cannot assign " + v.Item.Expr.Value.ActualType + " to variable of type " + v.Item.Formal.Type); } } }
public void Visit(Ast.Stmt.Funcdef f) { this.m_FunctionStack.Push(f); //System.Console.WriteLine("Push " + f); this.m_symbolTable.Insert(f.Item.Formal.Name, f); // Add formal params to defs this.m_symbolTable.PushNewScope(); foreach (var formal in f.Item.FormalList) { Ast.Stmt.Vardef vd = (Ast.Stmt.Vardef)Ast.Stmt.Vardef.NewVardef(new Ast.VardefType(new System.Tuple <Ast.Formal, FSharpOption <Ast.Expr> >(formal.Formal, new FSharpOption <Ast.Expr>(null)))); this.m_symbolTable.Insert(vd.Item.Formal.Name, vd); } Visit(f.Item.Body); this.m_FunctionStack.Pop(); //System.Console.WriteLine("Pop " + f); this.m_symbolTable.PopScope(); }