public object VisitReturnStmt(Statements.Return stmt) { object value = null; if (stmt.Value != null) { value = Evaluate(stmt.Value); } throw new CLex.Return(value); }
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); }