OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Matches Script::Type from objects.h | 31 // Matches Script::Type from objects.h |
32 var TYPE_NATIVE = 0; | 32 var TYPE_NATIVE = 0; |
33 var TYPE_EXTENSION = 1; | 33 var TYPE_EXTENSION = 1; |
34 var TYPE_NORMAL = 2; | 34 var TYPE_NORMAL = 2; |
35 | 35 |
36 // Matches Script::CompilationType from objects.h | 36 // Matches Script::CompilationType from objects.h |
37 var COMPILATION_TYPE_HOST = 0; | 37 var COMPILATION_TYPE_HOST = 0; |
38 var COMPILATION_TYPE_EVAL = 1; | 38 var COMPILATION_TYPE_EVAL = 1; |
39 var COMPILATION_TYPE_JSON = 2; | 39 var COMPILATION_TYPE_JSON = 2; |
40 | 40 |
41 // Lazily initialized. | |
42 var kVowelSounds = 0; | |
43 var kCapitalVowelSounds = 0; | |
44 | |
45 // Matches Messages::kNoLineNumberInfo from v8.h | 41 // Matches Messages::kNoLineNumberInfo from v8.h |
46 var kNoLineNumberInfo = 0; | 42 var kNoLineNumberInfo = 0; |
47 | 43 |
48 // If this object gets passed to an error constructor the error will | 44 // If this object gets passed to an error constructor the error will |
49 // get an accessor for .message that constructs a descriptive error | 45 // get an accessor for .message that constructs a descriptive error |
50 // message on access. | 46 // message on access. |
51 var kAddMessageAccessorsMarker = { }; | 47 var kAddMessageAccessorsMarker = { }; |
52 | 48 |
53 var kMessages = 0; | 49 var kMessages = 0; |
54 | 50 |
55 var kReplacementMarkers = | 51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; |
56 [ "%0", "%1", "%2", "%3" ] | |
57 | 52 |
58 function FormatString(format, message) { | 53 function FormatString(format, message) { |
59 var args = %MessageGetArguments(message); | 54 var args = %MessageGetArguments(message); |
60 var result = ""; | 55 var result = ""; |
61 var arg_num = 0; | 56 var arg_num = 0; |
62 for (var i = 0; i < format.length; i++) { | 57 for (var i = 0; i < format.length; i++) { |
63 var str = format[i]; | 58 var str = format[i]; |
64 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { | 59 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { |
65 if (format[i] !== kReplacementMarkers[arg_num]) continue; | 60 if (format[i] !== kReplacementMarkers[arg_num]) continue; |
66 try { | 61 try { |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 else throw e; | 1052 else throw e; |
1058 } | 1053 } |
1059 } | 1054 } |
1060 | 1055 |
1061 %FunctionSetName(errorToString, 'toString'); | 1056 %FunctionSetName(errorToString, 'toString'); |
1062 %SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM); | 1057 %SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM); |
1063 | 1058 |
1064 // Boilerplate for exceptions for stack overflows. Used from | 1059 // Boilerplate for exceptions for stack overflows. Used from |
1065 // Top::StackOverflow(). | 1060 // Top::StackOverflow(). |
1066 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1061 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |