public object visitReturnStmt(Stmt.Return stmt) { Object value = null; if (stmt.Value != null) { value = evaluate(stmt.Value); } throw new LoxReturn(value); }
public object visitReturnStmt(Stmt.Return stmt) { if (currentFunction == FunctionType.NONE) { Lox.error(stmt.Keyword, "Cannot return from top-level code"); } if (stmt.Value != null) { if (currentFunction == FunctionType.INITIALIZER) { Lox.error(stmt.Keyword, "Cannot return a value from initilizer;"); } resolve(stmt.Value); } return(null); }