MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / set_tail

Method set_tail

compiler/src/modules/parser/literals.rs:119–133  ·  view source on GitHub ↗

Finishes a `{}` set after the first element; mirrors `dict_tail` with `SetUpdate`/`SetAdd` and `BuildSet`. */

(&mut self, mut count: u16, mut incremental: bool)

Source from the content-addressed store, hash-verified

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) {
120 while self.eat_if(TokenType::Comma) {
121 if matches!(self.peek(), Some(TokenType::Rbrace)) { break; }
122 if self.eat_if(TokenType::Star) {
123 if !incremental { self.chunk.emit(OpCode::BuildSet, count); incremental = true; }
124 self.expr();
125 self.chunk.emit(OpCode::SetUpdate, 0);
126 } else {
127 self.expr();
128 if incremental { self.chunk.emit(OpCode::SetAdd, 0); } else { count += 1; }
129 }
130 }
131 self.eat(TokenType::Rbrace);
132 if !incremental { self.chunk.emit(OpCode::BuildSet, count); }
133 }
134
135 /* Finishes a `[]` list after the first element; mirrors `dict_tail` with `ListExtend`/`ListAppend` and `BuildList`. */
136 fn list_tail(&mut self, mut count: u16, mut incremental: bool) {

Callers 1

brace_literalMethod · 0.80

Calls 4

eat_ifMethod · 0.80
emitMethod · 0.80
exprMethod · 0.80
eatMethod · 0.80

Tested by

no test coverage detected