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

Side by Side Diff: src/runtime.js

Issue 861623002: Add a pretty printer to improve the error message non-function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 5 years, 11 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
« no previous file with comments | « src/prettyprinter.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 function FILTER_KEY(key) { 370 function FILTER_KEY(key) {
371 var string = %ToName(key); 371 var string = %ToName(key);
372 if (%HasProperty(this, string)) return string; 372 if (%HasProperty(this, string)) return string;
373 return 0; 373 return 0;
374 } 374 }
375 375
376 376
377 function CALL_NON_FUNCTION() { 377 function CALL_NON_FUNCTION() {
378 var delegate = %GetFunctionDelegate(this); 378 var delegate = %GetFunctionDelegate(this);
379 if (!IS_FUNCTION(delegate)) { 379 if (!IS_FUNCTION(delegate)) {
380 throw %MakeTypeError('called_non_callable', [typeof this]); 380 var callsite = %RenderCallSite();
381 if (callsite == "") callsite = typeof this;
382 throw %MakeTypeError('called_non_callable', [callsite]);
381 } 383 }
382 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); 384 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
383 } 385 }
384 386
385 387
386 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { 388 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
387 var delegate = %GetConstructorDelegate(this); 389 var delegate = %GetConstructorDelegate(this);
388 if (!IS_FUNCTION(delegate)) { 390 if (!IS_FUNCTION(delegate)) {
389 throw %MakeTypeError('called_non_callable', [typeof this]); 391 var callsite = %RenderCallSite();
392 if (callsite == "") callsite = typeof this;
393 throw %MakeTypeError('called_non_callable', [callsite]);
390 } 394 }
391 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); 395 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
392 } 396 }
393 397
394 398
395 function CALL_FUNCTION_PROXY() { 399 function CALL_FUNCTION_PROXY() {
396 var arity = %_ArgumentsLength() - 1; 400 var arity = %_ArgumentsLength() - 1;
397 var proxy = %_Arguments(arity); // The proxy comes in as an additional arg. 401 var proxy = %_Arguments(arity); // The proxy comes in as an additional arg.
398 var trap = %GetCallTrap(proxy); 402 var trap = %GetCallTrap(proxy);
399 return %Apply(trap, this, arguments, 0, arity); 403 return %Apply(trap, this, arguments, 0, arity);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 return i; 687 return i;
684 } 688 }
685 689
686 690
687 // NOTE: Setting the prototype for Array must take place as early as 691 // NOTE: Setting the prototype for Array must take place as early as
688 // possible due to code generation for array literals. When 692 // possible due to code generation for array literals. When
689 // generating code for a array literal a boilerplate array is created 693 // generating code for a array literal a boilerplate array is created
690 // that is cloned when running the code. It is essential that the 694 // that is cloned when running the code. It is essential that the
691 // boilerplate gets the right prototype. 695 // boilerplate gets the right prototype.
692 %FunctionSetPrototype($Array, new $Array(0)); 696 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/prettyprinter.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698