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

Method compile_block_inner

compiler/src/modules/parser/stmt.rs:315–334  ·  view source on GitHub ↗

Compiles Indent/Dedent block; is_body=true stops after ReturnValue to skip dead code. */

(&mut self, is_body: bool)

Source from the content-addressed store, hash-verified

313
314 /* Compiles Indent/Dedent block; is_body=true stops after ReturnValue to skip dead code. */
315 fn compile_block_inner(&mut self, is_body: bool) {
316 let indented = self.eat_if(TokenType::Indent);
317 loop {
318 while self.eat_if(TokenType::Semi) {}
319 if self.at_end() { break; }
320 if matches!(self.peek(), Some(TokenType::Dedent)) {
321 self.advance();
322 break;
323 }
324 let produced_value = self.stmt();
325 if produced_value {
326 self.chunk.emit(OpCode::PopTop, 0);
327 }
328 if indented { continue; }
329 if is_body {
330 let just_returned = self.chunk.instructions.last().is_some_and(|i| i.opcode == OpCode::ReturnValue);
331 if just_returned || !matches!(self.peek(), Some(TokenType::Semi)) { break; }
332 } else if !matches!(self.peek(), Some(TokenType::Semi)) { break; }
333 }
334 }
335
336 /* Annotation: discard tokens up to `=`; Edge Python is dynamically typed. Returns true when an assignment follows. */
337 fn skip_annotation(&mut self) -> bool {

Callers 2

compile_blockMethod · 0.80
compile_block_bodyMethod · 0.80

Calls 5

eat_ifMethod · 0.80
advanceMethod · 0.80
stmtMethod · 0.80
emitMethod · 0.80
at_endMethod · 0.45

Tested by

no test coverage detected