mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-15 00:18:06 -05:00
Extract constants later so that simplify has more information
This commit is contained in:
@@ -561,12 +561,20 @@ impl StackFrameTrait for BytecodeStackFrame {
|
||||
}
|
||||
|
||||
Cat => {
|
||||
assert!(
|
||||
self.decoder.decode_type() == BytecodeType::Array,
|
||||
"TODO: cat non-inline arrays"
|
||||
);
|
||||
|
||||
let cat_frame = CatStackFrame::from_args(self.decoder.decode_vec_val(&mut self.registers));
|
||||
let cat_frame = match self.decoder.peek_type() {
|
||||
BytecodeType::Array => {
|
||||
self.decoder.decode_type();
|
||||
CatStackFrame::from_vec_val(self.decoder.decode_vec_val(&mut self.registers))
|
||||
}
|
||||
_ => match self.decoder.decode_val(&mut self.registers) {
|
||||
Val::Array(array) => CatStackFrame::from_vec_val(array.elements.clone()),
|
||||
_ => {
|
||||
return Err(
|
||||
"TODO: cat instruction on non-array (usually type error)".to_internal_error(),
|
||||
)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
self.this_target = None;
|
||||
self.return_target = self.decoder.decode_register_index();
|
||||
|
||||
@@ -27,7 +27,7 @@ pub enum CatFrameState {
|
||||
}
|
||||
|
||||
impl CatStackFrame {
|
||||
pub fn from_args(args: Vec<Val>) -> Self {
|
||||
pub fn from_vec_val(args: Vec<Val>) -> Self {
|
||||
Self {
|
||||
state: CatFrameState::ReadNext,
|
||||
iter_result: None,
|
||||
|
||||
Reference in New Issue
Block a user