summaryrefslogtreecommitdiff
path: root/tnslc/compile/compbuf.tnsl
blob: b4ce2614c054c31a1e3ddc4b2deec2eb553f1954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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()
  ;/
;/