Finishes a `{}` dict after the first pair. `pairs` = loose key/val pairs on the stack; `incremental` = a Dict object is already on the stack. On the first `**` the loose pairs are consolidated with `BuildDict pairs`, then merges use `DictUpdate`/`MapAdd`. */
(&mut self, mut pairs: u16, mut incremental: bool)
| 98 | |
| 99 | /* Finishes a `{}` dict after the first pair. `pairs` = loose key/val pairs on the stack; `incremental` = a Dict object is already on the stack. On the first `**` the loose pairs are consolidated with `BuildDict pairs`, then merges use `DictUpdate`/`MapAdd`. */ |
| 100 | fn dict_tail(&mut self, mut pairs: u16, mut incremental: bool) { |
| 101 | while self.eat_if(TokenType::Comma) { |
| 102 | if matches!(self.peek(), Some(TokenType::Rbrace)) { break; } |
| 103 | if self.eat_if(TokenType::DoubleStar) { |
| 104 | if !incremental { self.chunk.emit(OpCode::BuildDict, pairs); incremental = true; } |
| 105 | self.expr(); |
| 106 | self.chunk.emit(OpCode::DictUpdate, 0); |
| 107 | } else { |
| 108 | self.expr(); |
| 109 | self.eat(TokenType::Colon); |
| 110 | self.expr(); |
| 111 | if incremental { self.chunk.emit(OpCode::MapAdd, 0); } else { pairs += 1; } |
| 112 | } |
| 113 | } |
| 114 | self.eat(TokenType::Rbrace); |
| 115 | if !incremental { self.chunk.emit(OpCode::BuildDict, pairs); } |
| 116 | } |
| 117 | |
| 118 | /* Finishes a `{}` set after the first element; mirrors `dict_tail` with `SetUpdate`/`SetAdd` and `BuildSet`. */ |
| 119 | fn set_tail(&mut self, mut count: u16, mut incremental: bool) { |
no test coverage detected