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

Side by Side Diff: src/messages.js

Issue 1065863003: Use array literals instead of array constructor in native javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 5 years, 8 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/math.js ('k') | src/object-observe.js » ('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 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 * 607 *
608 * @return {?string} script name if present, value for //# sourceURL or 608 * @return {?string} script name if present, value for //# sourceURL or
609 * deprecated //@ sourceURL comment otherwise. 609 * deprecated //@ sourceURL comment otherwise.
610 */ 610 */
611 function ScriptNameOrSourceURL() { 611 function ScriptNameOrSourceURL() {
612 if (this.source_url) return this.source_url; 612 if (this.source_url) return this.source_url;
613 return this.name; 613 return this.name;
614 } 614 }
615 615
616 616
617 SetUpLockedPrototype(Script, 617 SetUpLockedPrototype(Script, [
618 $Array("source", "name", "source_url", "source_mapping_url", "line_ends", 618 "source",
619 "line_offset", "column_offset"), 619 "name",
620 $Array( 620 "source_url",
621 "source_mapping_url",
622 "line_ends",
623 "line_offset",
624 "column_offset"
625 ], [
621 "lineFromPosition", ScriptLineFromPosition, 626 "lineFromPosition", ScriptLineFromPosition,
622 "locationFromPosition", ScriptLocationFromPosition, 627 "locationFromPosition", ScriptLocationFromPosition,
623 "locationFromLine", ScriptLocationFromLine, 628 "locationFromLine", ScriptLocationFromLine,
624 "sourceSlice", ScriptSourceSlice, 629 "sourceSlice", ScriptSourceSlice,
625 "sourceLine", ScriptSourceLine, 630 "sourceLine", ScriptSourceLine,
626 "lineCount", ScriptLineCount, 631 "lineCount", ScriptLineCount,
627 "nameOrSourceURL", ScriptNameOrSourceURL 632 "nameOrSourceURL", ScriptNameOrSourceURL
628 ) 633 ]
629 ); 634 );
630 635
631 636
632 /** 637 /**
633 * Class for source location. A source location is a position within some 638 * Class for source location. A source location is a position within some
634 * source with the following properties: 639 * source with the following properties:
635 * script : script object for the source 640 * script : script object for the source
636 * line : source line number 641 * line : source line number
637 * column : source column within the line 642 * column : source column within the line
638 * position : position within the source 643 * position : position within the source
(...skipping 28 matching lines...) Expand all
667 */ 672 */
668 function SourceLocationSourceText() { 673 function SourceLocationSourceText() {
669 return %_CallFunction(this.script.source, 674 return %_CallFunction(this.script.source,
670 this.start, 675 this.start,
671 this.end, 676 this.end,
672 $stringSubstring); 677 $stringSubstring);
673 } 678 }
674 679
675 680
676 SetUpLockedPrototype(SourceLocation, 681 SetUpLockedPrototype(SourceLocation,
677 $Array("script", "position", "line", "column", "start", "end"), 682 ["script", "position", "line", "column", "start", "end"],
678 $Array( 683 ["sourceText", SourceLocationSourceText]
679 "sourceText", SourceLocationSourceText
680 )
681 ); 684 );
682 685
683 686
684 /** 687 /**
685 * Class for a source slice. A source slice is a part of a script source with 688 * Class for a source slice. A source slice is a part of a script source with
686 * the following properties: 689 * the following properties:
687 * script : script object for the source 690 * script : script object for the source
688 * from_line : line number for the first line in the slice 691 * from_line : line number for the first line in the slice
689 * to_line : source line number for the last line in the slice 692 * to_line : source line number for the last line in the slice
690 * from_position : position of the first character in the slice 693 * from_position : position of the first character in the slice
(...skipping 22 matching lines...) Expand all
713 * the line terminating characters (if any) 716 * the line terminating characters (if any)
714 */ 717 */
715 function SourceSliceSourceText() { 718 function SourceSliceSourceText() {
716 return %_CallFunction(this.script.source, 719 return %_CallFunction(this.script.source,
717 this.from_position, 720 this.from_position,
718 this.to_position, 721 this.to_position,
719 $stringSubstring); 722 $stringSubstring);
720 } 723 }
721 724
722 SetUpLockedPrototype(SourceSlice, 725 SetUpLockedPrototype(SourceSlice,
723 $Array("script", "from_line", "to_line", "from_position", "to_position"), 726 ["script", "from_line", "to_line", "from_position", "to_position"],
724 $Array("sourceText", SourceSliceSourceText) 727 ["sourceText", SourceSliceSourceText]
725 ); 728 );
726 729
727 730
728 // Returns the offset of the given position within the containing 731 // Returns the offset of the given position within the containing
729 // line. 732 // line.
730 function GetPositionInLine(message) { 733 function GetPositionInLine(message) {
731 var script = %MessageGetScript(message); 734 var script = %MessageGetScript(message);
732 var start_position = %MessageGetStartPosition(message); 735 var start_position = %MessageGetStartPosition(message);
733 var location = script.locationFromPosition(start_position, false); 736 var location = script.locationFromPosition(start_position, false);
734 if (location == null) return -1; 737 if (location == null) return -1;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 } else { 948 } else {
946 line += fileLocation; 949 line += fileLocation;
947 addSuffix = false; 950 addSuffix = false;
948 } 951 }
949 if (addSuffix) { 952 if (addSuffix) {
950 line += " (" + fileLocation + ")"; 953 line += " (" + fileLocation + ")";
951 } 954 }
952 return line; 955 return line;
953 } 956 }
954 957
955 SetUpLockedPrototype(CallSite, $Array("receiver", "fun", "pos"), $Array( 958 SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
956 "getThis", CallSiteGetThis, 959 "getThis", CallSiteGetThis,
957 "getTypeName", CallSiteGetTypeName, 960 "getTypeName", CallSiteGetTypeName,
958 "isToplevel", CallSiteIsToplevel, 961 "isToplevel", CallSiteIsToplevel,
959 "isEval", CallSiteIsEval, 962 "isEval", CallSiteIsEval,
960 "getEvalOrigin", CallSiteGetEvalOrigin, 963 "getEvalOrigin", CallSiteGetEvalOrigin,
961 "getScriptNameOrSourceURL", CallSiteGetScriptNameOrSourceURL, 964 "getScriptNameOrSourceURL", CallSiteGetScriptNameOrSourceURL,
962 "getFunction", CallSiteGetFunction, 965 "getFunction", CallSiteGetFunction,
963 "getFunctionName", CallSiteGetFunctionName, 966 "getFunctionName", CallSiteGetFunctionName,
964 "getMethodName", CallSiteGetMethodName, 967 "getMethodName", CallSiteGetMethodName,
965 "getFileName", CallSiteGetFileName, 968 "getFileName", CallSiteGetFileName,
966 "getLineNumber", CallSiteGetLineNumber, 969 "getLineNumber", CallSiteGetLineNumber,
967 "getColumnNumber", CallSiteGetColumnNumber, 970 "getColumnNumber", CallSiteGetColumnNumber,
968 "isNative", CallSiteIsNative, 971 "isNative", CallSiteIsNative,
969 "getPosition", CallSiteGetPosition, 972 "getPosition", CallSiteGetPosition,
970 "isConstructor", CallSiteIsConstructor, 973 "isConstructor", CallSiteIsConstructor,
971 "toString", CallSiteToString 974 "toString", CallSiteToString
972 )); 975 ]);
973 976
974 977
975 function FormatEvalOrigin(script) { 978 function FormatEvalOrigin(script) {
976 var sourceURL = script.nameOrSourceURL(); 979 var sourceURL = script.nameOrSourceURL();
977 if (sourceURL) { 980 if (sourceURL) {
978 return sourceURL; 981 return sourceURL;
979 } 982 }
980 983
981 var eval_origin = "eval at "; 984 var eval_origin = "eval at ";
982 if (script.eval_from_function_name) { 985 if (script.eval_from_function_name) {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 function SetUpStackOverflowBoilerplate() { 1284 function SetUpStackOverflowBoilerplate() {
1282 var boilerplate = MakeRangeError('stack_overflow', []); 1285 var boilerplate = MakeRangeError('stack_overflow', []);
1283 1286
1284 %DefineAccessorPropertyUnchecked( 1287 %DefineAccessorPropertyUnchecked(
1285 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); 1288 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM);
1286 1289
1287 return boilerplate; 1290 return boilerplate;
1288 } 1291 }
1289 1292
1290 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); 1293 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate();
OLDNEW
« no previous file with comments | « src/math.js ('k') | src/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698