示例#1
0
        public Void VisitReturnStmt(Stmt.Return stmt)
        {
            object value = null;

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

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

            if (stmt.value != null)
            {
                if (currentFunction == FunctionType.INITIALIZER)
                {
                    ElizScriptCompiler.Error(stmt.keyword,
                                             "Cannot return a value from an initializer.");
                }

                Resolve(stmt.value);
            }

            return(null);
        }