mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Implement Array/SetWithLength
This commit is contained in:
parent
87bfe836ec
commit
e02def52ab
5 changed files with 55 additions and 7 deletions
|
@ -1700,6 +1700,15 @@ impl CodeGenerator {
|
|||
self.stack_dec_n(len - 1);
|
||||
}
|
||||
}
|
||||
Array::WithLength(arr) => {
|
||||
self.emit_expr(*arr.elem);
|
||||
self.write_instr(BUILD_LIST);
|
||||
self.write_arg(1u8);
|
||||
self.emit_expr(*arr.len);
|
||||
self.write_instr(BINARY_MULTIPLY);
|
||||
self.write_arg(0);
|
||||
self.stack_dec();
|
||||
}
|
||||
other => todo!("{other}"),
|
||||
},
|
||||
// TODO: tuple comprehension
|
||||
|
@ -1733,7 +1742,11 @@ impl CodeGenerator {
|
|||
self.stack_dec_n(len - 1);
|
||||
}
|
||||
}
|
||||
crate::hir::Set::WithLength(_) => todo!(),
|
||||
crate::hir::Set::WithLength(st) => {
|
||||
self.emit_expr(*st.elem);
|
||||
self.write_instr(BUILD_SET);
|
||||
self.write_arg(1u8);
|
||||
}
|
||||
},
|
||||
Expr::Record(rec) => self.emit_record(rec),
|
||||
Expr::Code(code) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue