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

Function static_end_code

core/src/compiler/top.rs:95–106  ·  view source on GitHub ↗

Returns a statically-known `END` exit code and its source position, if any.

(expr: &Expr)

Source from the content-addressed store, hash-verified

93
94/// Returns a statically-known `END` exit code and its source position, if any.
95fn static_end_code(expr: &Expr) -> Option<(i32, LineCol)> {
96 match expr {
97 Expr::Integer(span) => Some((span.value, span.pos)),
98 Expr::Negate(span) => {
99 let Expr::Integer(inner) = &span.expr else {
100 return None;
101 };
102 inner.value.checked_neg().map(|value| (value, span.pos))
103 }
104 _ => None,
105 }
106}
107
108/// Returns true if `expr` references `target_key`.
109fn expr_references_symbol(expr: &Expr, target_key: &SymbolKey) -> bool {

Callers 1

compile_stmtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected