mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:42: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()) | ||||
|             return {}; | ||||
|         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 {}; | ||||
|         } | ||||
| 
 | ||||
|  | @ -167,9 +167,9 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj | |||
|             } else { | ||||
|                 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 { | ||||
|             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 {}; | ||||
|     } | ||||
|  | @ -692,7 +692,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob | |||
|         if (interpreter.exception()) | ||||
|             return {}; | ||||
|         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 {}; | ||||
|         } | ||||
|         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); | ||||
|     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 value; | ||||
|  | @ -1731,7 +1731,7 @@ Value TaggedTemplateLiteral::execute(Interpreter& interpreter, GlobalObject& glo | |||
|     if (interpreter.exception()) | ||||
|         return {}; | ||||
|     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 {}; | ||||
|     } | ||||
|     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(); | ||||
|     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; | ||||
|     } | ||||
|     auto callback = vm.argument(0); | ||||
|     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 &callback.as_function(); | ||||
|  |  | |||
|  | @ -94,7 +94,7 @@ JS_DEFINE_NATIVE_GETTER(ErrorPrototype::message_getter) | |||
| JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) | ||||
| { | ||||
|     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 {}; | ||||
|     } | ||||
|     auto& this_object = vm.this_value(global_object).as_object(); | ||||
|  |  | |||
|  | @ -29,52 +29,52 @@ | |||
| #define JS_ENUMERATE_ERROR_TYPES(M)                                                                                                     \ | ||||
|     M(ArrayInvalidLength, "Invalid array length")                                                                                       \ | ||||
|     M(ArrayMaxSize, "Maximum array size exceeded")                                                                                      \ | ||||
|     M(ArrayPrototypeOneArg, "Array.prototype.%s() requires at least one argument")                                                      \ | ||||
|     M(AccessorBadField, "Accessor descriptor's '%s' field must be a function or undefined")                                             \ | ||||
|     M(ArrayPrototypeOneArg, "Array.prototype.{}() requires at least one argument")                                                      \ | ||||
|     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(BigIntBadOperator, "Cannot use %s operator with BigInt")                                                                          \ | ||||
|     M(BigIntBadOperatorOtherType, "Cannot use %s operator with BigInt and other type")                                                  \ | ||||
|     M(BigIntBadOperator, "Cannot use {} operator with BigInt")                                                                          \ | ||||
|     M(BigIntBadOperatorOtherType, "Cannot use {} operator with BigInt and other type")                                                  \ | ||||
|     M(BigIntIntArgument, "BigInt argument must be an integer")                                                                          \ | ||||
|     M(BigIntInvalidValue, "Invalid value for BigInt: %s")                                                                               \ | ||||
|     M(ClassDoesNotExtendAConstructorOrNull, "Class extends value %s is not a constructor or null")                                      \ | ||||
|     M(Convert, "Cannot convert %s to %s")                                                                                               \ | ||||
|     M(BigIntInvalidValue, "Invalid value for BigInt: {}")                                                                               \ | ||||
|     M(ClassDoesNotExtendAConstructorOrNull, "Class extends value {} is not a constructor or null")                                      \ | ||||
|     M(Convert, "Cannot convert {} to {}")                                                                                               \ | ||||
|     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(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(InvalidLeftHandAssignment, "Invalid left-hand side in assignment")                                                                \ | ||||
|     M(InvalidRadix, "Radix must be an integer no less than 2, and no greater than 36")                                                  \ | ||||
|     M(IsNotA, "%s is not a %s")                                                                                                         \ | ||||
|     M(IsNotAEvaluatedFrom, "%s is not a %s (evaluated from '%s')")                                                                      \ | ||||
|     M(IsNotA, "{} is not a {}")                                                                                                         \ | ||||
|     M(IsNotAEvaluatedFrom, "{} is not a {} (evaluated from '{}')")                                                                      \ | ||||
|     M(IterableNextBadReturn, "iterator.next() returned a non-object value")                                                             \ | ||||
|     M(IterableNextNotAFunction, "'next' property on returned object from Symbol.iterator method is "                                    \ | ||||
|                                 "not a function")                                                                                       \ | ||||
|     M(JsonBigInt, "Cannot serialize BigInt value to JSON")                                                                              \ | ||||
|     M(JsonCircular, "Cannot stringify circular object")                                                                                 \ | ||||
|     M(JsonMalformed, "Malformed JSON string")                                                                                           \ | ||||
|     M(NotA, "Not a %s object")                                                                                                          \ | ||||
|     M(NotAConstructor, "%s is not a constructor")                                                                                       \ | ||||
|     M(NotAFunction, "%s is not a function")                                                                                             \ | ||||
|     M(NotA, "Not a {} object")                                                                                                          \ | ||||
|     M(NotAConstructor, "{} is not a constructor")                                                                                       \ | ||||
|     M(NotAFunction, "{} is not a function")                                                                                             \ | ||||
|     M(NotAFunctionNoParam, "Not a function")                                                                                            \ | ||||
|     M(NotAn, "Not an %s object")                                                                                                        \ | ||||
|     M(NotAnObject, "%s is not an object")                                                                                               \ | ||||
|     M(NotASymbol, "%s is not a symbol")                                                                                                 \ | ||||
|     M(NotIterable, "%s is not iterable")                                                                                                \ | ||||
|     M(NonExtensibleDefine, "Cannot define property %s on non-extensible object")                                                        \ | ||||
|     M(NumberIncompatibleThis, "Number.prototype.%s method called with incompatible this target")                                        \ | ||||
|     M(NotAn, "Not an {} object")                                                                                                        \ | ||||
|     M(NotAnObject, "{} is not an object")                                                                                               \ | ||||
|     M(NotASymbol, "{} is not a symbol")                                                                                                 \ | ||||
|     M(NotIterable, "{} is not iterable")                                                                                                \ | ||||
|     M(NonExtensibleDefine, "Cannot define property {} on non-extensible object")                                                        \ | ||||
|     M(NumberIncompatibleThis, "Number.prototype.{} method called with incompatible this target")                                        \ | ||||
|     M(ObjectDefinePropertyReturnedFalse, "Object's [[DefineProperty]] method returned false")                                           \ | ||||
|     M(ObjectSetPrototypeOfReturnedFalse, "Object's [[SetPrototypeOf]] method returned false")                                           \ | ||||
|     M(ObjectSetPrototypeOfTwoArgs, "Object.setPrototypeOf requires at least two arguments")                                             \ | ||||
|     M(ObjectPreventExtensionsReturnedFalse, "Object's [[PreventExtensions]] method returned false")                                     \ | ||||
|     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(ProxyCallWithNew, "Proxy must be called with the 'new' operator")                                                                 \ | ||||
|     M(ProxyConstructBadReturnType, "Proxy handler's construct trap violates invariant: must return "                                    \ | ||||
|                                    "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 "                                              \ | ||||
|                                            "invariant: a property cannot be defined as non-configurable if it already exists on the "   \ | ||||
|                                            "target object as a configurable property")                                                  \ | ||||
|  | @ -121,7 +121,7 @@ | |||
|     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 "                 \ | ||||
|                                      "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: "                                                 \ | ||||
|                                "return value must match the target's extensibility")                                                    \ | ||||
|     M(ProxyPreventExtensionsReturn, "Proxy handler's preventExtensions trap violates "                                                  \ | ||||
|  | @ -138,24 +138,24 @@ | |||
|                                         "target is non-extensible")                                                                     \ | ||||
|     M(ProxyTwoArguments, "Proxy constructor requires at least two arguments")                                                           \ | ||||
|     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(ReflectArgumentMustBeAFunction, "First argument of Reflect.%s() must be a function")                                              \ | ||||
|     M(ReflectArgumentMustBeAnObject, "First argument of Reflect.%s() must be an object")                                                \ | ||||
|     M(ReflectArgumentMustBeAFunction, "First argument of Reflect.{}() must be a function")                                              \ | ||||
|     M(ReflectArgumentMustBeAnObject, "First argument of Reflect.{}() 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(ReflectBadDescriptorArgument, "Descriptor argument is not an object")                                                             \ | ||||
|     M(StringRawCannotConvert, "Cannot convert property 'raw' to object from %s")                                                        \ | ||||
|     M(StringRepeatCountMustBe, "repeat count must be a %s number")                                                                      \ | ||||
|     M(StringRawCannotConvert, "Cannot convert property 'raw' to object from {}")                                                        \ | ||||
|     M(StringRepeatCountMustBe, "repeat count must be a {} number")                                                                      \ | ||||
|     M(ThisHasNotBeenInitialized, "|this| has not been initialized")                                                                     \ | ||||
|     M(ThisIsAlreadyInitialized, "|this| is already initialized")                                                                        \ | ||||
|     M(ToObjectNullOrUndef, "ToObject on null or undefined")                                                                             \ | ||||
|     M(UnknownIdentifier, "'%s' is not defined")                                                                                         \ | ||||
|     M(UnknownIdentifier, "'{}' is not defined")                                                                                         \ | ||||
|     /* LibWeb bindings */                                                                                                               \ | ||||
|     M(NotAByteString, "Argument to %s() must be a byte string")                                                                         \ | ||||
|     M(BadArgCountOne, "%s() needs one argument")                                                                                        \ | ||||
|     M(BadArgCountAtLeastOne, "%s() needs at least one argument")                                                                        \ | ||||
|     M(BadArgCountMany, "%s() needs %s arguments") | ||||
|     M(NotAByteString, "Argument to {}() must be a byte string")                                                                         \ | ||||
|     M(BadArgCountOne, "{}() needs one argument")                                                                                        \ | ||||
|     M(BadArgCountAtLeastOne, "{}() needs at least one argument")                                                                        \ | ||||
|     M(BadArgCountMany, "{}() needs {} arguments") | ||||
| 
 | ||||
| namespace JS { | ||||
| 
 | ||||
|  |  | |||
|  | @ -45,14 +45,14 @@ Object* get_iterator(GlobalObject& global_object, Value value, String hint, Valu | |||
|             return {}; | ||||
|     } | ||||
|     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; | ||||
|     } | ||||
|     auto iterator = vm.call(method.as_function(), value); | ||||
|     if (vm.exception()) | ||||
|         return {}; | ||||
|     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 &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"; | ||||
| #endif | ||||
|         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; | ||||
|     } | ||||
| 
 | ||||
|  | @ -498,7 +498,7 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert | |||
|         dbg() << "Disallow reconfig of non-configurable property"; | ||||
| #endif | ||||
|         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; | ||||
|     } | ||||
| 
 | ||||
|  | @ -860,7 +860,7 @@ Value Object::invoke(const StringOrSymbol& property_name, Optional<MarkedValueLi | |||
|     if (vm.exception()) | ||||
|         return {}; | ||||
|     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 vm.call(property.as_function(), this, move(arguments)); | ||||
|  |  | |||
|  | @ -181,7 +181,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property_) | |||
|             if (object.is_proxy_object()) { | ||||
|                 vm.throw_exception<TypeError>(global_object, ErrorType::ObjectDefinePropertyReturnedFalse); | ||||
|             } 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 {}; | ||||
|  |  | |||
|  | @ -66,11 +66,11 @@ Value ProxyConstructor::construct(Function&) | |||
|     auto handler = vm.argument(1); | ||||
| 
 | ||||
|     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 {}; | ||||
|     } | ||||
|     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 ProxyObject::create(global_object(), target.as_object(), handler.as_object()); | ||||
|  |  | |||
|  | @ -462,7 +462,7 @@ void ProxyObject::visit_children(Cell::Visitor& visitor) | |||
| Value ProxyObject::call() | ||||
| { | ||||
|     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 {}; | ||||
|     } | ||||
|     if (m_is_revoked) { | ||||
|  | @ -495,7 +495,7 @@ Value ProxyObject::construct(Function& new_target) | |||
| { | ||||
|     auto& vm = this->vm(); | ||||
|     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 {}; | ||||
|     } | ||||
|     if (m_is_revoked) { | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ void Reference::put(GlobalObject& global_object, Value value) | |||
|     } | ||||
| 
 | ||||
|     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; | ||||
|     } | ||||
| 
 | ||||
|  | @ -68,7 +68,7 @@ void Reference::throw_reference_error(GlobalObject& global_object) | |||
|     if (property_name.is_empty()) { | ||||
|         global_object.vm().throw_exception<ReferenceError>(global_object, ErrorType::ReferenceUnresolvable); | ||||
|     } 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 target = vm.argument(0); | ||||
|     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 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 target = vm.argument(0); | ||||
|     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 &target.as_function(); | ||||
|  |  | |||
|  | @ -148,7 +148,7 @@ Value ScriptFunction::call() | |||
| Value ScriptFunction::construct(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 call(); | ||||
|  |  | |||
|  | @ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::key_for) | |||
| { | ||||
|     auto argument = vm.argument(0); | ||||
|     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 {}; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -197,7 +197,7 @@ public: | |||
|     template<typename T, typename... 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&); | ||||
|  |  | |||
|  | @ -312,7 +312,7 @@ BigInt* Value::to_bigint(GlobalObject& global_object) const | |||
|     case Type::String: { | ||||
|         auto& string = primitive.as_string().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 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(); | ||||
|     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 {}; | ||||
|     } | ||||
|     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_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 {}; | ||||
|         } | ||||
| 
 | ||||
|  | @ -716,7 +716,7 @@ Value instance_of(GlobalObject& global_object, Value lhs, Value rhs) | |||
|     } | ||||
| 
 | ||||
|     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 ordinary_has_instance(global_object, lhs, rhs); | ||||
|  | @ -743,7 +743,7 @@ Value ordinary_has_instance(GlobalObject& global_object, Value lhs, Value rhs) | |||
|         return {}; | ||||
| 
 | ||||
|     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 {}; | ||||
|     } | ||||
|     while (true) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh