From 0587f854d80a9ad95c459b45509fcda7926cde20 Mon Sep 17 00:00:00 2001 From: CircleShift Date: Tue, 9 Dec 2025 02:25:30 -0500 Subject: begin on the actual codegen --- tnslc/compile/function.tnsl | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tnslc/compile/function.tnsl') diff --git a/tnslc/compile/function.tnsl b/tnslc/compile/function.tnsl index d55579e..eec65ed 100644 --- a/tnslc/compile/function.tnsl +++ b/tnslc/compile/function.tnsl @@ -161,7 +161,35 @@ struct Function { self._end_func(~fscope, cb) ;/ - /; _compile_statements(~Scope s, int off) + # + # Compiling individual statements + # + + /; _compile_statements (~Scope s, int off) + ~parse.Node _up = self._up + ~parse.Node n = NULL + /; loop (off < _up`.sub.count) [off++] + n = _up`.sub.get(off) + /; if (n`._type == parse.NTYPE_FLOW_CONTROL) + self._compile_flow_control(s, n) + ;; else if (n`._type == parse.NTYPE_ASM) + s`.cb`.add_c(" \0") + s`.cb`.add_c(n`.data) + s`.cb`.add_c(" ; User defined asm\n\0") + ;/ + ;/ + ;/ + + # Should handle break, continue, and return + /; _compile_flow_control (~Scope s, ~parse.Node n) + /; if (utils.strcmp(n`.data, "return\0") == true) + # Compute value and return + self._compile_value(s, n) + ;/ + ;/ + + # Should handle computing a value, delegate to other funcs when needed + /; _compile_value (~Scope s, ~parse.Node n) ;/ /; _print (int idt) -- cgit v1.2.3