Revision: 10758
Author:   [email protected]
Date:     Mon Feb 20 05:48:24 2012
Log: Make built-ins strict mode conforming, and support a --use-strict flag.

* Turned all uses of 'const' into 'var'.
* Turned all uses of local 'function' into 'var'.
* Added a couple of missing toplevel 'var' declarations.

One consequence is that the properties on the builtin object  are no longer
non-writable, and I had to adapt one test. Is that a problem?

Unfortunately, we cannot actually switch the library scripts to strict mode
by default, because that makes observable things like poisoned .caller properties
for library functions.

Also removed dead flag code in Compiler::Compile.

[email protected]
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9415010
http://code.google.com/p/v8/source/detail?r=10758

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/apinatives.js
 /branches/bleeding_edge/src/array.js
 /branches/bleeding_edge/src/collection.js
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/d8.js
 /branches/bleeding_edge/src/date.js
 /branches/bleeding_edge/src/debug-debugger.js
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/math.js
 /branches/bleeding_edge/src/messages.js
 /branches/bleeding_edge/src/mirror-debugger.js
 /branches/bleeding_edge/src/proxy.js
 /branches/bleeding_edge/src/regexp.js
 /branches/bleeding_edge/src/runtime.js
 /branches/bleeding_edge/src/string.js
 /branches/bleeding_edge/src/uri.js
 /branches/bleeding_edge/src/v8natives.js
 /branches/bleeding_edge/test/cctest/test-debug.cc
 /branches/bleeding_edge/test/mjsunit/builtins.js

=======================================
--- /branches/bleeding_edge/include/v8.h        Mon Feb 20 04:57:23 2012
+++ /branches/bleeding_edge/include/v8.h        Mon Feb 20 05:48:24 2012
@@ -1198,7 +1198,7 @@
    * passed in as parameters.
    */
   V8EXPORT static Local<String> Concat(Handle<String> left,
-                                       Handle<String>right);
+                                       Handle<String> right);

   /**
    * Creates a new external string using the data defined in the given
=======================================
--- /branches/bleeding_edge/src/apinatives.js   Thu Aug 11 00:22:16 2011
+++ /branches/bleeding_edge/src/apinatives.js   Mon Feb 20 05:48:24 2012
@@ -37,8 +37,8 @@
 }


-const kApiFunctionCache = {};
-const functionCache = kApiFunctionCache;
+var kApiFunctionCache = {};
+var functionCache = kApiFunctionCache;


 function Instantiate(data, name) {
=======================================
--- /branches/bleeding_edge/src/array.js        Fri Feb 17 02:06:26 2012
+++ /branches/bleeding_edge/src/array.js        Mon Feb 20 05:48:24 2012
@@ -27,7 +27,7 @@

// This file relies on the fact that the following declarations have been made
 // in runtime.js:
-// const $Array = global.Array;
+// var $Array = global.Array;

 // -------------------------------------------------------------------

@@ -757,7 +757,7 @@
   }
   var receiver = %GetDefaultReceiver(comparefn);

-  function InsertionSort(a, from, to) {
+  var InsertionSort = function InsertionSort(a, from, to) {
     for (var i = from + 1; i < to; i++) {
       var element = a[i];
       for (var j = i - 1; j >= from; j--) {
@@ -771,9 +771,9 @@
       }
       a[j + 1] = element;
     }
-  }
-
-  function QuickSort(a, from, to) {
+  };
+
+  var QuickSort = function QuickSort(a, from, to) {
     // Insertion sort is faster for short arrays.
     if (to - from <= 10) {
       InsertionSort(a, from, to);
@@ -841,12 +841,12 @@
     }
     QuickSort(a, from, low_end);
     QuickSort(a, high_start, to);
-  }
+  };

   // Copy elements in the range 0..length from obj's prototype chain
// to obj itself, if obj has holes. Return one more than the maximal index
   // of a prototype property.
-  function CopyFromPrototype(obj, length) {
+  var CopyFromPrototype = function CopyFromPrototype(obj, length) {
     var max = 0;
     for (var proto = obj.__proto__; proto; proto = proto.__proto__) {
       var indices = %GetArrayKeys(proto, length);
@@ -873,12 +873,12 @@
       }
     }
     return max;
-  }
+  };

   // Set a value of "undefined" on all indices in the range from..to
   // where a prototype of obj has an element. I.e., shadow all prototype
   // elements in that range.
-  function ShadowPrototypeElements(obj, from, to) {
+  var ShadowPrototypeElements = function(obj, from, to) {
     for (var proto = obj.__proto__; proto; proto = proto.__proto__) {
       var indices = %GetArrayKeys(proto, to);
       if (indices.length > 0) {
@@ -901,9 +901,9 @@
         }
       }
     }
-  }
-
-  function SafeRemoveArrayHoles(obj) {
+  };
+
+  var SafeRemoveArrayHoles = function SafeRemoveArrayHoles(obj) {
// Copy defined elements from the end to fill in all holes and undefineds // in the beginning of the array. Write undefineds and holes at the end
     // after loop is finished.
@@ -958,7 +958,7 @@

     // Return the number of defined elements.
     return first_undefined;
-  }
+  };

   var length = TO_UINT32(this.length);
   if (length < 2) return this;
@@ -1373,7 +1373,7 @@

   var specialFunctions = %SpecialArrayFunctions({});

-  function getFunction(name, jsBuiltin, len) {
+  var getFunction = function(name, jsBuiltin, len) {
     var f = jsBuiltin;
     if (specialFunctions.hasOwnProperty(name)) {
       f = specialFunctions[name];
@@ -1382,7 +1382,7 @@
       %FunctionSetLength(f, len);
     }
     return f;
-  }
+  };

   // Set up non-enumerable functions of the Array.prototype object and
   // set their names.
=======================================
--- /branches/bleeding_edge/src/collection.js   Thu Jan  5 04:55:06 2012
+++ /branches/bleeding_edge/src/collection.js   Mon Feb 20 05:48:24 2012
@@ -25,10 +25,11 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
-const $Set = global.Set;
-const $Map = global.Map;
-const $WeakMap = global.WeakMap;
+"use strict";
+
+var $Set = global.Set;
+var $Map = global.Map;
+var $WeakMap = global.WeakMap;

 //-------------------------------------------------------------------

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Thu Feb 16 00:38:11 2012
+++ /branches/bleeding_edge/src/compiler.cc     Mon Feb 20 05:48:24 2012
@@ -497,13 +497,6 @@
     // for small sources, odds are that there aren't many functions
     // that would be compiled lazily anyway, so we skip the preparse step
     // in that case too.
-    int flags = kNoParsingFlags;
-    if ((natives == NATIVES_CODE) || FLAG_allow_natives_syntax) {
-      flags |= kAllowNativesSyntax;
-    }
-    if (natives != NATIVES_CODE && FLAG_harmony_scoping) {
-      flags |= EXTENDED_MODE;
-    }

     // Create a script object describing the script to be compiled.
     Handle<Script> script = FACTORY->NewScript(source);
@@ -524,6 +517,7 @@
     info.MarkAsGlobal();
     info.SetExtension(extension);
     info.SetPreParseData(pre_data);
+    if (FLAG_use_strict) info.SetLanguageMode(STRICT_MODE);
     result = MakeFunctionInfo(&info);
     if (extension == NULL && !result.is_null()) {
       compilation_cache->PutScript(source, result);
=======================================
--- /branches/bleeding_edge/src/d8.js   Mon Nov 28 04:11:00 2011
+++ /branches/bleeding_edge/src/d8.js   Mon Feb 20 05:48:24 2012
@@ -25,6 +25,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+"use strict";
+
 String.prototype.startsWith = function (str) {
   if (str.length > this.length) {
     return false;
@@ -76,7 +78,7 @@


 // Global object holding debugger related constants and state.
-const Debug = {};
+var Debug = {};


// Debug events which can occour in the V8 JavaScript engine. These originate
@@ -111,7 +113,7 @@


 // Current debug state.
-const kNoFrame = -1;
+var kNoFrame = -1;
 Debug.State = {
   currentFrame: kNoFrame,
   displaySourceStartLine: -1,
@@ -123,8 +125,8 @@
 var last_cmd_line = '';
//var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined.
 var lol_next_dump_index = 0;
-const kDefaultLolLinesToPrintAtATime = 10;
-const kMaxLolLinesToPrintAtATime = 1000;
+var kDefaultLolLinesToPrintAtATime = 10;
+var kMaxLolLinesToPrintAtATime = 1000;
 var repeat_cmd_line = '';
 var is_running = true;

@@ -2629,7 +2631,7 @@

 // Mapping of some control characters to avoid the \uXXXX syntax for most
 // commonly used control cahracters.
-const ctrlCharMap_ = {
+var ctrlCharMap_ = {
   '\b': '\\b',
   '\t': '\\t',
   '\n': '\\n',
@@ -2641,12 +2643,12 @@


// Regular expression testing for ", \ and control characters (0x00 - 0x1F).
-const ctrlCharTest_ = new RegExp('["\\\\\x00-\x1F]');
+var ctrlCharTest_ = new RegExp('["\\\\\x00-\x1F]');


 // Regular expression matching ", \ and control characters (0x00 - 0x1F)
 // globally.
-const ctrlCharMatch_ = new RegExp('["\\\\\x00-\x1F]', 'g');
+var ctrlCharMatch_ = new RegExp('["\\\\\x00-\x1F]', 'g');


 /**
@@ -2688,12 +2690,12 @@
  * @return {string} JSON formatted Date value
  */
 function DateToISO8601_(value) {
-  function f(n) {
+  var f = function(n) {
     return n < 10 ? '0' + n : n;
-  }
-  function g(n) {
+  };
+  var g = function(n) {
     return n < 10 ? '00' + n : n < 100 ? '0' + n : n;
-  }
+  };
   return builtins.GetUTCFullYearFrom(value)         + '-' +
           f(builtins.GetUTCMonthFrom(value) + 1)    + '-' +
           f(builtins.GetUTCDateFrom(value))         + 'T' +
=======================================
--- /branches/bleeding_edge/src/date.js Mon Nov 28 04:11:00 2011
+++ /branches/bleeding_edge/src/date.js Mon Feb 20 05:48:24 2012
@@ -28,17 +28,16 @@

// This file relies on the fact that the following declarations have been made
 // in v8natives.js:
-// const $isFinite = GlobalIsFinite;
+// var $isFinite = GlobalIsFinite;

 // -------------------------------------------------------------------

 // This file contains date support implemented in JavaScript.

-
 // Keep reference to original values of some global properties.  This
 // has the added benefit that the code in this file is isolated from
 // changes to these properties.
-const $Date = global.Date;
+var $Date = global.Date;

 // Helper function to throw error.
 function ThrowDateTypeError() {
=======================================
--- /branches/bleeding_edge/src/debug-debugger.js       Fri Jan 13 05:09:52 2012
+++ /branches/bleeding_edge/src/debug-debugger.js       Mon Feb 20 05:48:24 2012
@@ -26,14 +26,14 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Default number of frames to include in the response to backtrace request.
-const kDefaultBacktraceLength = 10;
-
-const Debug = {};
+var kDefaultBacktraceLength = 10;
+
+var Debug = {};

// Regular expression to skip "crud" at the beginning of a source line which is
 // not really code. Currently the regular expression matches whitespace and
 // comments.
-const sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;
+var sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;

// Debug events which can occour in the V8 JavaScript engine. These originate
 // from the API include file debug.h.
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h      Mon Feb 20 04:57:23 2012
+++ /branches/bleeding_edge/src/flag-definitions.h      Mon Feb 20 05:48:24 2012
@@ -106,7 +106,9 @@
 //
 #define FLAG FLAG_FULL

-// Flags for experimental language features.
+// Flags for language modes and experimental language features.
+DEFINE_bool(use_strict, false, "enforce strict mode")
+
 DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof")
 DEFINE_bool(harmony_scoping, false, "enable harmony block scoping")
 DEFINE_bool(harmony_modules, false, "enable harmony modules")
=======================================
--- /branches/bleeding_edge/src/math.js Tue Jan  3 02:45:28 2012
+++ /branches/bleeding_edge/src/math.js Mon Feb 20 05:48:24 2012
@@ -29,15 +29,15 @@
 // Keep reference to original values of some global properties.  This
 // has the added benefit that the code in this file is isolated from
 // changes to these properties.
-const $floor = MathFloor;
-const $random = MathRandom;
-const $abs = MathAbs;
+var $floor = MathFloor;
+var $random = MathRandom;
+var $abs = MathAbs;

 // Instance class name can only be set on functions. That is the only
 // purpose for MathConstructor.
 function MathConstructor() {}
 %FunctionSetInstanceClassName(MathConstructor, 'Math');
-const $Math = new MathConstructor();
+var $Math = new MathConstructor();
 $Math.__proto__ = $Object.prototype;
 %SetProperty(global, "Math", $Math, DONT_ENUM);

=======================================
--- /branches/bleeding_edge/src/messages.js     Tue Feb  7 01:31:06 2012
+++ /branches/bleeding_edge/src/messages.js     Mon Feb 20 05:48:24 2012
@@ -25,17 +25,18 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+"use strict";

 // -------------------------------------------------------------------
 //
 // If this object gets passed to an error constructor the error will
 // get an accessor for .message that constructs a descriptive error
 // message on access.
-const kAddMessageAccessorsMarker = { };
+var kAddMessageAccessorsMarker = { };

 // This will be lazily initialized when first needed (and forcibly
 // overwritten even though it's const).
-const kMessages = 0;
+var kMessages = 0;

 function FormatString(format, message) {
   var args = %MessageGetArguments(message);
@@ -603,7 +604,7 @@
   this.end = end;
 }

-const kLineLengthLimit = 78;
+var kLineLengthLimit = 78;

 /**
* Restrict source location start and end positions to make the source slice
@@ -748,18 +749,18 @@
   // can't rely on 'this' being the same as 'obj'.
   var hasBeenSet = false;
   var value;
-  function getter() {
+  var getter = function() {
     if (hasBeenSet) {
       return value;
     }
     hasBeenSet = true;
     value = fun(obj);
     return value;
-  }
-  function setter(v) {
+  };
+  var setter = function(v) {
     hasBeenSet = true;
     value = v;
-  }
+  };
   %DefineOrRedefineAccessorProperty(obj, name, GETTER, getter, DONT_ENUM);
   %DefineOrRedefineAccessorProperty(obj, name, SETTER, setter, DONT_ENUM);
 }
@@ -1090,7 +1091,7 @@
 function SetUpError() {
   // Define special error type constructors.

-  function DefineError(f) {
+  var DefineError = function(f) {
     // Store the error function in both the global object
     // and the runtime object. The function is fetched
     // from the runtime object when throwing errors from
@@ -1106,7 +1107,7 @@
       // However, it can't be an instance of the Error object because
       // it hasn't been properly configured yet.  Instead we create a
       // special not-a-true-error-but-close-enough object.
-      function ErrorPrototype() {}
+      var ErrorPrototype = function() {};
       %FunctionSetPrototype(ErrorPrototype, $Object.prototype);
       %FunctionSetInstanceClassName(ErrorPrototype, 'Error');
       %FunctionSetPrototype(f, new ErrorPrototype());
@@ -1148,7 +1149,7 @@
       }
     });
     %SetNativeFlag(f);
-  }
+  };

   DefineError(function Error() { });
   DefineError(function TypeError() { });
@@ -1167,8 +1168,8 @@

 // Global list of error objects visited during ErrorToString. This is
 // used to detect cycles in error toString formatting.
-const visited_errors = new InternalArray();
-const cyclic_error_marker = new $Object();
+var visited_errors = new InternalArray();
+var cyclic_error_marker = new $Object();

 function ErrorToStringDetectCycle(error) {
   if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker;
@@ -1213,4 +1214,4 @@

 // Boilerplate for exceptions for stack overflows. Used from
 // Isolate::StackOverflow().
-const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
+var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
=======================================
--- /branches/bleeding_edge/src/mirror-debugger.js      Mon Nov 28 04:11:00 2011
+++ /branches/bleeding_edge/src/mirror-debugger.js      Mon Feb 20 05:48:24 2012
@@ -144,32 +144,32 @@


 // Type names of the different mirrors.
-const UNDEFINED_TYPE = 'undefined';
-const NULL_TYPE = 'null';
-const BOOLEAN_TYPE = 'boolean';
-const NUMBER_TYPE = 'number';
-const STRING_TYPE = 'string';
-const OBJECT_TYPE = 'object';
-const FUNCTION_TYPE = 'function';
-const REGEXP_TYPE = 'regexp';
-const ERROR_TYPE = 'error';
-const PROPERTY_TYPE = 'property';
-const FRAME_TYPE = 'frame';
-const SCRIPT_TYPE = 'script';
-const CONTEXT_TYPE = 'context';
-const SCOPE_TYPE = 'scope';
+var UNDEFINED_TYPE = 'undefined';
+var NULL_TYPE = 'null';
+var BOOLEAN_TYPE = 'boolean';
+var NUMBER_TYPE = 'number';
+var STRING_TYPE = 'string';
+var OBJECT_TYPE = 'object';
+var FUNCTION_TYPE = 'function';
+var REGEXP_TYPE = 'regexp';
+var ERROR_TYPE = 'error';
+var PROPERTY_TYPE = 'property';
+var FRAME_TYPE = 'frame';
+var SCRIPT_TYPE = 'script';
+var CONTEXT_TYPE = 'context';
+var SCOPE_TYPE = 'scope';

 // Maximum length when sending strings through the JSON protocol.
-const kMaxProtocolStringLength = 80;
+var kMaxProtocolStringLength = 80;

 // Different kind of properties.
-PropertyKind = {};
+var PropertyKind = {};
 PropertyKind.Named   = 1;
 PropertyKind.Indexed = 2;


 // A copy of the PropertyType enum from global.h
-PropertyType = {};
+var PropertyType = {};
 PropertyType.Normal                  = 0;
 PropertyType.Field                   = 1;
 PropertyType.ConstantFunction        = 2;
@@ -183,7 +183,7 @@


 // Different attributes for a property.
-PropertyAttribute = {};
+var PropertyAttribute = {};
 PropertyAttribute.None       = NONE;
 PropertyAttribute.ReadOnly   = READ_ONLY;
 PropertyAttribute.DontEnum   = DONT_ENUM;
@@ -191,12 +191,12 @@


 // A copy of the scope types from runtime.cc.
-ScopeType = { Global: 0,
-              Local: 1,
-              With: 2,
-              Closure: 3,
-              Catch: 4,
-              Block: 5 };
+var ScopeType = { Global: 0,
+                  Local: 1,
+                  With: 2,
+                  Closure: 3,
+                  Catch: 4,
+                  Block: 5 };


 // Mirror hierarchy:
@@ -1237,24 +1237,24 @@
 };


-const kFrameDetailsFrameIdIndex = 0;
-const kFrameDetailsReceiverIndex = 1;
-const kFrameDetailsFunctionIndex = 2;
-const kFrameDetailsArgumentCountIndex = 3;
-const kFrameDetailsLocalCountIndex = 4;
-const kFrameDetailsSourcePositionIndex = 5;
-const kFrameDetailsConstructCallIndex = 6;
-const kFrameDetailsAtReturnIndex = 7;
-const kFrameDetailsFlagsIndex = 8;
-const kFrameDetailsFirstDynamicIndex = 9;
-
-const kFrameDetailsNameIndex = 0;
-const kFrameDetailsValueIndex = 1;
-const kFrameDetailsNameValueSize = 2;
-
-const kFrameDetailsFlagDebuggerFrameMask = 1 << 0;
-const kFrameDetailsFlagOptimizedFrameMask = 1 << 1;
-const kFrameDetailsFlagInlinedFrameIndexMask = 7 << 2;
+var kFrameDetailsFrameIdIndex = 0;
+var kFrameDetailsReceiverIndex = 1;
+var kFrameDetailsFunctionIndex = 2;
+var kFrameDetailsArgumentCountIndex = 3;
+var kFrameDetailsLocalCountIndex = 4;
+var kFrameDetailsSourcePositionIndex = 5;
+var kFrameDetailsConstructCallIndex = 6;
+var kFrameDetailsAtReturnIndex = 7;
+var kFrameDetailsFlagsIndex = 8;
+var kFrameDetailsFirstDynamicIndex = 9;
+
+var kFrameDetailsNameIndex = 0;
+var kFrameDetailsValueIndex = 1;
+var kFrameDetailsNameValueSize = 2;
+
+var kFrameDetailsFlagDebuggerFrameMask = 1 << 0;
+var kFrameDetailsFlagOptimizedFrameMask = 1 << 1;
+var kFrameDetailsFlagInlinedFrameIndexMask = 7 << 2;

 /**
* Wrapper for the frame details information retreived from the VM. The frame
@@ -1732,8 +1732,8 @@
 };


-const kScopeDetailsTypeIndex = 0;
-const kScopeDetailsObjectIndex = 1;
+var kScopeDetailsTypeIndex = 0;
+var kScopeDetailsObjectIndex = 1;

 function ScopeDetails(frame, index) {
   this.break_id_ = frame.break_id_;
=======================================
--- /branches/bleeding_edge/src/proxy.js        Mon Oct 24 09:25:30 2011
+++ /branches/bleeding_edge/src/proxy.js        Mon Feb 20 05:48:24 2012
@@ -25,6 +25,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+"use strict";
+
 global.Proxy = new $Object();

 var $Proxy = global.Proxy
=======================================
--- /branches/bleeding_edge/src/regexp.js       Mon Jan 16 04:38:59 2012
+++ /branches/bleeding_edge/src/regexp.js       Mon Feb 20 05:48:24 2012
@@ -28,7 +28,7 @@
 // Expect $Object = global.Object;
 // Expect $Array = global.Array;

-const $RegExp = global.RegExp;
+var $RegExp = global.RegExp;

 // A recursive descent parser for Patterns according to the grammar of
 // ECMA-262 15.10.1, with deviations noted below.
@@ -413,13 +413,13 @@
// The properties input, $input, and $_ are aliases for each other. When this
   // value is set the value it is set to is coerced to a string.
   // Getter and setter for the input.
-  function RegExpGetInput() {
+  var RegExpGetInput = function() {
     var regExpInput = LAST_INPUT(lastMatchInfo);
     return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
-  }
-  function RegExpSetInput(string) {
+  };
+  var RegExpSetInput = function(string) {
     LAST_INPUT(lastMatchInfo) = ToString(string);
-  }
+  };

   %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE);
   %DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE);
@@ -441,8 +441,8 @@

   // Getter and setter for multiline.
   var multiline = false;
-  function RegExpGetMultiline() { return multiline; }
-  function RegExpSetMultiline(flag) { multiline = flag ? true : false; }
+  var RegExpGetMultiline = function() { return multiline; };
+ var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; };

   %DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline,
                   DONT_DELETE);
@@ -454,7 +454,7 @@
                   DONT_ENUM | DONT_DELETE);


-  function NoOpSetter(ignored) {}
+  var NoOpSetter = function(ignored) {};


   // Static properties set by a successful match.
=======================================
--- /branches/bleeding_edge/src/runtime.js      Mon Nov 28 04:11:00 2011
+++ /branches/bleeding_edge/src/runtime.js      Mon Feb 20 05:48:24 2012
@@ -39,16 +39,16 @@
    -----------------------------------
 */

-// The following const declarations are shared with other native JS files.
-// They are all declared at this one spot to avoid const redeclaration errors.
-const $Object = global.Object;
-const $Array = global.Array;
-const $String = global.String;
-const $Number = global.Number;
-const $Function = global.Function;
-const $Boolean = global.Boolean;
-const $NaN = 0/0;
-const builtins = this;
+// The following declarations are shared with other native JS files.
+// They are all declared at this one spot to avoid redeclaration errors.
+var $Object = global.Object;
+var $Array = global.Array;
+var $String = global.String;
+var $Number = global.Number;
+var $Function = global.Function;
+var $Boolean = global.Boolean;
+var $NaN = 0/0;
+var builtins = this;

 // ECMA-262 Section 11.9.3.
 function EQUALS(y) {
=======================================
--- /branches/bleeding_edge/src/string.js       Mon Feb 20 00:41:13 2012
+++ /branches/bleeding_edge/src/string.js       Mon Feb 20 05:48:24 2012
@@ -28,8 +28,8 @@

// This file relies on the fact that the following declaration has been made
 // in runtime.js:
-// const $String = global.String;
-// const $NaN = 0/0;
+// var $String = global.String;
+// var $NaN = 0/0;


 // Set the String function and constructor.
=======================================
--- /branches/bleeding_edge/src/uri.js  Mon Nov 28 04:11:00 2011
+++ /branches/bleeding_edge/src/uri.js  Mon Feb 20 05:48:24 2012
@@ -250,7 +250,7 @@

 // ECMA-262 - 15.1.3.1.
 function URIDecode(uri) {
-  function reservedPredicate(cc) {
+  var reservedPredicate = function(cc) {
     // #$
     if (35 <= cc && cc <= 36) return true;
     // &
@@ -267,7 +267,7 @@
     if (63 <= cc && cc <= 64) return true;

     return false;
-  }
+  };
   var string = ToString(uri);
   return Decode(string, reservedPredicate);
 }
@@ -275,7 +275,7 @@

 // ECMA-262 - 15.1.3.2.
 function URIDecodeComponent(component) {
-  function reservedPredicate(cc) { return false; }
+  var reservedPredicate = function(cc) { return false; };
   var string = ToString(component);
   return Decode(string, reservedPredicate);
 }
@@ -296,7 +296,7 @@

 // ECMA-262 - 15.1.3.3.
 function URIEncode(uri) {
-  function unescapePredicate(cc) {
+  var unescapePredicate = function(cc) {
     if (isAlphaNumeric(cc)) return true;
     // !
     if (cc == 33) return true;
@@ -316,7 +316,7 @@
     if (cc == 126) return true;

     return false;
-  }
+  };

   var string = ToString(uri);
   return Encode(string, unescapePredicate);
@@ -325,7 +325,7 @@

 // ECMA-262 - 15.1.3.4
 function URIEncodeComponent(component) {
-  function unescapePredicate(cc) {
+  var unescapePredicate = function(cc) {
     if (isAlphaNumeric(cc)) return true;
     // !
     if (cc == 33) return true;
@@ -339,7 +339,7 @@
     if (cc == 126) return true;

     return false;
-  }
+  };

   var string = ToString(component);
   return Encode(string, unescapePredicate);
=======================================
--- /branches/bleeding_edge/src/v8natives.js    Mon Dec 12 02:20:46 2011
+++ /branches/bleeding_edge/src/v8natives.js    Mon Feb 20 05:48:24 2012
@@ -28,18 +28,18 @@
// This file relies on the fact that the following declarations have been made
 //
 // in runtime.js:
-// const $Object = global.Object;
-// const $Boolean = global.Boolean;
-// const $Number = global.Number;
-// const $Function = global.Function;
-// const $Array = global.Array;
-// const $NaN = 0/0;
+// var $Object = global.Object;
+// var $Boolean = global.Boolean;
+// var $Number = global.Number;
+// var $Function = global.Function;
+// var $Array = global.Array;
+// var $NaN = 0/0;
 //
 // in math.js:
-// const $floor = MathFloor
-
-const $isNaN = GlobalIsNaN;
-const $isFinite = GlobalIsFinite;
+// var $floor = MathFloor
+
+var $isNaN = GlobalIsNaN;
+var $isFinite = GlobalIsFinite;

// ----------------------------------------------------------------------------

=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Mon Jan 30 05:07:01 2012 +++ /branches/bleeding_edge/test/cctest/test-debug.cc Mon Feb 20 05:48:24 2012
@@ -4222,9 +4222,9 @@

   // Get mirrors for the three objects with interceptor.
   CompileRun(
-      "named_mirror = debug.MakeMirror(intercepted_named);"
-      "indexed_mirror = debug.MakeMirror(intercepted_indexed);"
-      "both_mirror = debug.MakeMirror(intercepted_both)");
+      "var named_mirror = debug.MakeMirror(intercepted_named);"
+      "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
+      "var both_mirror = debug.MakeMirror(intercepted_both)");
   CHECK(CompileRun(
        "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
   CHECK(CompileRun(
@@ -4265,7 +4265,7 @@
   CHECK_EQ(5, CompileRun(source)->Int32Value());

// Get the interceptor properties for the object with only named interceptor.
-  CompileRun("named_values = named_mirror.properties()");
+  CompileRun("var named_values = named_mirror.properties()");

   // Check that the properties are interceptor properties.
   for (int i = 0; i < 3; i++) {
@@ -4284,7 +4284,7 @@

   // Get the interceptor properties for the object with only indexed
   // interceptor.
-  CompileRun("indexed_values = indexed_mirror.properties()");
+  CompileRun("var indexed_values = indexed_mirror.properties()");

   // Check that the properties are interceptor properties.
   for (int i = 0; i < 2; i++) {
@@ -4296,7 +4296,7 @@

   // Get the interceptor properties for the object with both types of
   // interceptors.
-  CompileRun("both_values = both_mirror.properties()");
+  CompileRun("var both_values = both_mirror.properties()");

   // Check that the properties are interceptor properties.
   for (int i = 0; i < 5; i++) {
@@ -4352,10 +4352,10 @@

   // Get mirrors for the four objects.
   CompileRun(
-      "o0_mirror = debug.MakeMirror(o0);"
-      "o1_mirror = debug.MakeMirror(o1);"
-      "o2_mirror = debug.MakeMirror(o2);"
-      "o3_mirror = debug.MakeMirror(o3)");
+      "var o0_mirror = debug.MakeMirror(o0);"
+      "var o1_mirror = debug.MakeMirror(o1);"
+      "var o2_mirror = debug.MakeMirror(o2);"
+      "var o3_mirror = debug.MakeMirror(o3)");
CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue());
@@ -4441,11 +4441,11 @@
   CHECK_EQ(10, CompileRun("instance.x")->Int32Value());

   // Get mirror for the object with property getter.
-  CompileRun("instance_mirror = debug.MakeMirror(instance);");
+  CompileRun("var instance_mirror = debug.MakeMirror(instance);");
   CHECK(CompileRun(
       "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());

-  CompileRun("named_names = instance_mirror.propertyNames();");
+  CompileRun("var named_names = instance_mirror.propertyNames();");
   CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
   CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
   CHECK(CompileRun(
@@ -4477,7 +4477,7 @@
   env->Global()->Set(v8::String::New("instance"), named->NewInstance());

   // Get mirror for the object with property getter.
-  CompileRun("instance_mirror = debug.MakeMirror(instance);");
+  CompileRun("var instance_mirror = debug.MakeMirror(instance);");
   CHECK(CompileRun(
       "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
   CompileRun("named_names = instance_mirror.propertyNames();");
=======================================
--- /branches/bleeding_edge/test/mjsunit/builtins.js Mon Sep 19 11:36:47 2011 +++ /branches/bleeding_edge/test/mjsunit/builtins.js Mon Feb 20 05:48:24 2012
@@ -27,8 +27,7 @@

 // Flags: --expose-natives-as=builtins

-// Checks that all function properties of the builtin object are neither
-// writable nor configurable. Also, theose functions that are actually
+// Checks that all function properties of the builtin object that are actually // constructors (recognized by having properties on their .prototype object),
 // have only unconfigurable properties on the prototype, and the methods
 // are also non-writable.
@@ -75,8 +74,6 @@
   assertTrue(desc.hasOwnProperty("value"));
   var value = desc.value;
   if (isFunction(value)) {
-    assertFalse(desc.writable, name);
-    assertFalse(desc.configurable, name);
     checkConstructor(value, name);
   }
 }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to