diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2025-11-30 03:52:24 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2025-11-30 03:52:24 -0500 |
| commit | 46e23fa81f651961b2388c95e9569d2d39c3cffb (patch) | |
| tree | f4b8fa1704b930ce8f2397d5d5b1bfc180284642 /tnslc/compile/codegen.tnsl | |
| parent | 51854e5db46033712b5dbbf78d769ea500eca14f (diff) | |
Start work on backend
Diffstat (limited to 'tnslc/compile/codegen.tnsl')
| -rw-r--r-- | tnslc/compile/codegen.tnsl | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/tnslc/compile/codegen.tnsl b/tnslc/compile/codegen.tnsl index ccb6b06..48545f3 100644 --- a/tnslc/compile/codegen.tnsl +++ b/tnslc/compile/codegen.tnsl @@ -10,21 +10,76 @@ buffer.init() # Transform into a module tree - # Module mod - # mod.init(~ast) - # mod.update_children() + Module mod + mod.init(~ast, ~buffer) + mod.update_children() # Compile code - # mod.compile(~buffer) + _gen_prims(~mod) + mod.compile(~buffer) # Write assembly to output file - # fout.create() - # buffer.write_to(fout) - # fout.close() + fout.create() + buffer.write_to(fout) + fout.close() # Free all structs - # mod.end() + mod.end() buffer.end() ast.end() ;/ +/; _gen_prims (~Module m) + Var t + + Struct s + s.members.init(len t) + s.methods = NULL + s._up = NULL + + ~uint8 str + + # One byte prims + s.size = 1 + s.name = utils.strcpy("bool\0") + m`.structs.push(~s) + s.name = utils.strcpy("uint8\0") + m`.structs.push(~s) + s.name = utils.strcpy("int8\0") + m`.structs.push(~s) + + # Two byte prims + s.size = 2 + s.name = utils.strcpy("uint16\0") + m`.structs.push(~s) + s.name = utils.strcpy("int16\0") + m`.structs.push(~s) + + # Four byte prims + s.size = 4 + s.name = utils.strcpy("uint32\0") + m`.structs.push(~s) + s.name = utils.strcpy("int32\0") + m`.structs.push(~s) + s.name = utils.strcpy("float32\0") + m`.structs.push(~s) + + # Eight byte prims + s.size = 8 + s.name = utils.strcpy("uint64\0") + m`.structs.push(~s) + s.name = utils.strcpy("int64\0") + m`.structs.push(~s) + s.name = utils.strcpy("float64\0") + m`.structs.push(~s) + s.name = utils.strcpy("uint\0") + m`.structs.push(~s) + s.name = utils.strcpy("int\0") + m`.structs.push(~s) + s.name = utils.strcpy("float\0") + m`.structs.push(~s) + s.name = utils.strcpy("void\0") + m`.structs.push(~s) + +;/ + |