feat(tvix/eval): implement with_stack in VM
Change-Id: I805c24c9a751ded15725ba9be651aa0869e013e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6218 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
		
							parent
							
								
									7cfdedfdfb
								
							
						
					
					
						commit
						5a497cdf1c
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -17,6 +17,10 @@ pub struct VM {
 | 
			
		|||
    ip: usize,
 | 
			
		||||
    chunk: Chunk,
 | 
			
		||||
    stack: Vec<Value>,
 | 
			
		||||
 | 
			
		||||
    // Stack indices of attribute sets from which variables should be
 | 
			
		||||
    // dynamically resolved (`with`).
 | 
			
		||||
    with_stack: Vec<usize>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
macro_rules! arithmetic_op {
 | 
			
		||||
| 
						 | 
				
			
			@ -277,7 +281,7 @@ impl VM {
 | 
			
		|||
                    self.push(value)
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                OpCode::OpPushWith(_idx) => todo!("with handling not implemented"),
 | 
			
		||||
                OpCode::OpPushWith(idx) => self.with_stack.push(idx),
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            #[cfg(feature = "disassembler")]
 | 
			
		||||
| 
						 | 
				
			
			@ -335,6 +339,7 @@ pub fn run_chunk(chunk: Chunk) -> EvalResult<Value> {
 | 
			
		|||
        chunk,
 | 
			
		||||
        ip: 0,
 | 
			
		||||
        stack: vec![],
 | 
			
		||||
        with_stack: vec![],
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    vm.run()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue