Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: src/messages.js

Issue 351853005: Split SetProperty(...attributes, strictmode) into AddProperty(...attributes) and SetProperty(...… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ------------------------------------------------------------------- 5 // -------------------------------------------------------------------
6 6
7 var kMessages = { 7 var kMessages = {
8 // Error 8 // Error
9 cyclic_proto: ["Cyclic __proto__ value"], 9 cyclic_proto: ["Cyclic __proto__ value"],
10 code_gen_from_strings: ["%0"], 10 code_gen_from_strings: ["%0"],
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 function MakeGenericError(constructor, type, args) { 275 function MakeGenericError(constructor, type, args) {
276 if (IS_UNDEFINED(args)) args = []; 276 if (IS_UNDEFINED(args)) args = [];
277 return new constructor(FormatMessage(type, args)); 277 return new constructor(FormatMessage(type, args));
278 } 278 }
279 279
280 280
281 /** 281 /**
282 * Set up the Script function and constructor. 282 * Set up the Script function and constructor.
283 */ 283 */
284 %FunctionSetInstanceClassName(Script, 'Script'); 284 %FunctionSetInstanceClassName(Script, 'Script');
285 %SetProperty(Script.prototype, 'constructor', Script, 285 %DefineProperty(Script.prototype, 'constructor', Script,
286 DONT_ENUM | DONT_DELETE | READ_ONLY); 286 DONT_ENUM | DONT_DELETE | READ_ONLY);
287 %SetCode(Script, function(x) { 287 %SetCode(Script, function(x) {
288 // Script objects can only be created by the VM. 288 // Script objects can only be created by the VM.
289 throw new $Error("Not supported"); 289 throw new $Error("Not supported");
290 }); 290 });
291 291
292 292
293 // Helper functions; called from the runtime system. 293 // Helper functions; called from the runtime system.
294 function FormatMessage(type, args) { 294 function FormatMessage(type, args) {
295 var format = kMessages[type]; 295 var format = kMessages[type];
296 if (!format) return "<unknown message " + type + ">"; 296 if (!format) return "<unknown message " + type + ">";
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 // Define special error type constructors. 1174 // Define special error type constructors.
1175 1175
1176 var DefineError = function(f) { 1176 var DefineError = function(f) {
1177 // Store the error function in both the global object 1177 // Store the error function in both the global object
1178 // and the runtime object. The function is fetched 1178 // and the runtime object. The function is fetched
1179 // from the runtime object when throwing errors from 1179 // from the runtime object when throwing errors from
1180 // within the runtime system to avoid strange side 1180 // within the runtime system to avoid strange side
1181 // effects when overwriting the error functions from 1181 // effects when overwriting the error functions from
1182 // user code. 1182 // user code.
1183 var name = f.name; 1183 var name = f.name;
1184 %SetProperty(global, name, f, DONT_ENUM); 1184 %DefineProperty(global, name, f, DONT_ENUM);
1185 %SetProperty(builtins, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY); 1185 %DefineProperty(builtins, '$' + name, f,
1186 DONT_ENUM | DONT_DELETE | READ_ONLY);
1186 // Configure the error function. 1187 // Configure the error function.
1187 if (name == 'Error') { 1188 if (name == 'Error') {
1188 // The prototype of the Error object must itself be an error. 1189 // The prototype of the Error object must itself be an error.
1189 // However, it can't be an instance of the Error object because 1190 // However, it can't be an instance of the Error object because
1190 // it hasn't been properly configured yet. Instead we create a 1191 // it hasn't been properly configured yet. Instead we create a
1191 // special not-a-true-error-but-close-enough object. 1192 // special not-a-true-error-but-close-enough object.
1192 var ErrorPrototype = function() {}; 1193 var ErrorPrototype = function() {};
1193 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); 1194 %FunctionSetPrototype(ErrorPrototype, $Object.prototype);
1194 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); 1195 %FunctionSetInstanceClassName(ErrorPrototype, 'Error');
1195 %FunctionSetPrototype(f, new ErrorPrototype()); 1196 %FunctionSetPrototype(f, new ErrorPrototype());
1196 } else { 1197 } else {
1197 %FunctionSetPrototype(f, new $Error()); 1198 %FunctionSetPrototype(f, new $Error());
1198 } 1199 }
1199 %FunctionSetInstanceClassName(f, 'Error'); 1200 %FunctionSetInstanceClassName(f, 'Error');
1200 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); 1201 %DefineProperty(f.prototype, 'constructor', f, DONT_ENUM);
1201 %SetProperty(f.prototype, "name", name, DONT_ENUM); 1202 %DefineProperty(f.prototype, "name", name, DONT_ENUM);
1202 %SetCode(f, function(m) { 1203 %SetCode(f, function(m) {
1203 if (%_IsConstructCall()) { 1204 if (%_IsConstructCall()) {
1204 // Define all the expected properties directly on the error 1205 // Define all the expected properties directly on the error
1205 // object. This avoids going through getters and setters defined 1206 // object. This avoids going through getters and setters defined
1206 // on prototype objects. 1207 // on prototype objects.
1207 %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM); 1208 %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM);
1208 if (!IS_UNDEFINED(m)) { 1209 if (!IS_UNDEFINED(m)) {
1209 %IgnoreAttributesAndSetProperty( 1210 %IgnoreAttributesAndSetProperty(
1210 this, 'message', ToString(m), DONT_ENUM); 1211 this, 'message', ToString(m), DONT_ENUM);
1211 } 1212 }
(...skipping 11 matching lines...) Expand all
1223 DefineError(function SyntaxError() { }); 1224 DefineError(function SyntaxError() { });
1224 DefineError(function ReferenceError() { }); 1225 DefineError(function ReferenceError() { });
1225 DefineError(function EvalError() { }); 1226 DefineError(function EvalError() { });
1226 DefineError(function URIError() { }); 1227 DefineError(function URIError() { });
1227 } 1228 }
1228 1229
1229 SetUpError(); 1230 SetUpError();
1230 1231
1231 $Error.captureStackTrace = captureStackTrace; 1232 $Error.captureStackTrace = captureStackTrace;
1232 1233
1233 %SetProperty($Error.prototype, 'message', '', DONT_ENUM); 1234 %DefineProperty($Error.prototype, 'message', '', DONT_ENUM);
1234 1235
1235 // Global list of error objects visited during ErrorToString. This is 1236 // Global list of error objects visited during ErrorToString. This is
1236 // used to detect cycles in error toString formatting. 1237 // used to detect cycles in error toString formatting.
1237 var visited_errors = new InternalArray(); 1238 var visited_errors = new InternalArray();
1238 var cyclic_error_marker = new $Object(); 1239 var cyclic_error_marker = new $Object();
1239 1240
1240 function GetPropertyWithoutInvokingMonkeyGetters(error, name) { 1241 function GetPropertyWithoutInvokingMonkeyGetters(error, name) {
1241 var current = error; 1242 var current = error;
1242 // Climb the prototype chain until we find the holder. 1243 // Climb the prototype chain until we find the holder.
1243 while (current && !%HasOwnProperty(current, name)) { 1244 while (current && !%HasOwnProperty(current, name)) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 return result; 1335 return result;
1335 }; 1336 };
1336 1337
1337 %DefineOrRedefineAccessorProperty( 1338 %DefineOrRedefineAccessorProperty(
1338 boilerplate, 'stack', getter, setter, DONT_ENUM); 1339 boilerplate, 'stack', getter, setter, DONT_ENUM);
1339 1340
1340 return boilerplate; 1341 return boilerplate;
1341 } 1342 }
1342 1343
1343 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1344 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698