Beispiel #1
0
        public Void visitReturnStmt(Stmt.Return stmt)
        {
            object value = null;

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

            throw new Return(value);
        }
Beispiel #2
0
        public Void visitReturnStmt(Stmt.Return stmt)
        {
            if (currentFunction == FunctionType.NONE)
            {
                Program.Error(stmt.keyword, "Cannot return from top level code");
            }

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

            return(null);
        }