Example #1
0
 public void Visit(Ast.Stmt.Return r)
 {
     Visit(r.Item.Expr.Value);
     Ast.Stmt.Funcdef fd = (Ast.Stmt.Funcdef)r.Item.Decl.Value;
     Ast.Expr         e  = r.Item.Expr.Value;
     if (fd.Item.Formal.Type != e.ActualType)
     {
         m_errorList.Add("Type Error: Cannot return " + e.ActualType +
                         " from function " + fd.Item.Formal.Name +
                         " returning " + fd.Item.Formal.Type);
     }
 }
Example #2
0
 public void Visit(Ast.Stmt.Return r)
 {
     Visit(r.Item.Expr.Value);
     if (this.m_FunctionStack.Count == 0)
     {
         r.Item.Decl = (Ast.Stmt.Funcdef)Ast.Stmt.Funcdef.NewFuncdef(new Ast.FuncdefType(new System.Tuple <Ast.Formal, FSharpList <Ast.VardefType>, Ast.Stmt>(new Ast.Formal("$global", Ast.Type.IntType), null, null)));
         // FuncionStack is no longer needed, anything after returning $global is not allowed
     }
     else
     {
         r.Item.Decl = this.m_FunctionStack.Peek();
     }
     Ast.Stmt.Funcdef fd = (Ast.Stmt.Funcdef)r.Item.Decl.Value;
     //System.Console.WriteLine("Return " + fd.Item.Formal.Name);
 }