From dac20eeb59da00ac130df944326f73ad7fc91132 Mon Sep 17 00:00:00 2001 From: Windel Bouwman Date: Wed, 28 Aug 2019 12:06:46 +0200 Subject: [PATCH] Make subscript its own bytecode. Remove pass bytecode. Move complex bytecodes into seperate functions to reduce complexity of dispatch function. --- src/compile.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/compile.rs b/src/compile.rs index 40173db..7cdfa1a 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -584,7 +584,7 @@ impl Compiler { } } Pass => { - self.emit(Instruction::Pass); + // No need to emit any code here :) } } Ok(()) @@ -1443,10 +1443,7 @@ impl Compiler { Subscript { a, b } => { self.compile_expression(a)?; self.compile_expression(b)?; - self.emit(Instruction::BinaryOperation { - op: bytecode::BinaryOperator::Subscript, - inplace: false, - }); + self.emit(Instruction::Subscript); } Unop { op, a } => { self.compile_expression(a)?; @@ -2129,7 +2126,6 @@ mod tests { JumpIfFalse { target: Label::new(0) }, - Pass, LoadConst { value: None }, ReturnValue ], @@ -2160,7 +2156,6 @@ mod tests { JumpIfFalse { target: Label::new(0) }, - Pass, LoadConst { value: None }, ReturnValue ], @@ -2197,7 +2192,6 @@ mod tests { JumpIfFalse { target: Label::new(0) }, - Pass, LoadConst { value: None }, ReturnValue ],