mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibJS: Move construction of GlobalObject native functions to Intrinsics
This will later allow global objects not inheriting from the regular JS::GlobalObject to pull in these functions without having to implement them from scratch. The primary use case here is, again, a wrapper-less HTML::Window in LibWeb :^) Allocating these upfront now allows us to get rid of two hacks: - The GlobalObject assigning Intrinsics private members after finishing its initialization - The GlobalObject defining the parseInt and parseFloat properties of the NumberConstructor object, as they are supposed to be identical with the global functions of the same name
This commit is contained in:
parent
3d5300a25e
commit
e3804e6426
5 changed files with 56 additions and 25 deletions
|
@ -41,10 +41,8 @@ void NumberConstructor::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.isInteger, is_integer, 1, attr);
|
||||
define_native_function(realm, vm.names.isNaN, is_nan, 1, attr);
|
||||
define_native_function(realm, vm.names.isSafeInteger, is_safe_integer, 1, attr);
|
||||
// NOTE: These are set from the global object as at this point we don't have them allocated yet;
|
||||
// The native functions are part of the global object itself.
|
||||
define_direct_property(vm.names.parseInt, js_undefined(), attr);
|
||||
define_direct_property(vm.names.parseFloat, js_undefined(), attr);
|
||||
define_direct_property(vm.names.parseInt, realm.intrinsics().parse_int_function(), attr);
|
||||
define_direct_property(vm.names.parseFloat, realm.intrinsics().parse_float_function(), attr);
|
||||
define_direct_property(vm.names.EPSILON, Value(EPSILON_VALUE), 0);
|
||||
define_direct_property(vm.names.MAX_VALUE, Value(NumericLimits<double>::max()), 0);
|
||||
define_direct_property(vm.names.MIN_VALUE, Value(NumericLimits<double>::min()), 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue