mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:22:43 +00:00 
			
		
		
		
	LibJS: Make Array constructor take its prototype
Let's start moving towards native JS objects taking their prototype as a constructor argument. This will eventually allow us to move prototypes off of Interpreter and into GlobalObject.
This commit is contained in:
		
							parent
							
								
									ee5816b9c8
								
							
						
					
					
						commit
						2d7b495244
					
				
					 7 changed files with 23 additions and 12 deletions
				
			
		|  | @ -46,11 +46,11 @@ ArrayConstructor::~ArrayConstructor() | |||
| 
 | ||||
| Value ArrayConstructor::call(Interpreter& interpreter) | ||||
| { | ||||
|     if (interpreter.argument_count() == 0) | ||||
|         return interpreter.heap().allocate<Array>(); | ||||
|     if (interpreter.argument_count() <= 0) | ||||
|         return Array::create(interpreter.global_object()); | ||||
| 
 | ||||
|     if (interpreter.argument_count() == 1) { | ||||
|         auto* array = interpreter.heap().allocate<Array>(); | ||||
|         auto* array = Array::create(interpreter.global_object()); | ||||
|         array->elements().resize(interpreter.argument(0).to_i32()); | ||||
|         return array; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling