mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	LibJS: Add spec links to a bunch of the environment record methods
This commit is contained in:
		
							parent
							
								
									cf34313fad
								
							
						
					
					
						commit
						15faa13c95
					
				
					 3 changed files with 26 additions and 0 deletions
				
			
		|  | @ -76,6 +76,7 @@ bool DeclarativeEnvironmentRecord::has_binding(FlyString const& name) const | |||
|     return m_bindings.contains(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-declarative-environment-records-createmutablebinding-n-d
 | ||||
| void DeclarativeEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyString const& name, bool can_be_deleted) | ||||
| { | ||||
|     auto result = m_bindings.set(name, | ||||
|  | @ -89,6 +90,7 @@ void DeclarativeEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyStri | |||
|     VERIFY(result == AK::HashSetResult::InsertedNewEntry); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-createimmutablebinding-n-s
 | ||||
| void DeclarativeEnvironmentRecord::create_immutable_binding(GlobalObject&, FlyString const& name, bool strict) | ||||
| { | ||||
|     auto result = m_bindings.set(name, | ||||
|  | @ -102,6 +104,7 @@ void DeclarativeEnvironmentRecord::create_immutable_binding(GlobalObject&, FlySt | |||
|     VERIFY(result == AK::HashSetResult::InsertedNewEntry); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-declarative-environment-records-initializebinding-n-v
 | ||||
| void DeclarativeEnvironmentRecord::initialize_binding(GlobalObject&, FlyString const& name, Value value) | ||||
| { | ||||
|     auto it = m_bindings.find(name); | ||||
|  | @ -111,6 +114,7 @@ void DeclarativeEnvironmentRecord::initialize_binding(GlobalObject&, FlyString c | |||
|     it->value.initialized = true; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-setmutablebinding-n-v-s
 | ||||
| void DeclarativeEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict) | ||||
| { | ||||
|     auto it = m_bindings.find(name); | ||||
|  | @ -141,6 +145,7 @@ void DeclarativeEnvironmentRecord::set_mutable_binding(GlobalObject& global_obje | |||
|     } | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-getbindingvalue-n-s
 | ||||
| Value DeclarativeEnvironmentRecord::get_binding_value(GlobalObject& global_object, FlyString const& name, bool) | ||||
| { | ||||
|     auto it = m_bindings.find(name); | ||||
|  | @ -152,6 +157,7 @@ Value DeclarativeEnvironmentRecord::get_binding_value(GlobalObject& global_objec | |||
|     return it->value.value; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.1.7 DeleteBinding ( N ), https://tc39.es/ecma262/#sec-declarative-environment-records-deletebinding-n
 | ||||
| bool DeclarativeEnvironmentRecord::delete_binding(GlobalObject&, FlyString const& name) | ||||
| { | ||||
|     auto it = m_bindings.find(name); | ||||
|  |  | |||
|  | @ -63,6 +63,7 @@ bool GlobalEnvironmentRecord::has_binding(FlyString const& name) const | |||
|     return m_object_record->has_binding(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-global-environment-records-createmutablebinding-n-d
 | ||||
| void GlobalEnvironmentRecord::create_mutable_binding(GlobalObject& global_object, FlyString const& name, bool can_be_deleted) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) { | ||||
|  | @ -72,6 +73,7 @@ void GlobalEnvironmentRecord::create_mutable_binding(GlobalObject& global_object | |||
|     m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-createimmutablebinding-n-s
 | ||||
| void GlobalEnvironmentRecord::create_immutable_binding(GlobalObject& global_object, FlyString const& name, bool strict) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) { | ||||
|  | @ -81,6 +83,7 @@ void GlobalEnvironmentRecord::create_immutable_binding(GlobalObject& global_obje | |||
|     m_declarative_record->create_immutable_binding(global_object, name, strict); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-global-environment-records-initializebinding-n-v
 | ||||
| void GlobalEnvironmentRecord::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) { | ||||
|  | @ -90,6 +93,7 @@ void GlobalEnvironmentRecord::initialize_binding(GlobalObject& global_object, Fl | |||
|     m_object_record->initialize_binding(global_object, name, value); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-global-environment-records-setmutablebinding-n-v-s
 | ||||
| void GlobalEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) { | ||||
|  | @ -100,6 +104,7 @@ void GlobalEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, F | |||
|     m_object_record->set_mutable_binding(global_object, name, value, strict); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-getbindingvalue-n-s
 | ||||
| Value GlobalEnvironmentRecord::get_binding_value(GlobalObject& global_object, FlyString const& name, bool strict) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) | ||||
|  | @ -107,6 +112,7 @@ Value GlobalEnvironmentRecord::get_binding_value(GlobalObject& global_object, Fl | |||
|     return m_object_record->get_binding_value(global_object, name, strict); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.7 DeleteBinding ( N ), https://tc39.es/ecma262/#sec-global-environment-records-deletebinding-n
 | ||||
| bool GlobalEnvironmentRecord::delete_binding(GlobalObject& global_object, FlyString const& name) | ||||
| { | ||||
|     if (m_declarative_record->has_binding(name)) | ||||
|  | @ -123,16 +129,19 @@ bool GlobalEnvironmentRecord::delete_binding(GlobalObject& global_object, FlyStr | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.12 HasVarDeclaration ( N ), https://tc39.es/ecma262/#sec-hasvardeclaration
 | ||||
| bool GlobalEnvironmentRecord::has_var_declaration(FlyString const& name) const | ||||
| { | ||||
|     return m_var_names.contains_slow(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.13 HasLexicalDeclaration ( N ), https://tc39.es/ecma262/#sec-haslexicaldeclaration
 | ||||
| bool GlobalEnvironmentRecord::has_lexical_declaration(FlyString const& name) const | ||||
| { | ||||
|     return m_declarative_record->has_binding(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.14 HasRestrictedGlobalProperty ( N ), https://tc39.es/ecma262/#sec-hasrestrictedglobalproperty
 | ||||
| bool GlobalEnvironmentRecord::has_restricted_global_property(FlyString const& name) const | ||||
| { | ||||
|     auto existing_prop = m_global_object.get_own_property_descriptor(name); | ||||
|  | @ -143,6 +152,7 @@ bool GlobalEnvironmentRecord::has_restricted_global_property(FlyString const& na | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.15 CanDeclareGlobalVar ( N ), https://tc39.es/ecma262/#sec-candeclareglobalvar
 | ||||
| bool GlobalEnvironmentRecord::can_declare_global_var(FlyString const& name) const | ||||
| { | ||||
|     bool has_property = m_object_record->object().has_own_property(name); | ||||
|  | @ -151,6 +161,7 @@ bool GlobalEnvironmentRecord::can_declare_global_var(FlyString const& name) cons | |||
|     return m_object_record->object().is_extensible(); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.16 CanDeclareGlobalFunction ( N ), https://tc39.es/ecma262/#sec-candeclareglobalfunction
 | ||||
| bool GlobalEnvironmentRecord::can_declare_global_function(FlyString const& name) const | ||||
| { | ||||
|     auto existing_prop = m_object_record->object().get_own_property_descriptor(name); | ||||
|  | @ -163,6 +174,7 @@ bool GlobalEnvironmentRecord::can_declare_global_function(FlyString const& name) | |||
|     return false; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.17 CreateGlobalVarBinding ( N, D ), https://tc39.es/ecma262/#sec-createglobalvarbinding
 | ||||
| void GlobalEnvironmentRecord::create_global_var_binding(FlyString const& name, bool can_be_deleted) | ||||
| { | ||||
|     bool has_property = m_object_record->object().has_own_property(name); | ||||
|  | @ -175,6 +187,7 @@ void GlobalEnvironmentRecord::create_global_var_binding(FlyString const& name, b | |||
|         m_var_names.append(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.4.18 CreateGlobalFunctionBinding ( N, V, D ), https://tc39.es/ecma262/#sec-createglobalfunctionbinding
 | ||||
| void GlobalEnvironmentRecord::create_global_function_binding(FlyString const& name, Value value, bool can_be_deleted) | ||||
| { | ||||
|     auto existing_prop = m_object_record->object().get_own_property_descriptor(name); | ||||
|  |  | |||
|  | @ -52,6 +52,7 @@ bool ObjectEnvironmentRecord::has_binding(FlyString const& name) const | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-object-environment-records-createmutablebinding-n-d
 | ||||
| void ObjectEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyString const& name, bool can_be_deleted) | ||||
| { | ||||
|     PropertyAttributes attributes; | ||||
|  | @ -65,16 +66,20 @@ void ObjectEnvironmentRecord::create_mutable_binding(GlobalObject&, FlyString co | |||
|     m_object.define_property(name, js_undefined(), attributes, true); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-createimmutablebinding-n-s
 | ||||
| void ObjectEnvironmentRecord::create_immutable_binding(GlobalObject&, FlyString const&, bool) | ||||
| { | ||||
|     // "The CreateImmutableBinding concrete method of an object Environment Record is never used within this specification."
 | ||||
|     VERIFY_NOT_REACHED(); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-object-environment-records-initializebinding-n-v
 | ||||
| void ObjectEnvironmentRecord::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value) | ||||
| { | ||||
|     set_mutable_binding(global_object, name, value, false); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-object-environment-records-setmutablebinding-n-v-s
 | ||||
| void ObjectEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict) | ||||
| { | ||||
|     bool still_exists = m_object.has_property(name); | ||||
|  | @ -87,6 +92,7 @@ void ObjectEnvironmentRecord::set_mutable_binding(GlobalObject& global_object, F | |||
|     m_object.put(name, value); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-getbindingvalue-n-s
 | ||||
| Value ObjectEnvironmentRecord::get_binding_value(GlobalObject& global_object, FlyString const& name, bool strict) | ||||
| { | ||||
|     if (!m_object.has_property(name)) { | ||||
|  | @ -100,6 +106,7 @@ Value ObjectEnvironmentRecord::get_binding_value(GlobalObject& global_object, Fl | |||
|     return m_object.get(name); | ||||
| } | ||||
| 
 | ||||
| // 9.1.1.2.7 DeleteBinding ( N ), https://tc39.es/ecma262/#sec-object-environment-records-deletebinding-n
 | ||||
| bool ObjectEnvironmentRecord::delete_binding(GlobalObject&, FlyString const& name) | ||||
| { | ||||
|     return m_object.delete_property(name); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling