mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	LibJS: Extract most of Interpreter's run() into execute_statement()
Interpreter::run() was so far being used both as the "public API entry point" for running a JS::Program as well as internally to execute JS::Statement|s of all kinds - this is now more distinctly separated. A program as returned by the parser is still going through run(), which is responsible for creating the initial global call frame, but all other statements are executed via execute_statement() directly. Fixes #3437, a regression introduced by adding ASSERT(!exception()) to run() without considering the effects that would have on internal usage.
This commit is contained in:
		
							parent
							
								
									bd6390d8cb
								
							
						
					
					
						commit
						ec43f73b74
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-19 02:44:49 +09:00 
				
			
			Author: https://github.com/linusg
Commit: ec43f73b74
Pull-request: https://github.com/SerenityOS/serenity/pull/3457
Issue: https://github.com/SerenityOS/serenity/issues/3437
			
					 5 changed files with 55 additions and 25 deletions
				
			
		|  | @ -58,23 +58,26 @@ Interpreter::~Interpreter() | |||
| { | ||||
| } | ||||
| 
 | ||||
| Value Interpreter::run(GlobalObject& global_object, const Statement& statement, ArgumentVector arguments, ScopeType scope_type) | ||||
| Value Interpreter::run(GlobalObject& global_object, const Program& program) | ||||
| { | ||||
|     ASSERT(!exception()); | ||||
| 
 | ||||
|     if (statement.is_program()) { | ||||
|         if (m_call_stack.is_empty()) { | ||||
|             CallFrame global_call_frame; | ||||
|             global_call_frame.this_value = &global_object; | ||||
|             global_call_frame.function_name = "(global execution context)"; | ||||
|             global_call_frame.environment = heap().allocate<LexicalEnvironment>(global_object, LexicalEnvironment::EnvironmentRecordType::Global); | ||||
|             global_call_frame.environment->bind_this_value(&global_object); | ||||
|             if (exception()) | ||||
|                 return {}; | ||||
|             m_call_stack.append(move(global_call_frame)); | ||||
|         } | ||||
|     if (m_call_stack.is_empty()) { | ||||
|         CallFrame global_call_frame; | ||||
|         global_call_frame.this_value = &global_object; | ||||
|         global_call_frame.function_name = "(global execution context)"; | ||||
|         global_call_frame.environment = heap().allocate<LexicalEnvironment>(global_object, LexicalEnvironment::EnvironmentRecordType::Global); | ||||
|         global_call_frame.environment->bind_this_value(&global_object); | ||||
|         if (exception()) | ||||
|             return {}; | ||||
|         m_call_stack.append(move(global_call_frame)); | ||||
|     } | ||||
| 
 | ||||
|     return program.execute(*this, global_object); | ||||
| } | ||||
| 
 | ||||
| Value Interpreter::execute_statement(GlobalObject& global_object, const Statement& statement, ArgumentVector arguments, ScopeType scope_type) | ||||
| { | ||||
|     if (!statement.is_scope_node()) | ||||
|         return statement.execute(*this, global_object); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh