예제 #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);
        }