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
This commit is contained in:
rossberg@chromium.org 2012-02-20 13:48:24 +00:00
parent 8ebbd863a5
commit 1336b913d0
20 changed files with 154 additions and 156 deletions

View File

@ -1198,7 +1198,7 @@ class String : public Primitive {
* 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

View File

@ -37,8 +37,8 @@ function CreateDate(time) {
}
const kApiFunctionCache = {};
const functionCache = kApiFunctionCache;
var kApiFunctionCache = {};
var functionCache = kApiFunctionCache;
function Instantiate(data, name) {

View File

@ -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 @@ function ArraySort(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++) {
var element = a[i];
for (var j = i - 1; j >= from; j--) {
@ -771,9 +771,9 @@ function ArraySort(comparefn) {
}
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 @@ function ArraySort(comparefn) {
}
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 @@ function ArraySort(comparefn) {
}
}
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 ArraySort(comparefn) {
}
}
}
}
};
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 @@ function ArraySort(comparefn) {
// Return the number of defined elements.
return first_undefined;
}
};
var length = TO_UINT32(this.length);
if (length < 2) return this;
@ -1373,7 +1373,7 @@ function SetUpArray() {
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 @@ function SetUpArray() {
%FunctionSetLength(f, len);
}
return f;
}
};
// Set up non-enumerable functions of the Array.prototype object and
// set their names.

View File

@ -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.
"use strict";
const $Set = global.Set;
const $Map = global.Map;
const $WeakMap = global.WeakMap;
var $Set = global.Set;
var $Map = global.Map;
var $WeakMap = global.WeakMap;
//-------------------------------------------------------------------

View File

@ -497,13 +497,6 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
// 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 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
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);

View File

@ -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 @@ function GetCompletions(global, last, full) {
// 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 @@ Debug.ScopeType = { Global: 0,
// Current debug state.
const kNoFrame = -1;
var kNoFrame = -1;
Debug.State = {
currentFrame: kNoFrame,
displaySourceStartLine: -1,
@ -123,8 +125,8 @@ var trace_debug_json = false; // Tracing all debug json packets?
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 @@ function NumberToJSON_(value) {
// 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 @@ const ctrlCharMap_ = {
// 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 @@ function StringToJSON_(value) {
* @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' +

View File

@ -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() {

View File

@ -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;
var kDefaultBacktraceLength = 10;
const Debug = {};
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.

View File

@ -106,7 +106,9 @@ private:
//
#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")

View File

@ -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);

View File

@ -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 @@ function SourceLocation(script, position, line, column, start, end) {
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 @@ function DefineOneShotAccessor(obj, name, fun) {
// 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 captureStackTrace(obj, cons_opt) {
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 @@ function SetUpError() {
// 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 @@ function SetUpError() {
}
});
%SetNativeFlag(f);
}
};
DefineError(function Error() { });
DefineError(function TypeError() { });
@ -1167,8 +1168,8 @@ $Error.captureStackTrace = captureStackTrace;
// 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 @@ InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]);
// Boilerplate for exceptions for stack overflows. Used from
// Isolate::StackOverflow().
const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
var kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);

View File

@ -144,32 +144,32 @@ function inherits(ctor, superCtor) {
// 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 @@ PropertyType.NullDescriptor = 9;
// Different attributes for a property.
PropertyAttribute = {};
var PropertyAttribute = {};
PropertyAttribute.None = NONE;
PropertyAttribute.ReadOnly = READ_ONLY;
PropertyAttribute.DontEnum = DONT_ENUM;
@ -191,12 +191,12 @@ PropertyAttribute.DontDelete = DONT_DELETE;
// 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 @@ PropertyMirror.prototype.isNative = function() {
};
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;
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;
const kFrameDetailsNameIndex = 0;
const kFrameDetailsValueIndex = 1;
const kFrameDetailsNameValueSize = 2;
var kFrameDetailsNameIndex = 0;
var kFrameDetailsValueIndex = 1;
var kFrameDetailsNameValueSize = 2;
const kFrameDetailsFlagDebuggerFrameMask = 1 << 0;
const kFrameDetailsFlagOptimizedFrameMask = 1 << 1;
const kFrameDetailsFlagInlinedFrameIndexMask = 7 << 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 @@ FrameMirror.prototype.toText = function(opt_locals) {
};
const kScopeDetailsTypeIndex = 0;
const kScopeDetailsObjectIndex = 1;
var kScopeDetailsTypeIndex = 0;
var kScopeDetailsObjectIndex = 1;
function ScopeDetails(frame, index) {
this.break_id_ = frame.break_id_;

View File

@ -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

View File

@ -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 @@ function SetUpRegExp() {
// 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 @@ function SetUpRegExp() {
// 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 @@ function SetUpRegExp() {
DONT_ENUM | DONT_DELETE);
function NoOpSetter(ignored) {}
var NoOpSetter = function(ignored) {};
// Static properties set by a successful match.

View File

@ -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) {

View File

@ -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.

View File

@ -250,7 +250,7 @@ function Decode(uri, reserved) {
// 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 @@ function URIDecode(uri) {
if (63 <= cc && cc <= 64) return true;
return false;
}
};
var string = ToString(uri);
return Decode(string, reservedPredicate);
}
@ -275,7 +275,7 @@ function URIDecode(uri) {
// 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 @@ function isAlphaNumeric(cc) {
// 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 @@ function URIEncode(uri) {
if (cc == 126) return true;
return false;
}
};
var string = ToString(uri);
return Encode(string, unescapePredicate);
@ -325,7 +325,7 @@ function URIEncode(uri) {
// 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 @@ function URIEncodeComponent(component) {
if (cc == 126) return true;
return false;
}
};
var string = ToString(component);
return Encode(string, unescapePredicate);

View File

@ -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
// var $floor = MathFloor
const $isNaN = GlobalIsNaN;
const $isFinite = GlobalIsFinite;
var $isNaN = GlobalIsNaN;
var $isFinite = GlobalIsFinite;
// ----------------------------------------------------------------------------

View File

@ -4222,9 +4222,9 @@ TEST(InterceptorPropertyMirror) {
// 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 @@ TEST(InterceptorPropertyMirror) {
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 @@ TEST(InterceptorPropertyMirror) {
// 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 @@ TEST(InterceptorPropertyMirror) {
// 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 @@ TEST(HiddenPrototypePropertyMirror) {
// 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 @@ TEST(NativeGetterPropertyMirror) {
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 @@ TEST(NativeGetterThrowingErrorPropertyMirror) {
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();");

View File

@ -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 @@ for (var i = 0; i < names.length; i++) {
assertTrue(desc.hasOwnProperty("value"));
var value = desc.value;
if (isFunction(value)) {
assertFalse(desc.writable, name);
assertFalse(desc.configurable, name);
checkConstructor(value, name);
}
}