summaryrefslogtreecommitdiff
path: root/tnslc/compile/module.tnsl
blob: 6dbef6cfa628c7f205096702ac6b1f4296d3f49d (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

struct Module {
  # Text name of module
  ~uint8 name,

  # Various contained elements
  utils.Vector
    vars,
    structs,
    funcs,
    subs,

  # Whether we export or not
  bool e
}

/; method Module
  
  /; init (~uint8 name, bool exp)
    Var v
    Struct s
    Function f
    Module m

    self.vars.init(len v)
    self.structs.init(len s)
    self.funcs.init(len f)
    self.subs.init(len m)

    self.name = name
    self.e = exp
  ;/

  /; end
    _delete(self.name)

    ~Var v
    /; loop (int i = 0; i < self.vars.count) [i++]
      v = self.vars.get(i)
      v`.end()
    ;/
    self.vars.end()

    ~Struct s
    /; loop (int i = 0; i < self.structs.count) [i++]
      s = self.structs.get(i)
      s`.end()
    ;/
    self.structs.end()

    ~Function f
    /; loop (int i = 0; i < self.funcs.count) [i++]
      f = self.funcs.get(i)
      f`.end()
    ;/
    self.funcs.end()

    ~Module m
    /; loop (int i = 0; i < self.subs.count) [i++]
      m = self.subs.get(i)
      m`.end()
    ;/
    self.subs.end()

  ;/

;/