MCPcopy Index your code
hub / github.com/endbasic/endbasic / compile_integer_exprs

Function compile_integer_exprs

core/src/compiler/exprs.rs:30–46  ·  view source on GitHub ↗

Compiles `exprs` into consecutive integer registers allocated from `scope` and returns the first register. The caller must guarantee that `exprs` is non-empty.

(
    codegen: &mut Codegen,
    symtable: &mut TempSymtable<'_, '_>,
    scope: &mut TempScope,
    pos: LineCol,
    exprs: impl Iterator<Item = Expr>,
)

Source from the content-addressed store, hash-verified

28/// Compiles `exprs` into consecutive integer registers allocated from `scope` and returns the
29/// first register. The caller must guarantee that `exprs` is non-empty.
30pub(super) fn compile_integer_exprs(
31 codegen: &mut Codegen,
32 symtable: &mut TempSymtable<'_, '_>,
33 scope: &mut TempScope,
34 pos: LineCol,
35 exprs: impl Iterator<Item = Expr>,
36) -> Result<Register> {
37 let mut first_reg = None;
38 for expr in exprs {
39 let reg = scope.alloc().map_err(|e| Error::from_syms(e, pos))?;
40 if first_reg.is_none() {
41 first_reg = Some(reg);
42 }
43 compile_expr_as_type(codegen, symtable, reg, expr, ExprType::Integer)?;
44 }
45 Ok(first_reg.expect("Must have at least one expression"))
46}
47
48/// Compiles an array element access expression into `reg`.
49fn compile_array_access(

Callers 2

compile_array_accessFunction · 0.85
compile_stmtFunction · 0.85

Calls 2

compile_expr_as_typeFunction · 0.85
allocMethod · 0.80

Tested by

no test coverage detected