public string VisitReturnStmt(Stmt.Return stmt) { if (stmt.Value == null) { return("(return)"); } return(Parenthesize("return", stmt.Value)); }
public object VisitReturnStmt(Stmt.Return stmt) { object value = null; if (stmt.Value != null) { value = Evaluate(stmt.Value); } throw new Return(value); }
public object VisitReturnStmt(Stmt.Return stmt) { if (_currentFunction == FunctionType.NONE) { _logger.Error(stmt.Keyword, "Cannot return from top-level code."); } if (stmt.Value != null) { if (_currentFunction == FunctionType.INITIALIZER) { _logger.Error(stmt.Keyword, "Cannot return a value from an initializer."); } Resolve(stmt.Value); } return(null); }