mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-03 23:00:58 +00:00 
			
		
		
		
	LibJS: Move most of Interpreter into VM
This patch moves the exception state, call stack and scope stack from Interpreter to VM. I'm doing this to help myself discover what the split between Interpreter and VM should be, by shuffling things around and seeing what falls where. With these changes, we no longer have a persistent lexical environment for the current global object on the Interpreter's call stack. Instead, we push/pop that environment on Interpreter::run() enter/exit. Since it should only be used to find the global "this", and not for variable storage (that goes directly into the global object instead!), I had to insert some short-circuiting when walking the environment parent chain during variable lookup. Note that this is a "stepping stone" commit, not a final design.
This commit is contained in:
		
							parent
							
								
									838d9fa251
								
							
						
					
					
						commit
						6861c619c6
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-19 02:10:43 +09:00 
				
			
			Author: https://github.com/awesomekling
Commit: 6861c619c6
			
					 48 changed files with 765 additions and 726 deletions
				
			
		| 
						 | 
				
			
			@ -41,7 +41,7 @@ static ScriptFunction* typed_this(Interpreter& interpreter, GlobalObject& global
 | 
			
		|||
    if (!this_object)
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    if (!this_object->is_function()) {
 | 
			
		||||
        interpreter.throw_exception<TypeError>(ErrorType::NotAFunctionNoParam);
 | 
			
		||||
        interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::NotAFunctionNoParam);
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
    return static_cast<ScriptFunction*>(this_object);
 | 
			
		||||
| 
						 | 
				
			
			@ -130,13 +130,13 @@ Value ScriptFunction::call(Interpreter& interpreter)
 | 
			
		|||
        arguments.append({ parameter.name, value });
 | 
			
		||||
        interpreter.current_environment()->set(parameter.name, { value, DeclarationKind::Var });
 | 
			
		||||
    }
 | 
			
		||||
    return interpreter.execute_statement(global_object(), m_body, arguments, ScopeType::Function);
 | 
			
		||||
    return interpreter.vm().execute_statement(global_object(), m_body, arguments, ScopeType::Function);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Value ScriptFunction::construct(Interpreter& interpreter, Function&)
 | 
			
		||||
{
 | 
			
		||||
    if (m_is_arrow_function) {
 | 
			
		||||
        interpreter.throw_exception<TypeError>(ErrorType::NotAConstructor, m_name.characters());
 | 
			
		||||
        interpreter.vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, m_name.characters());
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
    return call(interpreter);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue