コード例 #1
0
        public object VisitReturnStmt(Statements.Return stmt)
        {
            object value = null;

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

            throw new CLex.Return(value);
        }
コード例 #2
0
        object Statements.IVisitor <object> .VisitReturnStmt(Statements.Return stmt)
        {
            if (currentFunction == FunctionType.NONE)
            {
                Lox.Error(stmt.Keyword, "Cannot return from top-level code.");
            }

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

            return(null);
        }