pseudocode splatted dict algo
This commit is contained in:
parent
35d7d3b1c8
commit
4dd4b8ff7e
|
@ -848,6 +848,11 @@ impl<'a> Compiler<'a> {
|
|||
self.match_depth = match_depth + members.len();
|
||||
}
|
||||
DictPattern(pairs) => {
|
||||
// here's an algorithm for dealing with splatted dicts
|
||||
// check len to see it's at least as long as the pattern
|
||||
// then, match against all the values
|
||||
// then push the dict itself as last value
|
||||
// and then emit an opcode and constant/keyword to OMIT that key from the dict
|
||||
self.emit_op(Op::MatchDict);
|
||||
self.emit_byte(pairs.len());
|
||||
let before_load_dict_idx = self.stub_jump(Op::JumpIfNoMatch);
|
||||
|
|
|
@ -75,7 +75,7 @@ pub fn run(src: &'static str) {
|
|||
pub fn main() {
|
||||
env::set_var("RUST_BACKTRACE", "1");
|
||||
let src = "
|
||||
let (...y) = (1, 2)
|
||||
let (...y) = (1, 2, 3, 4, 5)
|
||||
y
|
||||
";
|
||||
run(src);
|
||||
|
|
Loading…
Reference in New Issue
Block a user