mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-15 09:05:25 +00:00
Make subscript its own bytecode. Remove pass bytecode. Move complex bytecodes into seperate functions to reduce complexity of dispatch function.
This commit is contained in:
parent
e0a52c15f6
commit
dac20eeb59
1 changed files with 2 additions and 8 deletions
|
@ -584,7 +584,7 @@ impl<O: OutputStream> Compiler<O> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pass => {
|
Pass => {
|
||||||
self.emit(Instruction::Pass);
|
// No need to emit any code here :)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1443,10 +1443,7 @@ impl<O: OutputStream> Compiler<O> {
|
||||||
Subscript { a, b } => {
|
Subscript { a, b } => {
|
||||||
self.compile_expression(a)?;
|
self.compile_expression(a)?;
|
||||||
self.compile_expression(b)?;
|
self.compile_expression(b)?;
|
||||||
self.emit(Instruction::BinaryOperation {
|
self.emit(Instruction::Subscript);
|
||||||
op: bytecode::BinaryOperator::Subscript,
|
|
||||||
inplace: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Unop { op, a } => {
|
Unop { op, a } => {
|
||||||
self.compile_expression(a)?;
|
self.compile_expression(a)?;
|
||||||
|
@ -2129,7 +2126,6 @@ mod tests {
|
||||||
JumpIfFalse {
|
JumpIfFalse {
|
||||||
target: Label::new(0)
|
target: Label::new(0)
|
||||||
},
|
},
|
||||||
Pass,
|
|
||||||
LoadConst { value: None },
|
LoadConst { value: None },
|
||||||
ReturnValue
|
ReturnValue
|
||||||
],
|
],
|
||||||
|
@ -2160,7 +2156,6 @@ mod tests {
|
||||||
JumpIfFalse {
|
JumpIfFalse {
|
||||||
target: Label::new(0)
|
target: Label::new(0)
|
||||||
},
|
},
|
||||||
Pass,
|
|
||||||
LoadConst { value: None },
|
LoadConst { value: None },
|
||||||
ReturnValue
|
ReturnValue
|
||||||
],
|
],
|
||||||
|
@ -2197,7 +2192,6 @@ mod tests {
|
||||||
JumpIfFalse {
|
JumpIfFalse {
|
||||||
target: Label::new(0)
|
target: Label::new(0)
|
||||||
},
|
},
|
||||||
Pass,
|
|
||||||
LoadConst { value: None },
|
LoadConst { value: None },
|
||||||
ReturnValue
|
ReturnValue
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue