Commit 1336b913 authored by rossberg@chromium.org's avatar rossberg@chromium.org

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.

R=yangguo@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9415010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10758 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8ebbd863
...@@ -1198,7 +1198,7 @@ class String : public Primitive { ...@@ -1198,7 +1198,7 @@ class String : public Primitive {
* passed in as parameters. * passed in as parameters.
*/ */
V8EXPORT static Local<String> Concat(Handle<String> left, 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 * Creates a new external string using the data defined in the given
......
...@@ -37,8 +37,8 @@ function CreateDate(time) { ...@@ -37,8 +37,8 @@ function CreateDate(time) {
} }
const kApiFunctionCache = {}; var kApiFunctionCache = {};
const functionCache = kApiFunctionCache; var functionCache = kApiFunctionCache;
function Instantiate(data, name) { function Instantiate(data, name) {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// This file relies on the fact that the following declarations have been made // This file relies on the fact that the following declarations have been made
// in runtime.js: // in runtime.js:
// const $Array = global.Array; // var $Array = global.Array;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -757,7 +757,7 @@ function ArraySort(comparefn) { ...@@ -757,7 +757,7 @@ function ArraySort(comparefn) {
} }
var receiver = %GetDefaultReceiver(comparefn); var receiver = %GetDefaultReceiver(comparefn);
function InsertionSort(a, from, to) { var InsertionSort = function InsertionSort(a, from, to) {
for (var i = from + 1; i < to; i++) { for (var i = from + 1; i < to; i++) {
var element = a[i]; var element = a[i];
for (var j = i - 1; j >= from; j--) { for (var j = i - 1; j >= from; j--) {
...@@ -771,9 +771,9 @@ function ArraySort(comparefn) { ...@@ -771,9 +771,9 @@ function ArraySort(comparefn) {
} }
a[j + 1] = element; a[j + 1] = element;
} }
} };
function QuickSort(a, from, to) { var QuickSort = function QuickSort(a, from, to) {
// Insertion sort is faster for short arrays. // Insertion sort is faster for short arrays.
if (to - from <= 10) { if (to - from <= 10) {
InsertionSort(a, from, to); InsertionSort(a, from, to);
...@@ -841,12 +841,12 @@ function ArraySort(comparefn) { ...@@ -841,12 +841,12 @@ function ArraySort(comparefn) {
} }
QuickSort(a, from, low_end); QuickSort(a, from, low_end);
QuickSort(a, high_start, to); QuickSort(a, high_start, to);
} };
// Copy elements in the range 0..length from obj's prototype chain // 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 // to obj itself, if obj has holes. Return one more than the maximal index
// of a prototype property. // of a prototype property.
function CopyFromPrototype(obj, length) { var CopyFromPrototype = function CopyFromPrototype(obj, length) {
var max = 0; var max = 0;
for (var proto = obj.__proto__; proto; proto = proto.__proto__) { for (var proto = obj.__proto__; proto; proto = proto.__proto__) {
var indices = %GetArrayKeys(proto, length); var indices = %GetArrayKeys(proto, length);
...@@ -873,12 +873,12 @@ function ArraySort(comparefn) { ...@@ -873,12 +873,12 @@ function ArraySort(comparefn) {
} }
} }
return max; return max;
} };
// Set a value of "undefined" on all indices in the range from..to // 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 // where a prototype of obj has an element. I.e., shadow all prototype
// elements in that range. // elements in that range.
function ShadowPrototypeElements(obj, from, to) { var ShadowPrototypeElements = function(obj, from, to) {
for (var proto = obj.__proto__; proto; proto = proto.__proto__) { for (var proto = obj.__proto__; proto; proto = proto.__proto__) {
var indices = %GetArrayKeys(proto, to); var indices = %GetArrayKeys(proto, to);
if (indices.length > 0) { if (indices.length > 0) {
...@@ -901,9 +901,9 @@ function ArraySort(comparefn) { ...@@ -901,9 +901,9 @@ function ArraySort(comparefn) {
} }
} }
} }
} };
function SafeRemoveArrayHoles(obj) { var SafeRemoveArrayHoles = function SafeRemoveArrayHoles(obj) {
// Copy defined elements from the end to fill in all holes and undefineds // 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 // in the beginning of the array. Write undefineds and holes at the end
// after loop is finished. // after loop is finished.
...@@ -958,7 +958,7 @@ function ArraySort(comparefn) { ...@@ -958,7 +958,7 @@ function ArraySort(comparefn) {
// Return the number of defined elements. // Return the number of defined elements.
return first_undefined; return first_undefined;
} };
var length = TO_UINT32(this.length); var length = TO_UINT32(this.length);
if (length < 2) return this; if (length < 2) return this;
...@@ -1373,7 +1373,7 @@ function SetUpArray() { ...@@ -1373,7 +1373,7 @@ function SetUpArray() {
var specialFunctions = %SpecialArrayFunctions({}); var specialFunctions = %SpecialArrayFunctions({});
function getFunction(name, jsBuiltin, len) { var getFunction = function(name, jsBuiltin, len) {
var f = jsBuiltin; var f = jsBuiltin;
if (specialFunctions.hasOwnProperty(name)) { if (specialFunctions.hasOwnProperty(name)) {
f = specialFunctions[name]; f = specialFunctions[name];
...@@ -1382,7 +1382,7 @@ function SetUpArray() { ...@@ -1382,7 +1382,7 @@ function SetUpArray() {
%FunctionSetLength(f, len); %FunctionSetLength(f, len);
} }
return f; return f;
} };
// Set up non-enumerable functions of the Array.prototype object and // Set up non-enumerable functions of the Array.prototype object and
// set their names. // set their names.
......
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict";
const $Set = global.Set; var $Set = global.Set;
const $Map = global.Map; var $Map = global.Map;
const $WeakMap = global.WeakMap; var $WeakMap = global.WeakMap;
//------------------------------------------------------------------- //-------------------------------------------------------------------
......
...@@ -497,13 +497,6 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, ...@@ -497,13 +497,6 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
// for small sources, odds are that there aren't many functions // for small sources, odds are that there aren't many functions
// that would be compiled lazily anyway, so we skip the preparse step // that would be compiled lazily anyway, so we skip the preparse step
// in that case too. // 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. // Create a script object describing the script to be compiled.
Handle<Script> script = FACTORY->NewScript(source); Handle<Script> script = FACTORY->NewScript(source);
...@@ -524,6 +517,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, ...@@ -524,6 +517,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
info.MarkAsGlobal(); info.MarkAsGlobal();
info.SetExtension(extension); info.SetExtension(extension);
info.SetPreParseData(pre_data); info.SetPreParseData(pre_data);
if (FLAG_use_strict) info.SetLanguageMode(STRICT_MODE);
result = MakeFunctionInfo(&info); result = MakeFunctionInfo(&info);
if (extension == NULL && !result.is_null()) { if (extension == NULL && !result.is_null()) {
compilation_cache->PutScript(source, result); compilation_cache->PutScript(source, result);
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict";
String.prototype.startsWith = function (str) { String.prototype.startsWith = function (str) {
if (str.length > this.length) { if (str.length > this.length) {
return false; return false;
...@@ -76,7 +78,7 @@ function GetCompletions(global, last, full) { ...@@ -76,7 +78,7 @@ function GetCompletions(global, last, full) {
// Global object holding debugger related constants and state. // Global object holding debugger related constants and state.
const Debug = {}; var Debug = {};
// Debug events which can occour in the V8 JavaScript engine. These originate // Debug events which can occour in the V8 JavaScript engine. These originate
...@@ -111,7 +113,7 @@ Debug.ScopeType = { Global: 0, ...@@ -111,7 +113,7 @@ Debug.ScopeType = { Global: 0,
// Current debug state. // Current debug state.
const kNoFrame = -1; var kNoFrame = -1;
Debug.State = { Debug.State = {
currentFrame: kNoFrame, currentFrame: kNoFrame,
displaySourceStartLine: -1, displaySourceStartLine: -1,
...@@ -123,8 +125,8 @@ var trace_debug_json = false; // Tracing all debug json packets? ...@@ -123,8 +125,8 @@ var trace_debug_json = false; // Tracing all debug json packets?
var last_cmd_line = ''; var last_cmd_line = '';
//var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined. //var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined.
var lol_next_dump_index = 0; var lol_next_dump_index = 0;
const kDefaultLolLinesToPrintAtATime = 10; var kDefaultLolLinesToPrintAtATime = 10;
const kMaxLolLinesToPrintAtATime = 1000; var kMaxLolLinesToPrintAtATime = 1000;
var repeat_cmd_line = ''; var repeat_cmd_line = '';
var is_running = true; var is_running = true;
...@@ -2629,7 +2631,7 @@ function NumberToJSON_(value) { ...@@ -2629,7 +2631,7 @@ function NumberToJSON_(value) {
// Mapping of some control characters to avoid the \uXXXX syntax for most // Mapping of some control characters to avoid the \uXXXX syntax for most
// commonly used control cahracters. // commonly used control cahracters.
const ctrlCharMap_ = { var ctrlCharMap_ = {
'\b': '\\b', '\b': '\\b',
'\t': '\\t', '\t': '\\t',
'\n': '\\n', '\n': '\\n',
...@@ -2641,12 +2643,12 @@ const ctrlCharMap_ = { ...@@ -2641,12 +2643,12 @@ const ctrlCharMap_ = {
// Regular expression testing for ", \ and control characters (0x00 - 0x1F). // 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) // Regular expression matching ", \ and control characters (0x00 - 0x1F)
// globally. // globally.
const ctrlCharMatch_ = new RegExp('["\\\\\x00-\x1F]', 'g'); var ctrlCharMatch_ = new RegExp('["\\\\\x00-\x1F]', 'g');
/** /**
...@@ -2688,12 +2690,12 @@ function StringToJSON_(value) { ...@@ -2688,12 +2690,12 @@ function StringToJSON_(value) {
* @return {string} JSON formatted Date value * @return {string} JSON formatted Date value
*/ */
function DateToISO8601_(value) { function DateToISO8601_(value) {
function f(n) { var f = function(n) {
return n < 10 ? '0' + n : 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 n < 10 ? '00' + n : n < 100 ? '0' + n : n;
} };
return builtins.GetUTCFullYearFrom(value) + '-' + return builtins.GetUTCFullYearFrom(value) + '-' +
f(builtins.GetUTCMonthFrom(value) + 1) + '-' + f(builtins.GetUTCMonthFrom(value) + 1) + '-' +
f(builtins.GetUTCDateFrom(value)) + 'T' + f(builtins.GetUTCDateFrom(value)) + 'T' +
......
...@@ -28,17 +28,16 @@ ...@@ -28,17 +28,16 @@
// This file relies on the fact that the following declarations have been made // This file relies on the fact that the following declarations have been made
// in v8natives.js: // in v8natives.js:
// const $isFinite = GlobalIsFinite; // var $isFinite = GlobalIsFinite;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// This file contains date support implemented in JavaScript. // This file contains date support implemented in JavaScript.
// Keep reference to original values of some global properties. This // Keep reference to original values of some global properties. This
// has the added benefit that the code in this file is isolated from // has the added benefit that the code in this file is isolated from
// changes to these properties. // changes to these properties.
const $Date = global.Date; var $Date = global.Date;
// Helper function to throw error. // Helper function to throw error.
function ThrowDateTypeError() { function ThrowDateTypeError() {
......
...@@ -26,14 +26,14 @@ ...@@ -26,14 +26,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Default number of frames to include in the response to backtrace request. // Default number of frames to include in the response to backtrace request.
const kDefaultBacktraceLength = 10; var kDefaultBacktraceLength = 10;
const Debug = {}; var Debug = {};
// Regular expression to skip "crud" at the beginning of a source line which is // Regular expression to skip "crud" at the beginning of a source line which is
// not really code. Currently the regular expression matches whitespace and // not really code. Currently the regular expression matches whitespace and
// comments. // comments.
const sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/; var sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;
// Debug events which can occour in the V8 JavaScript engine. These originate // Debug events which can occour in the V8 JavaScript engine. These originate
// from the API include file debug.h. // from the API include file debug.h.
......
...@@ -106,7 +106,9 @@ private: ...@@ -106,7 +106,9 @@ private:
// //
#define FLAG FLAG_FULL #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_typeof, false, "enable harmony semantics for typeof")
DEFINE_bool(harmony_scoping, false, "enable harmony block scoping") DEFINE_bool(harmony_scoping, false, "enable harmony block scoping")
DEFINE_bool(harmony_modules, false, "enable harmony modules") DEFINE_bool(harmony_modules, false, "enable harmony modules")
......
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
// Keep reference to original values of some global properties. This // Keep reference to original values of some global properties. This
// has the added benefit that the code in this file is isolated from // has the added benefit that the code in this file is isolated from
// changes to these properties. // changes to these properties.
const $floor = MathFloor; var $floor = MathFloor;
const $random = MathRandom; var $random = MathRandom;
const $abs = MathAbs; var $abs = MathAbs;
// Instance class name can only be set on functions. That is the only // Instance class name can only be set on functions. That is the only
// purpose for MathConstructor. // purpose for MathConstructor.
function MathConstructor() {} function MathConstructor() {}
%FunctionSetInstanceClassName(MathConstructor, 'Math'); %FunctionSetInstanceClassName(MathConstructor, 'Math');
const $Math = new MathConstructor(); var $Math = new MathConstructor();
$Math.__proto__ = $Object.prototype; $Math.__proto__ = $Object.prototype;
%SetProperty(global, "Math", $Math, DONT_ENUM); %SetProperty(global, "Math", $Math, DONT_ENUM);
......
...@@ -25,17 +25,18 @@ ...@@ -25,17 +25,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // 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 // If this object gets passed to an error constructor the error will
// get an accessor for .message that constructs a descriptive error // get an accessor for .message that constructs a descriptive error
// message on access. // message on access.
const kAddMessageAccessorsMarker = { }; var kAddMessageAccessorsMarker = { };
// This will be lazily initialized when first needed (and forcibly // This will be lazily initialized when first needed (and forcibly
// overwritten even though it's const). // overwritten even though it's const).
const kMessages = 0; var kMessages = 0;
function FormatString(format, message) { function FormatString(format, message) {
var args = %MessageGetArguments(message); var args = %MessageGetArguments(message);
...@@ -603,7 +604,7 @@ function SourceLocation(script, position, line, column, start, end) { ...@@ -603,7 +604,7 @@ function SourceLocation(script, position, line, column, start, end) {
this.end = end; this.end = end;
} }
const kLineLengthLimit = 78; var kLineLengthLimit = 78;
/** /**
* Restrict source location start and end positions to make the source slice * Restrict source location start and end positions to make the source slice
...@@ -748,18 +749,18 @@ function DefineOneShotAccessor(obj, name, fun) { ...@@ -748,18 +749,18 @@ function DefineOneShotAccessor(obj, name, fun) {
// can't rely on 'this' being the same as 'obj'. // can't rely on 'this' being the same as 'obj'.
var hasBeenSet = false; var hasBeenSet = false;
var value; var value;
function getter() { var getter = function() {
if (hasBeenSet) { if (hasBeenSet) {
return value; return value;
} }
hasBeenSet = true; hasBeenSet = true;
value = fun(obj); value = fun(obj);
return value; return value;
} };
function setter(v) { var setter = function(v) {
hasBeenSet = true; hasBeenSet = true;
value = v; value = v;
} };
%DefineOrRedefineAccessorProperty(obj, name, GETTER, getter, DONT_ENUM); %DefineOrRedefineAccessorProperty(obj, name, GETTER, getter, DONT_ENUM);
%DefineOrRedefineAccessorProperty(obj, name, SETTER, setter, DONT_ENUM); %DefineOrRedefineAccessorProperty(obj, name, SETTER, setter, DONT_ENUM);
} }
...@@ -1090,7 +1091,7 @@ function captureStackTrace(obj, cons_opt) { ...@@ -1090,7 +1091,7 @@ function captureStackTrace(obj, cons_opt) {
function SetUpError() { function SetUpError() {
// Define special error type constructors. // Define special error type constructors.
function DefineError(f) { var DefineError = function(f) {
// Store the error function in both the global object // Store the error function in both the global object
// and the runtime object. The function is fetched // and the runtime object. The function is fetched
// from the runtime object when throwing errors from // from the runtime object when throwing errors from
...@@ -1106,7 +1107,7 @@ function SetUpError() { ...@@ -1106,7 +1107,7 @@ function SetUpError() {
// However, it can't be an instance of the Error object because // However, it can't be an instance of the Error object because
// it hasn't been properly configured yet. Instead we create a // it hasn't been properly configured yet. Instead we create a
// special not-a-true-error-but-close-enough object. // special not-a-true-error-but-close-enough object.
function ErrorPrototype() {} var ErrorPrototype = function() {};
%FunctionSetPrototype(ErrorPrototype, $Object.prototype); %FunctionSetPrototype(ErrorPrototype, $Object.prototype);
%FunctionSetInstanceClassName(ErrorPrototype, 'Error'); %FunctionSetInstanceClassName(ErrorPrototype, 'Error');
%FunctionSetPrototype(f, new ErrorPrototype()); %FunctionSetPrototype(f, new ErrorPrototype());
...@@ -1148,7 +1149,7 @@ function SetUpError() { ...@@ -1148,7 +1149,7 @@ function SetUpError() {
} }
}); });
%SetNativeFlag(f); %SetNativeFlag(f);
} };
DefineError(function Error() { }); DefineError(function Error() { });
DefineError(function TypeError() { }); DefineError(function TypeError() { });
...@@ -1167,8 +1168,8 @@ $Error.captureStackTrace = captureStackTrace; ...@@ -1167,8 +1168,8 @@ $Error.captureStackTrace = captureStackTrace;
// Global list of error objects visited during ErrorToString. This is // Global list of error objects visited during ErrorToString. This is
// used to detect cycles in error toString formatting. // used to detect cycles in error toString formatting.
const visited_errors = new InternalArray(); var visited_errors = new InternalArray();
const cyclic_error_marker = new $Object(); var cyclic_error_marker = new $Object();
function ErrorToStringDetectCycle(error) { function ErrorToStringDetectCycle(error) {
if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker; if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker;
...@@ -1213,4 +1214,4 @@ InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); ...@@ -1213,4 +1214,4 @@ InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]);
// Boilerplate for exceptions for stack overflows. Used from // Boilerplate for exceptions for stack overflows. Used from
// Isolate::StackOverflow(). // Isolate::StackOverflow().
const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
...@@ -144,32 +144,32 @@ function inherits(ctor, superCtor) { ...@@ -144,32 +144,32 @@ function inherits(ctor, superCtor) {
// Type names of the different mirrors. // Type names of the different mirrors.
const UNDEFINED_TYPE = 'undefined'; var UNDEFINED_TYPE = 'undefined';
const NULL_TYPE = 'null'; var NULL_TYPE = 'null';
const BOOLEAN_TYPE = 'boolean'; var BOOLEAN_TYPE = 'boolean';
const NUMBER_TYPE = 'number'; var NUMBER_TYPE = 'number';
const STRING_TYPE = 'string'; var STRING_TYPE = 'string';
const OBJECT_TYPE = 'object'; var OBJECT_TYPE = 'object';
const FUNCTION_TYPE = 'function'; var FUNCTION_TYPE = 'function';
const REGEXP_TYPE = 'regexp'; var REGEXP_TYPE = 'regexp';
const ERROR_TYPE = 'error'; var ERROR_TYPE = 'error';
const PROPERTY_TYPE = 'property'; var PROPERTY_TYPE = 'property';
const FRAME_TYPE = 'frame'; var FRAME_TYPE = 'frame';
const SCRIPT_TYPE = 'script'; var SCRIPT_TYPE = 'script';
const CONTEXT_TYPE = 'context'; var CONTEXT_TYPE = 'context';
const SCOPE_TYPE = 'scope'; var SCOPE_TYPE = 'scope';
// Maximum length when sending strings through the JSON protocol. // Maximum length when sending strings through the JSON protocol.
const kMaxProtocolStringLength = 80; var kMaxProtocolStringLength = 80;
// Different kind of properties. // Different kind of properties.
PropertyKind = {}; var PropertyKind = {};
PropertyKind.Named = 1; PropertyKind.Named = 1;
PropertyKind.Indexed = 2; PropertyKind.Indexed = 2;
// A copy of the PropertyType enum from global.h // A copy of the PropertyType enum from global.h
PropertyType = {}; var PropertyType = {};
PropertyType.Normal = 0; PropertyType.Normal = 0;
PropertyType.Field = 1; PropertyType.Field = 1;
PropertyType.ConstantFunction = 2; PropertyType.ConstantFunction = 2;
...@@ -183,7 +183,7 @@ PropertyType.NullDescriptor = 9; ...@@ -183,7 +183,7 @@ PropertyType.NullDescriptor = 9;
// Different attributes for a property. // Different attributes for a property.
PropertyAttribute = {}; var PropertyAttribute = {};
PropertyAttribute.None = NONE; PropertyAttribute.None = NONE;
PropertyAttribute.ReadOnly = READ_ONLY; PropertyAttribute.ReadOnly = READ_ONLY;
PropertyAttribute.DontEnum = DONT_ENUM; PropertyAttribute.DontEnum = DONT_ENUM;
...@@ -191,12 +191,12 @@ PropertyAttribute.DontDelete = DONT_DELETE; ...@@ -191,12 +191,12 @@ PropertyAttribute.DontDelete = DONT_DELETE;
// A copy of the scope types from runtime.cc. // A copy of the scope types from runtime.cc.
ScopeType = { Global: 0, var ScopeType = { Global: 0,
Local: 1, Local: 1,
With: 2, With: 2,
Closure: 3, Closure: 3,
Catch: 4, Catch: 4,
Block: 5 }; Block: 5 };
// Mirror hierarchy: // Mirror hierarchy:
...@@ -1237,24 +1237,24 @@ PropertyMirror.prototype.isNative = function() { ...@@ -1237,24 +1237,24 @@ PropertyMirror.prototype.isNative = function() {
}; };
const kFrameDetailsFrameIdIndex = 0; var kFrameDetailsFrameIdIndex = 0;
const kFrameDetailsReceiverIndex = 1; var kFrameDetailsReceiverIndex = 1;
const kFrameDetailsFunctionIndex = 2; var kFrameDetailsFunctionIndex = 2;
const kFrameDetailsArgumentCountIndex = 3; var kFrameDetailsArgumentCountIndex = 3;
const kFrameDetailsLocalCountIndex = 4; var kFrameDetailsLocalCountIndex = 4;
const kFrameDetailsSourcePositionIndex = 5; var kFrameDetailsSourcePositionIndex = 5;
const kFrameDetailsConstructCallIndex = 6; var kFrameDetailsConstructCallIndex = 6;
const kFrameDetailsAtReturnIndex = 7; var kFrameDetailsAtReturnIndex = 7;
const kFrameDetailsFlagsIndex = 8; var kFrameDetailsFlagsIndex = 8;
const kFrameDetailsFirstDynamicIndex = 9; var kFrameDetailsFirstDynamicIndex = 9;
const kFrameDetailsNameIndex = 0; var kFrameDetailsNameIndex = 0;
const kFrameDetailsValueIndex = 1; var kFrameDetailsValueIndex = 1;
const kFrameDetailsNameValueSize = 2; var kFrameDetailsNameValueSize = 2;
const kFrameDetailsFlagDebuggerFrameMask = 1 << 0; var kFrameDetailsFlagDebuggerFrameMask = 1 << 0;
const kFrameDetailsFlagOptimizedFrameMask = 1 << 1; var kFrameDetailsFlagOptimizedFrameMask = 1 << 1;
const kFrameDetailsFlagInlinedFrameIndexMask = 7 << 2; var kFrameDetailsFlagInlinedFrameIndexMask = 7 << 2;
/** /**
* Wrapper for the frame details information retreived from the VM. The frame * Wrapper for the frame details information retreived from the VM. The frame
...@@ -1732,8 +1732,8 @@ FrameMirror.prototype.toText = function(opt_locals) { ...@@ -1732,8 +1732,8 @@ FrameMirror.prototype.toText = function(opt_locals) {
}; };
const kScopeDetailsTypeIndex = 0; var kScopeDetailsTypeIndex = 0;
const kScopeDetailsObjectIndex = 1; var kScopeDetailsObjectIndex = 1;
function ScopeDetails(frame, index) { function ScopeDetails(frame, index) {
this.break_id_ = frame.break_id_; this.break_id_ = frame.break_id_;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict";
global.Proxy = new $Object(); global.Proxy = new $Object();
var $Proxy = global.Proxy var $Proxy = global.Proxy
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// Expect $Object = global.Object; // Expect $Object = global.Object;
// Expect $Array = global.Array; // Expect $Array = global.Array;
const $RegExp = global.RegExp; var $RegExp = global.RegExp;
// A recursive descent parser for Patterns according to the grammar of // A recursive descent parser for Patterns according to the grammar of
// ECMA-262 15.10.1, with deviations noted below. // ECMA-262 15.10.1, with deviations noted below.
...@@ -413,13 +413,13 @@ function SetUpRegExp() { ...@@ -413,13 +413,13 @@ function SetUpRegExp() {
// The properties input, $input, and $_ are aliases for each other. When this // 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. // value is set the value it is set to is coerced to a string.
// Getter and setter for the input. // Getter and setter for the input.
function RegExpGetInput() { var RegExpGetInput = function() {
var regExpInput = LAST_INPUT(lastMatchInfo); var regExpInput = LAST_INPUT(lastMatchInfo);
return IS_UNDEFINED(regExpInput) ? "" : regExpInput; return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
} };
function RegExpSetInput(string) { var RegExpSetInput = function(string) {
LAST_INPUT(lastMatchInfo) = ToString(string); LAST_INPUT(lastMatchInfo) = ToString(string);
} };
%DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE); %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE);
%DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE); %DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE);
...@@ -441,8 +441,8 @@ function SetUpRegExp() { ...@@ -441,8 +441,8 @@ function SetUpRegExp() {
// Getter and setter for multiline. // Getter and setter for multiline.
var multiline = false; var multiline = false;
function RegExpGetMultiline() { return multiline; } var RegExpGetMultiline = function() { return multiline; };
function RegExpSetMultiline(flag) { multiline = flag ? true : false; } var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; };
%DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline, %DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline,
DONT_DELETE); DONT_DELETE);
...@@ -454,7 +454,7 @@ function SetUpRegExp() { ...@@ -454,7 +454,7 @@ function SetUpRegExp() {
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
function NoOpSetter(ignored) {} var NoOpSetter = function(ignored) {};
// Static properties set by a successful match. // Static properties set by a successful match.
......
...@@ -39,16 +39,16 @@ ...@@ -39,16 +39,16 @@
----------------------------------- -----------------------------------
*/ */
// The following const declarations are shared with other native JS files. // The following declarations are shared with other native JS files.
// They are all declared at this one spot to avoid const redeclaration errors. // They are all declared at this one spot to avoid redeclaration errors.
const $Object = global.Object; var $Object = global.Object;
const $Array = global.Array; var $Array = global.Array;
const $String = global.String; var $String = global.String;
const $Number = global.Number; var $Number = global.Number;
const $Function = global.Function; var $Function = global.Function;
const $Boolean = global.Boolean; var $Boolean = global.Boolean;
const $NaN = 0/0; var $NaN = 0/0;
const builtins = this; var builtins = this;
// ECMA-262 Section 11.9.3. // ECMA-262 Section 11.9.3.
function EQUALS(y) { function EQUALS(y) {
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
// This file relies on the fact that the following declaration has been made // This file relies on the fact that the following declaration has been made
// in runtime.js: // in runtime.js:
// const $String = global.String; // var $String = global.String;
// const $NaN = 0/0; // var $NaN = 0/0;
// Set the String function and constructor. // Set the String function and constructor.
......
...@@ -250,7 +250,7 @@ function Decode(uri, reserved) { ...@@ -250,7 +250,7 @@ function Decode(uri, reserved) {
// ECMA-262 - 15.1.3.1. // ECMA-262 - 15.1.3.1.
function URIDecode(uri) { function URIDecode(uri) {
function reservedPredicate(cc) { var reservedPredicate = function(cc) {
// #$ // #$
if (35 <= cc && cc <= 36) return true; if (35 <= cc && cc <= 36) return true;
// & // &
...@@ -267,7 +267,7 @@ function URIDecode(uri) { ...@@ -267,7 +267,7 @@ function URIDecode(uri) {
if (63 <= cc && cc <= 64) return true; if (63 <= cc && cc <= 64) return true;
return false; return false;
} };
var string = ToString(uri); var string = ToString(uri);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
...@@ -275,7 +275,7 @@ function URIDecode(uri) { ...@@ -275,7 +275,7 @@ function URIDecode(uri) {
// ECMA-262 - 15.1.3.2. // ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) { function URIDecodeComponent(component) {
function reservedPredicate(cc) { return false; } var reservedPredicate = function(cc) { return false; };
var string = ToString(component); var string = ToString(component);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
...@@ -296,7 +296,7 @@ function isAlphaNumeric(cc) { ...@@ -296,7 +296,7 @@ function isAlphaNumeric(cc) {
// ECMA-262 - 15.1.3.3. // ECMA-262 - 15.1.3.3.
function URIEncode(uri) { function URIEncode(uri) {
function unescapePredicate(cc) { var unescapePredicate = function(cc) {
if (isAlphaNumeric(cc)) return true; if (isAlphaNumeric(cc)) return true;
// ! // !
if (cc == 33) return true; if (cc == 33) return true;
...@@ -316,7 +316,7 @@ function URIEncode(uri) { ...@@ -316,7 +316,7 @@ function URIEncode(uri) {
if (cc == 126) return true; if (cc == 126) return true;
return false; return false;
} };
var string = ToString(uri); var string = ToString(uri);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
...@@ -325,7 +325,7 @@ function URIEncode(uri) { ...@@ -325,7 +325,7 @@ function URIEncode(uri) {
// ECMA-262 - 15.1.3.4 // ECMA-262 - 15.1.3.4
function URIEncodeComponent(component) { function URIEncodeComponent(component) {
function unescapePredicate(cc) { var unescapePredicate = function(cc) {
if (isAlphaNumeric(cc)) return true; if (isAlphaNumeric(cc)) return true;
// ! // !
if (cc == 33) return true; if (cc == 33) return true;
...@@ -339,7 +339,7 @@ function URIEncodeComponent(component) { ...@@ -339,7 +339,7 @@ function URIEncodeComponent(component) {
if (cc == 126) return true; if (cc == 126) return true;
return false; return false;
} };
var string = ToString(component); var string = ToString(component);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
......
...@@ -28,18 +28,18 @@ ...@@ -28,18 +28,18 @@
// This file relies on the fact that the following declarations have been made // This file relies on the fact that the following declarations have been made
// //
// in runtime.js: // in runtime.js:
// const $Object = global.Object; // var $Object = global.Object;
// const $Boolean = global.Boolean; // var $Boolean = global.Boolean;
// const $Number = global.Number; // var $Number = global.Number;
// const $Function = global.Function; // var $Function = global.Function;
// const $Array = global.Array; // var $Array = global.Array;
// const $NaN = 0/0; // var $NaN = 0/0;
// //
// in math.js: // in math.js:
// const $floor = MathFloor // var $floor = MathFloor
const $isNaN = GlobalIsNaN; var $isNaN = GlobalIsNaN;
const $isFinite = GlobalIsFinite; var $isFinite = GlobalIsFinite;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -4222,9 +4222,9 @@ TEST(InterceptorPropertyMirror) { ...@@ -4222,9 +4222,9 @@ TEST(InterceptorPropertyMirror) {
// Get mirrors for the three objects with interceptor. // Get mirrors for the three objects with interceptor.
CompileRun( CompileRun(
"named_mirror = debug.MakeMirror(intercepted_named);" "var named_mirror = debug.MakeMirror(intercepted_named);"
"indexed_mirror = debug.MakeMirror(intercepted_indexed);" "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
"both_mirror = debug.MakeMirror(intercepted_both)"); "var both_mirror = debug.MakeMirror(intercepted_both)");
CHECK(CompileRun( CHECK(CompileRun(
"named_mirror instanceof debug.ObjectMirror")->BooleanValue()); "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
CHECK(CompileRun( CHECK(CompileRun(
...@@ -4265,7 +4265,7 @@ TEST(InterceptorPropertyMirror) { ...@@ -4265,7 +4265,7 @@ TEST(InterceptorPropertyMirror) {
CHECK_EQ(5, CompileRun(source)->Int32Value()); CHECK_EQ(5, CompileRun(source)->Int32Value());
// Get the interceptor properties for the object with only named interceptor. // 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. // Check that the properties are interceptor properties.
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
...@@ -4284,7 +4284,7 @@ TEST(InterceptorPropertyMirror) { ...@@ -4284,7 +4284,7 @@ TEST(InterceptorPropertyMirror) {
// Get the interceptor properties for the object with only indexed // Get the interceptor properties for the object with only indexed
// interceptor. // interceptor.
CompileRun("indexed_values = indexed_mirror.properties()"); CompileRun("var indexed_values = indexed_mirror.properties()");
// Check that the properties are interceptor properties. // Check that the properties are interceptor properties.
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
...@@ -4296,7 +4296,7 @@ TEST(InterceptorPropertyMirror) { ...@@ -4296,7 +4296,7 @@ TEST(InterceptorPropertyMirror) {
// Get the interceptor properties for the object with both types of // Get the interceptor properties for the object with both types of
// interceptors. // interceptors.
CompileRun("both_values = both_mirror.properties()"); CompileRun("var both_values = both_mirror.properties()");
// Check that the properties are interceptor properties. // Check that the properties are interceptor properties.
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
...@@ -4352,10 +4352,10 @@ TEST(HiddenPrototypePropertyMirror) { ...@@ -4352,10 +4352,10 @@ TEST(HiddenPrototypePropertyMirror) {
// Get mirrors for the four objects. // Get mirrors for the four objects.
CompileRun( CompileRun(
"o0_mirror = debug.MakeMirror(o0);" "var o0_mirror = debug.MakeMirror(o0);"
"o1_mirror = debug.MakeMirror(o1);" "var o1_mirror = debug.MakeMirror(o1);"
"o2_mirror = debug.MakeMirror(o2);" "var o2_mirror = debug.MakeMirror(o2);"
"o3_mirror = debug.MakeMirror(o3)"); "var o3_mirror = debug.MakeMirror(o3)");
CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue());
CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue());
CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue());
...@@ -4441,11 +4441,11 @@ TEST(NativeGetterPropertyMirror) { ...@@ -4441,11 +4441,11 @@ TEST(NativeGetterPropertyMirror) {
CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
// Get mirror for the object with property getter. // Get mirror for the object with property getter.
CompileRun("instance_mirror = debug.MakeMirror(instance);"); CompileRun("var instance_mirror = debug.MakeMirror(instance);");
CHECK(CompileRun( CHECK(CompileRun(
"instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); "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_EQ(1, CompileRun("named_names.length")->Int32Value());
CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
CHECK(CompileRun( CHECK(CompileRun(
...@@ -4477,7 +4477,7 @@ TEST(NativeGetterThrowingErrorPropertyMirror) { ...@@ -4477,7 +4477,7 @@ TEST(NativeGetterThrowingErrorPropertyMirror) {
env->Global()->Set(v8::String::New("instance"), named->NewInstance()); env->Global()->Set(v8::String::New("instance"), named->NewInstance());
// Get mirror for the object with property getter. // Get mirror for the object with property getter.
CompileRun("instance_mirror = debug.MakeMirror(instance);"); CompileRun("var instance_mirror = debug.MakeMirror(instance);");
CHECK(CompileRun( CHECK(CompileRun(
"instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
CompileRun("named_names = instance_mirror.propertyNames();"); CompileRun("named_names = instance_mirror.propertyNames();");
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
// Flags: --expose-natives-as=builtins // Flags: --expose-natives-as=builtins
// Checks that all function properties of the builtin object are neither // Checks that all function properties of the builtin object that are actually
// writable nor configurable. Also, theose functions that are actually
// constructors (recognized by having properties on their .prototype object), // constructors (recognized by having properties on their .prototype object),
// have only unconfigurable properties on the prototype, and the methods // have only unconfigurable properties on the prototype, and the methods
// are also non-writable. // are also non-writable.
...@@ -75,8 +74,6 @@ for (var i = 0; i < names.length; i++) { ...@@ -75,8 +74,6 @@ for (var i = 0; i < names.length; i++) {
assertTrue(desc.hasOwnProperty("value")); assertTrue(desc.hasOwnProperty("value"));
var value = desc.value; var value = desc.value;
if (isFunction(value)) { if (isFunction(value)) {
assertFalse(desc.writable, name);
assertFalse(desc.configurable, name);
checkConstructor(value, name); checkConstructor(value, name);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment