summaryrefslogtreecommitdiff
path: root/tnslc/compile/compbuf.tnsl
diff options
context:
space:
mode:
authorCircleShift <kgunger12@gmail.com>2025-03-05 07:26:58 -0500
committerCircleShift <kgunger12@gmail.com>2025-03-05 07:26:58 -0500
commitd4fe9e6e27f2013a6e1f6be94daba91ec53fa5c3 (patch)
treebc30806a177f62c15e991d9ebcd5d2034a786183 /tnslc/compile/compbuf.tnsl
parent61e1e5ce377719c8e9e437e5ba79ba06fc1de4ba (diff)
[tnslc] Rework compile layout
Diffstat (limited to 'tnslc/compile/compbuf.tnsl')
-rw-r--r--tnslc/compile/compbuf.tnsl45
1 files changed, 45 insertions, 0 deletions
diff --git a/tnslc/compile/compbuf.tnsl b/tnslc/compile/compbuf.tnsl
new file mode 100644
index 0000000..b4ce261
--- /dev/null
+++ b/tnslc/compile/compbuf.tnsl
@@ -0,0 +1,45 @@
+
+struct CompBuf {
+ utils.Vector
+ sec_head,
+ sec_data,
+ sec_code
+}
+
+/; method CompBuf
+ /; init
+ self.sec_head.init(1)
+ self.sec_data.init(1)
+ self.sec_code.init(1)
+ ;/
+
+ /; add_h(~uint8 text)
+ self.sec_head.push_cstr(text)
+ ;/
+
+ /; add_d(~uint8 text)
+ self.sec_data.push_cstr(text)
+ ;/
+
+ /; add_c(~uint8 text)
+ self.sec_code.push_cstr(text)
+ ;/
+
+ /; write_to(~utils.File fout)
+ fout`.write_cstr("BITS 64\0\n")
+ fout`.write_cstr(self.sec_head.as_cstr())
+
+ fout`.write_cstr("\nsection .data\0\n\n")
+ fout`.write_cstr(self.sec_data.as_cstr())
+
+ fout`.write_cstr("\nsection .text\0\n\n")
+ fout`.write_cstr(self.sec_code.as_cstr())
+ ;/
+
+ /; end
+ self.sec_head.end()
+ self.sec_data.end()
+ self.sec_code.end()
+ ;/
+;/
+