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

Method list_tail

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

Finishes a `[]` list after the first element; mirrors `dict_tail` with `ListExtend`/`ListAppend` and `BuildList`. */

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

Source from the content-addressed store, hash-verified

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) {
137 while self.eat_if(TokenType::Comma) {
138 if matches!(self.peek(), Some(TokenType::Rsqb)) { break; }
139 if self.eat_if(TokenType::Star) {
140 if !incremental { self.chunk.emit(OpCode::BuildList, count); incremental = true; }
141 self.expr();
142 self.chunk.emit(OpCode::ListExtend, 0);
143 } else {
144 self.expr();
145 if incremental { self.chunk.emit(OpCode::ListAppend, 0); } else { count += 1; }
146 }
147 }
148 self.eat(TokenType::Rsqb);
149 if !incremental { self.chunk.emit(OpCode::BuildList, count); }
150 }
151
152 /* Emits for/if comprehension scaffolding; reinjcts body with loop-bound SSA slots. */
153 pub(super) fn comprehension_loop(&mut self, elem_bodies: &[(usize, Vec<Instruction>)], append_op: OpCode, versions_before: &HashMap<String, u32>) {

Callers 1

list_literalMethod · 0.80

Calls 4

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

Tested by

no test coverage detected