コード例 #1
0
ファイル: Interpreter.cs プロジェクト: IBricchi/iglu_learning
        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)
            {
                Program.Error(stmt.keyword, "Cannot return from top level code");
            }

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

            return(null);
        }