mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	 1bbfaf8627
			
		
	
	
		1bbfaf8627
		
	
	
	
	
		
			
			Now we emit CreateVariable and SetVariable with the appropriate initialization/environment modes, much closer to the spec. This makes a whole lot of things like let/const variables, function and variable hoisting and some other things work :^)
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibJS/Bytecode/Interpreter.h>
 | |
| #include <LibJS/Runtime/ECMAScriptFunctionObject.h>
 | |
| #include <LibJS/Runtime/Object.h>
 | |
| 
 | |
| namespace JS {
 | |
| 
 | |
| class GeneratorObject final : public Object {
 | |
|     JS_OBJECT(GeneratorObject, Object);
 | |
| 
 | |
| public:
 | |
|     static ThrowCompletionOr<GeneratorObject*> create(GlobalObject&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow);
 | |
|     GeneratorObject(GlobalObject&, Object& prototype, ExecutionContext);
 | |
|     virtual void initialize(GlobalObject&) override;
 | |
|     virtual ~GeneratorObject() override;
 | |
|     void visit_edges(Cell::Visitor&) override;
 | |
| 
 | |
|     ThrowCompletionOr<Value> next_impl(VM&, GlobalObject&, Optional<Value> next_argument, Optional<Value> value_to_throw);
 | |
|     void set_done() { m_done = true; }
 | |
| 
 | |
| private:
 | |
|     ExecutionContext m_execution_context;
 | |
|     ECMAScriptFunctionObject* m_generating_function { nullptr };
 | |
|     Value m_previous_value;
 | |
|     Optional<Bytecode::RegisterWindow> m_frame;
 | |
|     bool m_done { false };
 | |
| };
 | |
| 
 | |
| }
 |