| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 static void DefaultMessageReport(Isolate* isolate, | 82 static void DefaultMessageReport(Isolate* isolate, |
| 83 const MessageLocation* loc, | 83 const MessageLocation* loc, |
| 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 /* TypeError */ \ | 94 /* TypeError */ \ |
| 95 T(ApplyNonFunction, \ | 95 T(ApplyNonFunction, \ |
| 96 "Function.prototype.apply was called on %, which is a % and not a " \ | 96 "Function.prototype.apply was called on %, which is a % and not a " \ |
| 97 "function") \ | 97 "function") \ |
| 98 T(CalledNonCallable, "% is not a function") \ | 98 T(CalledNonCallable, "% is not a function") \ |
| 99 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ | 99 T(CalledOnNonObject, "% called on non-object") \ |
| 100 T(GeneratorRunning, "Generator is already running") \ | 100 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ |
| 101 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ | 101 T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ |
| 102 T(InstanceofFunctionExpected, \ | 102 T(GeneratorRunning, "Generator is already running") \ |
| 103 "Expecting a function in instanceof check, but got %") \ | 103 T(FunctionBind, "Bind must be called on a function") \ |
| 104 T(InstanceofNonobjectProto, \ | 104 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ |
| 105 "Function has non-object prototype '%' in instanceof check") \ | 105 T(InstanceofFunctionExpected, \ |
| 106 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ | 106 "Expecting a function in instanceof check, but got %") \ |
| 107 T(NotConstructor, "% is not a constructor") \ | 107 T(InstanceofNonobjectProto, \ |
| 108 T(PropertyNotFunction, "Property '%' of object % is not a function") \ | 108 "Function has non-object prototype '%' in instanceof check") \ |
| 109 T(SymbolToPrimitive, \ | 109 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ |
| 110 "Cannot convert a Symbol wrapper object to a primitive value") \ | 110 T(NotAnIterator, "% is not an iterator") \ |
| 111 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ | 111 T(NotConstructor, "% is not a constructor") \ |
| 112 T(SymbolToString, "Cannot convert a Symbol value to a string") \ | 112 T(NotGeneric, "% is not generic") \ |
| 113 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ | 113 T(NotIterable, "% is not iterable") \ |
| 114 T(WithExpression, "% has no properties") \ | 114 T(ObjectGetterExpectingFunction, \ |
| 115 T(WrongArgs, "%: Arguments list has wrong type") \ | 115 "Object.prototype.__defineGetter__: Expecting function") \ |
| 116 /* RangeError */ \ | 116 T(ObjectGetterCallable, "Getter must be a function: %") \ |
| 117 T(StackOverflow, "Maximum call stack size exceeded") \ | 117 T(ObjectSetterExpectingFunction, \ |
| 118 /* EvalError */ \ | 118 "Object.prototype.__defineSetter__: Expecting function") \ |
| 119 T(ObjectSetterCallable, "Setter must be a function: %") \ |
| 120 T(PropertyDescObject, "Property description must be an object: %") \ |
| 121 T(PropertyNotFunction, "Property '%' of object % is not a function") \ |
| 122 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ |
| 123 T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \ |
| 124 T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \ |
| 125 T(ProxyHandlerTrapMustBeCallable, \ |
| 126 "Proxy handler %0 has non-callable '%' trap") \ |
| 127 T(ProxyNonObjectPropNames, "Trap '%' returned non-object %") \ |
| 128 T(ProxyRepeatedPropName, "Trap '%' returned repeated property name '%'") \ |
| 129 T(ProxyPropNotConfigurable, \ |
| 130 "Proxy handler % returned non-configurable descriptor for property '%' " \ |
| 131 "from '%' trap") \ |
| 132 T(RedefineDisallowed, "Cannot redefine property: %") \ |
| 133 T(SymbolToPrimitive, \ |
| 134 "Cannot convert a Symbol wrapper object to a primitive value") \ |
| 135 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ |
| 136 T(SymbolToString, "Cannot convert a Symbol value to a string") \ |
| 137 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ |
| 138 T(ValueAndAccessor, \ |
| 139 "Invalid property. A property cannot both have accessors and be " \ |
| 140 "writable or have a value, %") \ |
| 141 T(WithExpression, "% has no properties") \ |
| 142 T(WrongArgs, "%: Arguments list has wrong type") \ |
| 143 /* RangeError */ \ |
| 144 T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \ |
| 145 T(NumberFormatRange, "% argument must be between 0 and 20") \ |
| 146 T(StackOverflow, "Maximum call stack size exceeded") \ |
| 147 T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ |
| 148 /* SyntaxError */ \ |
| 149 T(ParenthesisInArgString, "Function arg string contains parenthesis") \ |
| 150 /* EvalError */ \ |
| 119 T(CodeGenFromStrings, "%") | 151 T(CodeGenFromStrings, "%") |
| 120 | 152 |
| 121 class MessageTemplate { | 153 class MessageTemplate { |
| 122 public: | 154 public: |
| 123 enum Template { | 155 enum Template { |
| 124 #define TEMPLATE(NAME, STRING) k##NAME, | 156 #define TEMPLATE(NAME, STRING) k##NAME, |
| 125 MESSAGE_TEMPLATES(TEMPLATE) | 157 MESSAGE_TEMPLATES(TEMPLATE) |
| 126 #undef TEMPLATE | 158 #undef TEMPLATE |
| 127 kLastMessage | 159 kLastMessage |
| 128 }; | 160 }; |
| 129 | 161 |
| 130 static MaybeHandle<String> FormatMessage(int template_index, | 162 static MaybeHandle<String> FormatMessage(int template_index, |
| 131 Handle<String> arg0, | 163 Handle<String> arg0, |
| 132 Handle<String> arg1, | 164 Handle<String> arg1, |
| 133 Handle<String> arg2); | 165 Handle<String> arg2); |
| 134 }; | 166 }; |
| 135 } } // namespace v8::internal | 167 } } // namespace v8::internal |
| 136 | 168 |
| 137 #endif // V8_MESSAGES_H_ | 169 #endif // V8_MESSAGES_H_ |
| OLD | NEW |