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 // 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 // The infrastructure used for (localized) message reporting in V8. | 5 // The infrastructure used for (localized) message reporting in V8. |
6 // | 6 // |
7 // Note: there's a big unresolved issue about ownership of the data | 7 // Note: there's a big unresolved issue about ownership of the data |
8 // structures used by this framework. | 8 // structures used by this framework. |
9 | 9 |
10 #ifndef V8_MESSAGES_H_ | 10 #ifndef V8_MESSAGES_H_ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 Handle<Object> message_obj); | 84 Handle<Object> message_obj); |
85 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); | 85 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
86 static SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, | 86 static SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, |
87 Handle<Object> data); | 87 Handle<Object> data); |
88 }; | 88 }; |
89 | 89 |
90 | 90 |
91 #define MESSAGE_TEMPLATES(T) \ | 91 #define MESSAGE_TEMPLATES(T) \ |
92 /* Error */ \ | 92 /* Error */ \ |
93 T(CyclicProto, "Cyclic __proto__ value") \ | 93 T(CyclicProto, "Cyclic __proto__ value") \ |
| 94 T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \ |
| 95 T(Unsupported, "Not supported") \ |
| 96 T(WrongServiceType, "Internal error, wrong service type: %") \ |
| 97 T(WrongValueType, "Internal error. Wrong value type.") \ |
94 /* TypeError */ \ | 98 /* TypeError */ \ |
95 T(ApplyNonFunction, \ | 99 T(ApplyNonFunction, \ |
96 "Function.prototype.apply was called on %, which is a % and not a " \ | 100 "Function.prototype.apply was called on %, which is a % and not a " \ |
97 "function") \ | 101 "function") \ |
| 102 T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \ |
| 103 T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \ |
98 T(CalledNonCallable, "% is not a function") \ | 104 T(CalledNonCallable, "% is not a function") \ |
99 T(CalledOnNonObject, "% called on non-object") \ | 105 T(CalledOnNonObject, "% called on non-object") \ |
| 106 T(CalledOnNullOrUndefined, "% called on null or undefined") \ |
| 107 T(CurrencyCode, "Currency code is required with currency style.") \ |
100 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ | 108 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ |
| 109 T(DateType, "this is not a Date object.") \ |
101 T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ | 110 T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ |
102 T(GeneratorRunning, "Generator is already running") \ | 111 T(GeneratorRunning, "Generator is already running") \ |
103 T(FunctionBind, "Bind must be called on a function") \ | 112 T(FunctionBind, "Bind must be called on a function") \ |
104 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ | 113 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ |
105 T(InstanceofFunctionExpected, \ | 114 T(InstanceofFunctionExpected, \ |
106 "Expecting a function in instanceof check, but got %") \ | 115 "Expecting a function in instanceof check, but got %") \ |
107 T(InstanceofNonobjectProto, \ | 116 T(InstanceofNonobjectProto, \ |
108 "Function has non-object prototype '%' in instanceof check") \ | 117 "Function has non-object prototype '%' in instanceof check") \ |
109 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ | 118 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ |
| 119 T(LanguageID, "Language ID should be string or object.") \ |
| 120 T(MethodCalledOnWrongObject, \ |
| 121 "Method % called on a non-object or on a wrong type of object.") \ |
| 122 T(MethodInvokedOnNullOrUndefined, \ |
| 123 "Method invoked on undefined or null value.") \ |
| 124 T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \ |
110 T(NotAnIterator, "% is not an iterator") \ | 125 T(NotAnIterator, "% is not an iterator") \ |
111 T(NotConstructor, "% is not a constructor") \ | 126 T(NotConstructor, "% is not a constructor") \ |
112 T(NotGeneric, "% is not generic") \ | 127 T(NotGeneric, "% is not generic") \ |
113 T(NotIterable, "% is not iterable") \ | 128 T(NotIterable, "% is not iterable") \ |
114 T(ObjectGetterExpectingFunction, \ | 129 T(ObjectGetterExpectingFunction, \ |
115 "Object.prototype.__defineGetter__: Expecting function") \ | 130 "Object.prototype.__defineGetter__: Expecting function") \ |
116 T(ObjectGetterCallable, "Getter must be a function: %") \ | 131 T(ObjectGetterCallable, "Getter must be a function: %") \ |
117 T(ObjectSetterExpectingFunction, \ | 132 T(ObjectSetterExpectingFunction, \ |
118 "Object.prototype.__defineSetter__: Expecting function") \ | 133 "Object.prototype.__defineSetter__: Expecting function") \ |
119 T(ObjectSetterCallable, "Setter must be a function: %") \ | 134 T(ObjectSetterCallable, "Setter must be a function: %") \ |
| 135 T(OrdinaryFunctionCalledAsConstructor, \ |
| 136 "Function object that's not a constructor was created with new") \ |
120 T(PropertyDescObject, "Property description must be an object: %") \ | 137 T(PropertyDescObject, "Property description must be an object: %") \ |
121 T(PropertyNotFunction, "Property '%' of object % is not a function") \ | 138 T(PropertyNotFunction, "Property '%' of object % is not a function") \ |
122 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ | 139 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ |
123 T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \ | 140 T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \ |
124 T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \ | 141 T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \ |
125 T(ProxyHandlerTrapMustBeCallable, \ | 142 T(ProxyHandlerTrapMustBeCallable, \ |
126 "Proxy handler %0 has non-callable '%' trap") \ | 143 "Proxy handler %0 has non-callable '%' trap") \ |
127 T(ProxyNonObjectPropNames, "Trap '%' returned non-object %") \ | 144 T(ProxyNonObjectPropNames, "Trap '%' returned non-object %") \ |
128 T(ProxyRepeatedPropName, "Trap '%' returned repeated property name '%'") \ | 145 T(ProxyRepeatedPropName, "Trap '%' returned repeated property name '%'") \ |
129 T(ProxyPropNotConfigurable, \ | 146 T(ProxyPropNotConfigurable, \ |
130 "Proxy handler % returned non-configurable descriptor for property '%' " \ | 147 "Proxy handler % returned non-configurable descriptor for property '%' " \ |
131 "from '%' trap") \ | 148 "from '%' trap") \ |
132 T(RedefineDisallowed, "Cannot redefine property: %") \ | 149 T(RedefineDisallowed, "Cannot redefine property: %") \ |
| 150 T(ReduceNoInitial, "Reduce of empty array with no initial value") \ |
| 151 T(ReinitializeIntl, "Trying to re-initialize % object.") \ |
| 152 T(ResolvedOptionsCalledOnNonObject, \ |
| 153 "resolvedOptions method called on a non-object or on a object that is " \ |
| 154 "not Intl.%.") \ |
133 T(SymbolToPrimitive, \ | 155 T(SymbolToPrimitive, \ |
134 "Cannot convert a Symbol wrapper object to a primitive value") \ | 156 "Cannot convert a Symbol wrapper object to a primitive value") \ |
135 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ | 157 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ |
136 T(SymbolToString, "Cannot convert a Symbol value to a string") \ | 158 T(SymbolToString, "Cannot convert a Symbol value to a string") \ |
137 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ | 159 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ |
138 T(ValueAndAccessor, \ | 160 T(ValueAndAccessor, \ |
139 "Invalid property. A property cannot both have accessors and be " \ | 161 "Invalid property. A property cannot both have accessors and be " \ |
140 "writable or have a value, %") \ | 162 "writable or have a value, %") \ |
141 T(WithExpression, "% has no properties") \ | 163 T(WithExpression, "% has no properties") \ |
142 T(WrongArgs, "%: Arguments list has wrong type") \ | 164 T(WrongArgs, "%: Arguments list has wrong type") \ |
143 /* RangeError */ \ | 165 /* RangeError */ \ |
144 T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \ | 166 T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \ |
| 167 T(DateRange, "Provided date is not in valid range.") \ |
| 168 T(ExpectedLocation, "Expected Area/Location for time zone, got %") \ |
| 169 T(InvalidCurrencyCode, "Invalid currency code: %") \ |
| 170 T(InvalidLanguageTag, "Invalid language tag: %") \ |
| 171 T(LocaleMatcher, "Illegal value for localeMatcher:%") \ |
| 172 T(NormalizationForm, "The normalization form should be one of %.") \ |
145 T(NumberFormatRange, "% argument must be between 0 and 20") \ | 173 T(NumberFormatRange, "% argument must be between 0 and 20") \ |
| 174 T(PropertyValueOutOfRange, "% value is out of range.") \ |
146 T(StackOverflow, "Maximum call stack size exceeded") \ | 175 T(StackOverflow, "Maximum call stack size exceeded") \ |
147 T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ | 176 T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ |
| 177 T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \ |
| 178 T(UnsupportedTimeZone, "Unsupported time zone specified %") \ |
| 179 T(ValueOutOfRange, "Value % out of range for % options property %") \ |
148 /* SyntaxError */ \ | 180 /* SyntaxError */ \ |
149 T(ParenthesisInArgString, "Function arg string contains parenthesis") \ | 181 T(ParenthesisInArgString, "Function arg string contains parenthesis") \ |
150 /* EvalError */ \ | 182 /* EvalError */ \ |
151 T(CodeGenFromStrings, "%") | 183 T(CodeGenFromStrings, "%") \ |
| 184 /* URIError */ \ |
| 185 T(URIMalformed, "URI malformed") |
152 | 186 |
153 class MessageTemplate { | 187 class MessageTemplate { |
154 public: | 188 public: |
155 enum Template { | 189 enum Template { |
156 #define TEMPLATE(NAME, STRING) k##NAME, | 190 #define TEMPLATE(NAME, STRING) k##NAME, |
157 MESSAGE_TEMPLATES(TEMPLATE) | 191 MESSAGE_TEMPLATES(TEMPLATE) |
158 #undef TEMPLATE | 192 #undef TEMPLATE |
159 kLastMessage | 193 kLastMessage |
160 }; | 194 }; |
161 | 195 |
162 static MaybeHandle<String> FormatMessage(int template_index, | 196 static MaybeHandle<String> FormatMessage(int template_index, |
163 Handle<String> arg0, | 197 Handle<String> arg0, |
164 Handle<String> arg1, | 198 Handle<String> arg1, |
165 Handle<String> arg2); | 199 Handle<String> arg2); |
166 }; | 200 }; |
167 } } // namespace v8::internal | 201 } } // namespace v8::internal |
168 | 202 |
169 #endif // V8_MESSAGES_H_ | 203 #endif // V8_MESSAGES_H_ |
OLD | NEW |