mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:12:45 +00:00 
			
		
		
		
	LibJS: Use String::formatted() for throw_exception() message
This commit is contained in:
		
							parent
							
								
									a27668cbae
								
							
						
					
					
						commit
						f9eaac62d9
					
				
					 15 changed files with 64 additions and 64 deletions
				
			
		|  | @ -132,7 +132,7 @@ CallExpression::ThisAndCallee CallExpression::compute_this_and_callee(Interprete | ||||||
|         if (interpreter.exception()) |         if (interpreter.exception()) | ||||||
|             return {}; |             return {}; | ||||||
|         if (is_super_property_lookup && lookup_target.is_nullish()) { |         if (is_super_property_lookup && lookup_target.is_nullish()) { | ||||||
|             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess, lookup_target.to_string_without_side_effects().characters()); |             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess, lookup_target.to_string_without_side_effects()); | ||||||
|             return {}; |             return {}; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -167,9 +167,9 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj | ||||||
|             } else { |             } else { | ||||||
|                 expression_string = static_cast<const MemberExpression&>(*m_callee).to_string_approximation(); |                 expression_string = static_cast<const MemberExpression&>(*m_callee).to_string_approximation(); | ||||||
|             } |             } | ||||||
|             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::IsNotAEvaluatedFrom, callee.to_string_without_side_effects().characters(), call_type, expression_string.characters()); |             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::IsNotAEvaluatedFrom, callee.to_string_without_side_effects(), call_type, expression_string); | ||||||
|         } else { |         } else { | ||||||
|             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::IsNotA, callee.to_string_without_side_effects().characters(), call_type); |             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::IsNotA, callee.to_string_without_side_effects(), call_type); | ||||||
|         } |         } | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|  | @ -692,7 +692,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob | ||||||
|         if (interpreter.exception()) |         if (interpreter.exception()) | ||||||
|             return {}; |             return {}; | ||||||
|         if (!super_constructor.is_function() && !super_constructor.is_null()) { |         if (!super_constructor.is_function() && !super_constructor.is_null()) { | ||||||
|             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::ClassDoesNotExtendAConstructorOrNull, super_constructor.to_string_without_side_effects().characters()); |             interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::ClassDoesNotExtendAConstructorOrNull, super_constructor.to_string_without_side_effects()); | ||||||
|             return {}; |             return {}; | ||||||
|         } |         } | ||||||
|         class_constructor->set_constructor_kind(Function::ConstructorKind::Derived); |         class_constructor->set_constructor_kind(Function::ConstructorKind::Derived); | ||||||
|  | @ -1163,7 +1163,7 @@ Value Identifier::execute(Interpreter& interpreter, GlobalObject& global_object) | ||||||
| { | { | ||||||
|     auto value = interpreter.vm().get_variable(string(), global_object); |     auto value = interpreter.vm().get_variable(string(), global_object); | ||||||
|     if (value.is_empty()) { |     if (value.is_empty()) { | ||||||
|         interpreter.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, string().characters()); |         interpreter.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, string()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     return value; |     return value; | ||||||
|  | @ -1731,7 +1731,7 @@ Value TaggedTemplateLiteral::execute(Interpreter& interpreter, GlobalObject& glo | ||||||
|     if (interpreter.exception()) |     if (interpreter.exception()) | ||||||
|         return {}; |         return {}; | ||||||
|     if (!tag.is_function()) { |     if (!tag.is_function()) { | ||||||
|         interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::NotAFunction, tag.to_string_without_side_effects().characters()); |         interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::NotAFunction, tag.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     auto& tag_function = tag.as_function(); |     auto& tag_function = tag.as_function(); | ||||||
|  |  | ||||||
|  | @ -90,12 +90,12 @@ static Function* callback_from_args(GlobalObject& global_object, const String& n | ||||||
| { | { | ||||||
|     auto& vm = global_object.vm(); |     auto& vm = global_object.vm(); | ||||||
|     if (vm.argument_count() < 1) { |     if (vm.argument_count() < 1) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::ArrayPrototypeOneArg, name.characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::ArrayPrototypeOneArg, name); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     auto callback = vm.argument(0); |     auto callback = vm.argument(0); | ||||||
|     if (!callback.is_function()) { |     if (!callback.is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects()); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     return &callback.as_function(); |     return &callback.as_function(); | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ JS_DEFINE_NATIVE_GETTER(ErrorPrototype::message_getter) | ||||||
| JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) | JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) | ||||||
| { | { | ||||||
|     if (!vm.this_value(global_object).is_object()) { |     if (!vm.this_value(global_object).is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, vm.this_value(global_object).to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, vm.this_value(global_object).to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     auto& this_object = vm.this_value(global_object).as_object(); |     auto& this_object = vm.this_value(global_object).as_object(); | ||||||
|  |  | ||||||
|  | @ -29,52 +29,52 @@ | ||||||
| #define JS_ENUMERATE_ERROR_TYPES(M)                                                                                                     \ | #define JS_ENUMERATE_ERROR_TYPES(M)                                                                                                     \ | ||||||
|     M(ArrayInvalidLength, "Invalid array length")                                                                                       \ |     M(ArrayInvalidLength, "Invalid array length")                                                                                       \ | ||||||
|     M(ArrayMaxSize, "Maximum array size exceeded")                                                                                      \ |     M(ArrayMaxSize, "Maximum array size exceeded")                                                                                      \ | ||||||
|     M(ArrayPrototypeOneArg, "Array.prototype.%s() requires at least one argument")                                                      \ |     M(ArrayPrototypeOneArg, "Array.prototype.{}() requires at least one argument")                                                      \ | ||||||
|     M(AccessorBadField, "Accessor descriptor's '%s' field must be a function or undefined")                                             \ |     M(AccessorBadField, "Accessor descriptor's '{}' field must be a function or undefined")                                             \ | ||||||
|     M(AccessorValueOrWritable, "Accessor property descriptor cannot specify a value or writable key")                                   \ |     M(AccessorValueOrWritable, "Accessor property descriptor cannot specify a value or writable key")                                   \ | ||||||
|     M(BigIntBadOperator, "Cannot use %s operator with BigInt")                                                                          \ |     M(BigIntBadOperator, "Cannot use {} operator with BigInt")                                                                          \ | ||||||
|     M(BigIntBadOperatorOtherType, "Cannot use %s operator with BigInt and other type")                                                  \ |     M(BigIntBadOperatorOtherType, "Cannot use {} operator with BigInt and other type")                                                  \ | ||||||
|     M(BigIntIntArgument, "BigInt argument must be an integer")                                                                          \ |     M(BigIntIntArgument, "BigInt argument must be an integer")                                                                          \ | ||||||
|     M(BigIntInvalidValue, "Invalid value for BigInt: %s")                                                                               \ |     M(BigIntInvalidValue, "Invalid value for BigInt: {}")                                                                               \ | ||||||
|     M(ClassDoesNotExtendAConstructorOrNull, "Class extends value %s is not a constructor or null")                                      \ |     M(ClassDoesNotExtendAConstructorOrNull, "Class extends value {} is not a constructor or null")                                      \ | ||||||
|     M(Convert, "Cannot convert %s to %s")                                                                                               \ |     M(Convert, "Cannot convert {} to {}")                                                                                               \ | ||||||
|     M(ConvertUndefinedToObject, "Cannot convert undefined to object")                                                                   \ |     M(ConvertUndefinedToObject, "Cannot convert undefined to object")                                                                   \ | ||||||
|     M(DescChangeNonConfigurable, "Cannot change attributes of non-configurable property '%s'")                                          \ |     M(DescChangeNonConfigurable, "Cannot change attributes of non-configurable property '{}'")                                          \ | ||||||
|     M(FunctionArgsNotObject, "Argument array must be an object")                                                                        \ |     M(FunctionArgsNotObject, "Argument array must be an object")                                                                        \ | ||||||
|     M(InOperatorWithObject, "'in' operator must be used on an object")                                                                  \ |     M(InOperatorWithObject, "'in' operator must be used on an object")                                                                  \ | ||||||
|     M(InstanceOfOperatorBadPrototype, "'prototype' property of %s is not an object")                                                    \ |     M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object")                                                    \ | ||||||
|     M(InvalidAssignToConst, "Invalid assignment to const variable")                                                                     \ |     M(InvalidAssignToConst, "Invalid assignment to const variable")                                                                     \ | ||||||
|     M(InvalidLeftHandAssignment, "Invalid left-hand side in assignment")                                                                \ |     M(InvalidLeftHandAssignment, "Invalid left-hand side in assignment")                                                                \ | ||||||
|     M(InvalidRadix, "Radix must be an integer no less than 2, and no greater than 36")                                                  \ |     M(InvalidRadix, "Radix must be an integer no less than 2, and no greater than 36")                                                  \ | ||||||
|     M(IsNotA, "%s is not a %s")                                                                                                         \ |     M(IsNotA, "{} is not a {}")                                                                                                         \ | ||||||
|     M(IsNotAEvaluatedFrom, "%s is not a %s (evaluated from '%s')")                                                                      \ |     M(IsNotAEvaluatedFrom, "{} is not a {} (evaluated from '{}')")                                                                      \ | ||||||
|     M(IterableNextBadReturn, "iterator.next() returned a non-object value")                                                             \ |     M(IterableNextBadReturn, "iterator.next() returned a non-object value")                                                             \ | ||||||
|     M(IterableNextNotAFunction, "'next' property on returned object from Symbol.iterator method is "                                    \ |     M(IterableNextNotAFunction, "'next' property on returned object from Symbol.iterator method is "                                    \ | ||||||
|                                 "not a function")                                                                                       \ |                                 "not a function")                                                                                       \ | ||||||
|     M(JsonBigInt, "Cannot serialize BigInt value to JSON")                                                                              \ |     M(JsonBigInt, "Cannot serialize BigInt value to JSON")                                                                              \ | ||||||
|     M(JsonCircular, "Cannot stringify circular object")                                                                                 \ |     M(JsonCircular, "Cannot stringify circular object")                                                                                 \ | ||||||
|     M(JsonMalformed, "Malformed JSON string")                                                                                           \ |     M(JsonMalformed, "Malformed JSON string")                                                                                           \ | ||||||
|     M(NotA, "Not a %s object")                                                                                                          \ |     M(NotA, "Not a {} object")                                                                                                          \ | ||||||
|     M(NotAConstructor, "%s is not a constructor")                                                                                       \ |     M(NotAConstructor, "{} is not a constructor")                                                                                       \ | ||||||
|     M(NotAFunction, "%s is not a function")                                                                                             \ |     M(NotAFunction, "{} is not a function")                                                                                             \ | ||||||
|     M(NotAFunctionNoParam, "Not a function")                                                                                            \ |     M(NotAFunctionNoParam, "Not a function")                                                                                            \ | ||||||
|     M(NotAn, "Not an %s object")                                                                                                        \ |     M(NotAn, "Not an {} object")                                                                                                        \ | ||||||
|     M(NotAnObject, "%s is not an object")                                                                                               \ |     M(NotAnObject, "{} is not an object")                                                                                               \ | ||||||
|     M(NotASymbol, "%s is not a symbol")                                                                                                 \ |     M(NotASymbol, "{} is not a symbol")                                                                                                 \ | ||||||
|     M(NotIterable, "%s is not iterable")                                                                                                \ |     M(NotIterable, "{} is not iterable")                                                                                                \ | ||||||
|     M(NonExtensibleDefine, "Cannot define property %s on non-extensible object")                                                        \ |     M(NonExtensibleDefine, "Cannot define property {} on non-extensible object")                                                        \ | ||||||
|     M(NumberIncompatibleThis, "Number.prototype.%s method called with incompatible this target")                                        \ |     M(NumberIncompatibleThis, "Number.prototype.{} method called with incompatible this target")                                        \ | ||||||
|     M(ObjectDefinePropertyReturnedFalse, "Object's [[DefineProperty]] method returned false")                                           \ |     M(ObjectDefinePropertyReturnedFalse, "Object's [[DefineProperty]] method returned false")                                           \ | ||||||
|     M(ObjectSetPrototypeOfReturnedFalse, "Object's [[SetPrototypeOf]] method returned false")                                           \ |     M(ObjectSetPrototypeOfReturnedFalse, "Object's [[SetPrototypeOf]] method returned false")                                           \ | ||||||
|     M(ObjectSetPrototypeOfTwoArgs, "Object.setPrototypeOf requires at least two arguments")                                             \ |     M(ObjectSetPrototypeOfTwoArgs, "Object.setPrototypeOf requires at least two arguments")                                             \ | ||||||
|     M(ObjectPreventExtensionsReturnedFalse, "Object's [[PreventExtensions]] method returned false")                                     \ |     M(ObjectPreventExtensionsReturnedFalse, "Object's [[PreventExtensions]] method returned false")                                     \ | ||||||
|     M(ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess,                                                                              \ |     M(ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess,                                                                              \ | ||||||
|         "Object prototype must not be %s on a super property access")                                                                   \ |         "Object prototype must not be {} on a super property access")                                                                   \ | ||||||
|     M(ObjectPrototypeWrongType, "Prototype must be an object or null")                                                                  \ |     M(ObjectPrototypeWrongType, "Prototype must be an object or null")                                                                  \ | ||||||
|     M(ProxyCallWithNew, "Proxy must be called with the 'new' operator")                                                                 \ |     M(ProxyCallWithNew, "Proxy must be called with the 'new' operator")                                                                 \ | ||||||
|     M(ProxyConstructBadReturnType, "Proxy handler's construct trap violates invariant: must return "                                    \ |     M(ProxyConstructBadReturnType, "Proxy handler's construct trap violates invariant: must return "                                    \ | ||||||
|                                    "an object")                                                                                         \ |                                    "an object")                                                                                         \ | ||||||
|     M(ProxyConstructorBadType, "Expected %s argument of Proxy constructor to be object, got %s")                                        \ |     M(ProxyConstructorBadType, "Expected {} argument of Proxy constructor to be object, got {}")                                        \ | ||||||
|     M(ProxyDefinePropExistingConfigurable, "Proxy handler's defineProperty trap violates "                                              \ |     M(ProxyDefinePropExistingConfigurable, "Proxy handler's defineProperty trap violates "                                              \ | ||||||
|                                            "invariant: a property cannot be defined as non-configurable if it already exists on the "   \ |                                            "invariant: a property cannot be defined as non-configurable if it already exists on the "   \ | ||||||
|                                            "target object as a configurable property")                                                  \ |                                            "target object as a configurable property")                                                  \ | ||||||
|  | @ -121,7 +121,7 @@ | ||||||
|     M(ProxyHasExistingNonExtensible, "Proxy handler's has trap violates invariant: a property "                                         \ |     M(ProxyHasExistingNonExtensible, "Proxy handler's has trap violates invariant: a property "                                         \ | ||||||
|                                      "cannot be reported as non-existent if it exists on the target and the target is "                 \ |                                      "cannot be reported as non-existent if it exists on the target and the target is "                 \ | ||||||
|                                      "non-extensible")                                                                                  \ |                                      "non-extensible")                                                                                  \ | ||||||
|     M(ProxyInvalidTrap, "Proxy handler's %s trap wasn't undefined, null, or callable")                                                  \ |     M(ProxyInvalidTrap, "Proxy handler's {} trap wasn't undefined, null, or callable")                                                  \ | ||||||
|     M(ProxyIsExtensibleReturn, "Proxy handler's isExtensible trap violates invariant: "                                                 \ |     M(ProxyIsExtensibleReturn, "Proxy handler's isExtensible trap violates invariant: "                                                 \ | ||||||
|                                "return value must match the target's extensibility")                                                    \ |                                "return value must match the target's extensibility")                                                    \ | ||||||
|     M(ProxyPreventExtensionsReturn, "Proxy handler's preventExtensions trap violates "                                                  \ |     M(ProxyPreventExtensionsReturn, "Proxy handler's preventExtensions trap violates "                                                  \ | ||||||
|  | @ -138,24 +138,24 @@ | ||||||
|                                         "target is non-extensible")                                                                     \ |                                         "target is non-extensible")                                                                     \ | ||||||
|     M(ProxyTwoArguments, "Proxy constructor requires at least two arguments")                                                           \ |     M(ProxyTwoArguments, "Proxy constructor requires at least two arguments")                                                           \ | ||||||
|     M(ReduceNoInitial, "Reduce of empty array with no initial value")                                                                   \ |     M(ReduceNoInitial, "Reduce of empty array with no initial value")                                                                   \ | ||||||
|     M(ReferencePrimitiveAssignment, "Cannot assign property %s to primitive value")                                                     \ |     M(ReferencePrimitiveAssignment, "Cannot assign property {} to primitive value")                                                     \ | ||||||
|     M(ReferenceUnresolvable, "Unresolvable reference")                                                                                  \ |     M(ReferenceUnresolvable, "Unresolvable reference")                                                                                  \ | ||||||
|     M(ReflectArgumentMustBeAFunction, "First argument of Reflect.%s() must be a function")                                              \ |     M(ReflectArgumentMustBeAFunction, "First argument of Reflect.{}() must be a function")                                              \ | ||||||
|     M(ReflectArgumentMustBeAnObject, "First argument of Reflect.%s() must be an object")                                                \ |     M(ReflectArgumentMustBeAnObject, "First argument of Reflect.{}() must be an object")                                                \ | ||||||
|     M(ReflectBadArgumentsList, "Arguments list must be an object")                                                                      \ |     M(ReflectBadArgumentsList, "Arguments list must be an object")                                                                      \ | ||||||
|     M(ReflectBadNewTarget, "Optional third argument of Reflect.construct() must be a constructor")                                      \ |     M(ReflectBadNewTarget, "Optional third argument of Reflect.construct() must be a constructor")                                      \ | ||||||
|     M(ReflectBadDescriptorArgument, "Descriptor argument is not an object")                                                             \ |     M(ReflectBadDescriptorArgument, "Descriptor argument is not an object")                                                             \ | ||||||
|     M(StringRawCannotConvert, "Cannot convert property 'raw' to object from %s")                                                        \ |     M(StringRawCannotConvert, "Cannot convert property 'raw' to object from {}")                                                        \ | ||||||
|     M(StringRepeatCountMustBe, "repeat count must be a %s number")                                                                      \ |     M(StringRepeatCountMustBe, "repeat count must be a {} number")                                                                      \ | ||||||
|     M(ThisHasNotBeenInitialized, "|this| has not been initialized")                                                                     \ |     M(ThisHasNotBeenInitialized, "|this| has not been initialized")                                                                     \ | ||||||
|     M(ThisIsAlreadyInitialized, "|this| is already initialized")                                                                        \ |     M(ThisIsAlreadyInitialized, "|this| is already initialized")                                                                        \ | ||||||
|     M(ToObjectNullOrUndef, "ToObject on null or undefined")                                                                             \ |     M(ToObjectNullOrUndef, "ToObject on null or undefined")                                                                             \ | ||||||
|     M(UnknownIdentifier, "'%s' is not defined")                                                                                         \ |     M(UnknownIdentifier, "'{}' is not defined")                                                                                         \ | ||||||
|     /* LibWeb bindings */                                                                                                               \ |     /* LibWeb bindings */                                                                                                               \ | ||||||
|     M(NotAByteString, "Argument to %s() must be a byte string")                                                                         \ |     M(NotAByteString, "Argument to {}() must be a byte string")                                                                         \ | ||||||
|     M(BadArgCountOne, "%s() needs one argument")                                                                                        \ |     M(BadArgCountOne, "{}() needs one argument")                                                                                        \ | ||||||
|     M(BadArgCountAtLeastOne, "%s() needs at least one argument")                                                                        \ |     M(BadArgCountAtLeastOne, "{}() needs at least one argument")                                                                        \ | ||||||
|     M(BadArgCountMany, "%s() needs %s arguments") |     M(BadArgCountMany, "{}() needs {} arguments") | ||||||
| 
 | 
 | ||||||
| namespace JS { | namespace JS { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -45,14 +45,14 @@ Object* get_iterator(GlobalObject& global_object, Value value, String hint, Valu | ||||||
|             return {}; |             return {}; | ||||||
|     } |     } | ||||||
|     if (!method.is_function()) { |     if (!method.is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects()); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     auto iterator = vm.call(method.as_function(), value); |     auto iterator = vm.call(method.as_function(), value); | ||||||
|     if (vm.exception()) |     if (vm.exception()) | ||||||
|         return {}; |         return {}; | ||||||
|     if (!iterator.is_object()) { |     if (!iterator.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects()); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     return &iterator.as_object(); |     return &iterator.as_object(); | ||||||
|  |  | ||||||
|  | @ -464,7 +464,7 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert | ||||||
|         dbg() << "Disallow define_property of non-extensible object"; |         dbg() << "Disallow define_property of non-extensible object"; | ||||||
| #endif | #endif | ||||||
|         if (throw_exceptions && vm().in_strict_mode()) |         if (throw_exceptions && vm().in_strict_mode()) | ||||||
|             vm().throw_exception<TypeError>(global_object(), ErrorType::NonExtensibleDefine, property_name.to_display_string().characters()); |             vm().throw_exception<TypeError>(global_object(), ErrorType::NonExtensibleDefine, property_name.to_display_string()); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -498,7 +498,7 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert | ||||||
|         dbg() << "Disallow reconfig of non-configurable property"; |         dbg() << "Disallow reconfig of non-configurable property"; | ||||||
| #endif | #endif | ||||||
|         if (throw_exceptions) |         if (throw_exceptions) | ||||||
|             vm().throw_exception<TypeError>(global_object(), ErrorType::DescChangeNonConfigurable, property_name.to_display_string().characters()); |             vm().throw_exception<TypeError>(global_object(), ErrorType::DescChangeNonConfigurable, property_name.to_display_string()); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -860,7 +860,7 @@ Value Object::invoke(const StringOrSymbol& property_name, Optional<MarkedValueLi | ||||||
|     if (vm.exception()) |     if (vm.exception()) | ||||||
|         return {}; |         return {}; | ||||||
|     if (!property.is_function()) { |     if (!property.is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object(), ErrorType::NotAFunction, property.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object(), ErrorType::NotAFunction, property.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     return vm.call(property.as_function(), this, move(arguments)); |     return vm.call(property.as_function(), this, move(arguments)); | ||||||
|  |  | ||||||
|  | @ -181,7 +181,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property_) | ||||||
|             if (object.is_proxy_object()) { |             if (object.is_proxy_object()) { | ||||||
|                 vm.throw_exception<TypeError>(global_object, ErrorType::ObjectDefinePropertyReturnedFalse); |                 vm.throw_exception<TypeError>(global_object, ErrorType::ObjectDefinePropertyReturnedFalse); | ||||||
|             } else { |             } else { | ||||||
|                 vm.throw_exception<TypeError>(global_object, ErrorType::NonExtensibleDefine, property_key.to_display_string().characters()); |                 vm.throw_exception<TypeError>(global_object, ErrorType::NonExtensibleDefine, property_key.to_display_string()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return {}; |         return {}; | ||||||
|  |  | ||||||
|  | @ -66,11 +66,11 @@ Value ProxyConstructor::construct(Function&) | ||||||
|     auto handler = vm.argument(1); |     auto handler = vm.argument(1); | ||||||
| 
 | 
 | ||||||
|     if (!target.is_object()) { |     if (!target.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     if (!handler.is_object()) { |     if (!handler.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     return ProxyObject::create(global_object(), target.as_object(), handler.as_object()); |     return ProxyObject::create(global_object(), target.as_object(), handler.as_object()); | ||||||
|  |  | ||||||
|  | @ -462,7 +462,7 @@ void ProxyObject::visit_children(Cell::Visitor& visitor) | ||||||
| Value ProxyObject::call() | Value ProxyObject::call() | ||||||
| { | { | ||||||
|     if (!is_function()) { |     if (!is_function()) { | ||||||
|         vm().throw_exception<TypeError>(global_object(), ErrorType::NotAFunction, Value(this).to_string_without_side_effects().characters()); |         vm().throw_exception<TypeError>(global_object(), ErrorType::NotAFunction, Value(this).to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     if (m_is_revoked) { |     if (m_is_revoked) { | ||||||
|  | @ -495,7 +495,7 @@ Value ProxyObject::construct(Function& new_target) | ||||||
| { | { | ||||||
|     auto& vm = this->vm(); |     auto& vm = this->vm(); | ||||||
|     if (!is_function()) { |     if (!is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, Value(this).to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, Value(this).to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     if (m_is_revoked) { |     if (m_is_revoked) { | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ void Reference::put(GlobalObject& global_object, Value value) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!base().is_object() && vm.in_strict_mode()) { |     if (!base().is_object() && vm.in_strict_mode()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::ReferencePrimitiveAssignment, m_name.to_string().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::ReferencePrimitiveAssignment, m_name.to_string()); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -68,7 +68,7 @@ void Reference::throw_reference_error(GlobalObject& global_object) | ||||||
|     if (property_name.is_empty()) { |     if (property_name.is_empty()) { | ||||||
|         global_object.vm().throw_exception<ReferenceError>(global_object, ErrorType::ReferenceUnresolvable); |         global_object.vm().throw_exception<ReferenceError>(global_object, ErrorType::ReferenceUnresolvable); | ||||||
|     } else { |     } else { | ||||||
|         global_object.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, property_name.characters()); |         global_object.vm().throw_exception<ReferenceError>(global_object, ErrorType::UnknownIdentifier, property_name); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ static Object* get_target_object_from(GlobalObject& global_object, const String& | ||||||
|     auto& vm = global_object.vm(); |     auto& vm = global_object.vm(); | ||||||
|     auto target = vm.argument(0); |     auto target = vm.argument(0); | ||||||
|     if (!target.is_object()) { |     if (!target.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::ReflectArgumentMustBeAnObject, name.characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::ReflectArgumentMustBeAnObject, name); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     return static_cast<Object*>(&target.as_object()); |     return static_cast<Object*>(&target.as_object()); | ||||||
|  | @ -49,7 +49,7 @@ static Function* get_target_function_from(GlobalObject& global_object, const Str | ||||||
|     auto& vm = global_object.vm(); |     auto& vm = global_object.vm(); | ||||||
|     auto target = vm.argument(0); |     auto target = vm.argument(0); | ||||||
|     if (!target.is_function()) { |     if (!target.is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::ReflectArgumentMustBeAFunction, name.characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::ReflectArgumentMustBeAFunction, name); | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
|     return &target.as_function(); |     return &target.as_function(); | ||||||
|  |  | ||||||
|  | @ -148,7 +148,7 @@ Value ScriptFunction::call() | ||||||
| Value ScriptFunction::construct(Function&) | Value ScriptFunction::construct(Function&) | ||||||
| { | { | ||||||
|     if (m_is_arrow_function) { |     if (m_is_arrow_function) { | ||||||
|         vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, m_name.characters()); |         vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, m_name); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     return call(); |     return call(); | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::key_for) | ||||||
| { | { | ||||||
|     auto argument = vm.argument(0); |     auto argument = vm.argument(0); | ||||||
|     if (!argument.is_symbol()) { |     if (!argument.is_symbol()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotASymbol, argument.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotASymbol, argument.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -197,7 +197,7 @@ public: | ||||||
|     template<typename T, typename... Args> |     template<typename T, typename... Args> | ||||||
|     void throw_exception(GlobalObject& global_object, ErrorType type, Args&&... args) |     void throw_exception(GlobalObject& global_object, ErrorType type, Args&&... args) | ||||||
|     { |     { | ||||||
|         return throw_exception(global_object, T::create(global_object, String::format(type.message(), forward<Args>(args)...))); |         return throw_exception(global_object, T::create(global_object, String::formatted(type.message(), forward<Args>(args)...))); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject&); |     Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject&); | ||||||
|  |  | ||||||
|  | @ -312,7 +312,7 @@ BigInt* Value::to_bigint(GlobalObject& global_object) const | ||||||
|     case Type::String: { |     case Type::String: { | ||||||
|         auto& string = primitive.as_string().string(); |         auto& string = primitive.as_string().string(); | ||||||
|         if (!is_valid_bigint_value(string)) { |         if (!is_valid_bigint_value(string)) { | ||||||
|             vm.throw_exception<SyntaxError>(global_object, ErrorType::BigIntInvalidValue, string.characters()); |             vm.throw_exception<SyntaxError>(global_object, ErrorType::BigIntInvalidValue, string); | ||||||
|             return {}; |             return {}; | ||||||
|         } |         } | ||||||
|         return js_bigint(vm.heap(), Crypto::SignedBigInteger::from_base10(string.trim_whitespace())); |         return js_bigint(vm.heap(), Crypto::SignedBigInteger::from_base10(string.trim_whitespace())); | ||||||
|  | @ -702,13 +702,13 @@ Value instance_of(GlobalObject& global_object, Value lhs, Value rhs) | ||||||
| { | { | ||||||
|     auto& vm = global_object.vm(); |     auto& vm = global_object.vm(); | ||||||
|     if (!rhs.is_object()) { |     if (!rhs.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, rhs.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, rhs.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     auto has_instance_method = rhs.as_object().get(vm.well_known_symbol_has_instance()); |     auto has_instance_method = rhs.as_object().get(vm.well_known_symbol_has_instance()); | ||||||
|     if (!has_instance_method.is_empty()) { |     if (!has_instance_method.is_empty()) { | ||||||
|         if (!has_instance_method.is_function()) { |         if (!has_instance_method.is_function()) { | ||||||
|             vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, has_instance_method.to_string_without_side_effects().characters()); |             vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, has_instance_method.to_string_without_side_effects()); | ||||||
|             return {}; |             return {}; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -716,7 +716,7 @@ Value instance_of(GlobalObject& global_object, Value lhs, Value rhs) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!rhs.is_function()) { |     if (!rhs.is_function()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, rhs.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, rhs.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     return ordinary_has_instance(global_object, lhs, rhs); |     return ordinary_has_instance(global_object, lhs, rhs); | ||||||
|  | @ -743,7 +743,7 @@ Value ordinary_has_instance(GlobalObject& global_object, Value lhs, Value rhs) | ||||||
|         return {}; |         return {}; | ||||||
| 
 | 
 | ||||||
|     if (!rhs_prototype.is_object()) { |     if (!rhs_prototype.is_object()) { | ||||||
|         vm.throw_exception<TypeError>(global_object, ErrorType::InstanceOfOperatorBadPrototype, rhs_prototype.to_string_without_side_effects().characters()); |         vm.throw_exception<TypeError>(global_object, ErrorType::InstanceOfOperatorBadPrototype, rhs_prototype.to_string_without_side_effects()); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     while (true) { |     while (true) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh