Esempio n. 1
0
        public Void VisitReturnStmt(Stmt.Return stmt)
        {
            object value = null;

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

            throw new Return(value);
        }
Esempio n. 2
0
        public object VisitReturnStmt(Stmt.Return stmt)
        {
            object value = null;

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

            throw new ReturnException(value);
        }
Esempio n. 3
0
        public Void VisitReturnStmt(Stmt.Return stmt)
        {
            if (_currentFunction == FunctionType.NONE)
            {
                Lox.Error(stmt.Keyword, "Can't return from top-level code.");
            }
            if (stmt.Value != null)
            {
                if (_currentFunction == FunctionType.INITIALIZER)
                {
                    Lox.Error(stmt.Keyword, "Can't return a value from an initializer");
                }
                Resolve(stmt.Value);
            }

            return(null);
        }
Esempio n. 4
0
        public object VisitReturnStmt(Stmt.Return stmt)
        {
            if (currentFunction == FunctionType.NONE)
            {
                Lox.Error(stmt.keyword, "Return statement must be inside a function.");
            }
            if (stmt.value != null)
            {
                if (currentFunction == FunctionType.INITIALIZER)
                {
                    Lox.Error(stmt.keyword, "Cannot return a value from an initializer.");
                }

                Resolve(stmt.value);
            }

            return(null);
        }
Esempio n. 5
0
        public object VisitReturnStmt(Stmt.Return stmt)
        {
            if (currentFunction == FunctionType.NONE)
            {
                Program.Error(stmt.keyword, "Can't return from top-level code.");
            }

            if (stmt.value != null)
            {
                if (currentFunction == FunctionType.INITIALIZER)
                {
                    Program.Error(stmt.keyword, "Can't return a value from an initializer.");
                }
                Resolve(stmt.value);
            }

            return(null);
        }
Esempio n. 6
0
        public object Visit(Stmt.Return _return)
        {
            if (_currentFunction == FunctionType.NONE)
            {
                Lox.Error(_return.keyword, "Cannot return from top-level code.");
            }

            if (_return.value != null)
            {
                if (_currentFunction == FunctionType.INITIALIZER)
                {
                    Lox.Error(_return.keyword, "Cannot return a value from an initializer.");
                }
                Resolve(_return.value);
            }

            return(null);
        }
Esempio n. 7
0
 public string VisitReturnStmt(Stmt.Return stmt)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 public string VisitReturnStmt(Stmt.Return stmt) => throw new System.NotImplementedException();