示例#1
0
 public object VisitReturnStatement(Statement.Return statement)
 {
     if (statement.value != null)
     {
         Resolve(statement.value);
     }
     return(null);
 }
        public object VisitReturnStatement(Statement.Return statement)
        {
            object value = null;

            if (statement.value != null)
            {
                value = Evaluate(statement.value);
            }

            throw new ReturnException(value);
        }
示例#3
0
 protected override Value?Visit(Statement.Return ret)
 {
     if (ret.Value == null)
     {
         // No return value
         Builder.Ret();
     }
     else
     {
         // We also need to compile the return value
         var value = VisitNonNull(ret.Value);
         Builder.Ret(value);
     }
     return(null);
 }
示例#4
0
        public override Statement VisitSTMR_Break([NotNull] S_ScriptParser.STMR_BreakContext context)
        {
            Statement x = null;

            if (context.K_BREAK() != null)
            {
                x = new Statement.Break(this._Host, this._Master);
            }
            else if (context.K_RETURN() != null)
            {
                x = new Statement.Return(this._Host, this._Master);
            }
            else if (context.K_EXIT() != null)
            {
                x = new Statement.Exit(this._Host, this._Master);
            }
            else
            {
                throw new Exception();
            }

            return(x);
        }
示例#5
0
        protected override object?Visit(Statement.Return ret)
        {
            Debug.Assert(currentProcReturnType != null);

            base.Visit(ret);
            Type retType = ret.Value == null ? Type.Unit : System.TypeOf(ret.Value);

            if (!currentProcReturnType.Equals(retType))
            {
                // Error, work out what we know
                Debug.Assert(currentProcSignature != null);
                var signature  = (Syntax.ParseTree.Expression.ProcSignature?)currentProcSignature.ParseTreeNode;
                var definition = (Syntax.ParseTree.IParseTreeElement?)signature?.Return ?? signature?.CloseParen;
                var wrong      = ((Node?)FindDeepestReturnValue(ret.Value) ?? ret)?.ParseTreeNode;
                System.Report(new TypeMismatchError(currentProcReturnType, retType)
                {
                    Defined           = definition,
                    Wrong             = wrong,
                    Context           = "return value",
                    ImplicitlyDefined = signature != null && signature.Return == null,
                });
            }
            return(null);
        }
示例#6
0
 public object VisitReturnStatement(Statement.Return stmt)
 {
     stmt.Expr.Accept(this);
     addInstruction(0x0F); // return
     return(null);
 }
示例#7
0
 public object VisitReturnStatement(Statement.Return stmt)
 {
     returningBranch = true;
     return(stmt.Expr.Accept(this));
 }
示例#8
0
 public Token visitReturnStatement(Statement.Return returnStmt)
 {
     return(returnStmt.keyword);
 }