public Void VisitReturnStmt(Stmt.Return stmt) { object value = null; if (stmt.value != null) { value = Evaluate(stmt.value); } throw new Return(value); }
public Void VisitReturnStmt(Stmt.Return stmt) { if (currentFunction == FunctionType.NONE) { ElizScriptCompiler.Error(stmt.keyword, "Cannot return from top-level code."); } if (stmt.value != null) { if (currentFunction == FunctionType.INITIALIZER) { ElizScriptCompiler.Error(stmt.keyword, "Cannot return a value from an initializer."); } Resolve(stmt.value); } return(null); }