File: ttypesectioncalls.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (328 lines) | stat: -rw-r--r-- 5,082 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
discard """
nimout: '''
StmtList
  TypeSection
    TypeDef
      Ident "A"
      Empty
      Call
        Ident "call"
        IntLit 1
  TypeSection
    TypeDef
      Ident "B"
      Empty
      Command
        Ident "call"
        IntLit 2
    TypeDef
      Ident "C"
      Empty
      Call
        Ident "call"
        StmtList
          IntLit 3
    TypeDef
      Ident "D"
      Empty
      Call
        Ident "call"
        StmtList
          IntLit 4
  TypeSection
    TypeDef
      Ident "E"
      Empty
      Call
        Ident "call"
        IntLit 5
        IntLit 6
    TypeDef
      Ident "F"
      Empty
      Command
        Ident "call"
        IntLit 7
        IntLit 8
    TypeDef
      Ident "G"
      Empty
      Call
        Ident "call"
        IntLit 9
        StmtList
          IntLit 10
    TypeDef
      Ident "H"
      Empty
      Call
        Ident "call"
        IntLit 11
        StmtList
          IntLit 12
    TypeDef
      Ident "I"
      Empty
      Command
        Ident "call"
        IntLit 13
        StmtList
          IntLit 14
    TypeDef
      Ident "J"
      Empty
      Command
        Ident "call"
        IntLit 15
        StmtList
          IntLit 16
  TypeSection
    TypeDef
      Ident "K"
      Empty
      Call
        Ident "call"
        IntLit 17
        IntLit 18
        IntLit 19
    TypeDef
      Ident "L"
      Empty
      Command
        Ident "call"
        IntLit 20
        IntLit 21
        IntLit 22
    TypeDef
      Ident "M"
      Empty
      Call
        Ident "call"
        IntLit 23
        IntLit 24
        StmtList
          IntLit 25
    TypeDef
      Ident "N"
      Empty
      Command
        Ident "call"
        IntLit 26
        IntLit 27
        StmtList
          IntLit 28
    TypeDef
      Ident "O"
      Empty
      Command
        Ident "call"
        IntLit 29
        IntLit 30
        StmtList
          IntLit 31
  TypeSection
    TypeDef
      Ident "P"
      Empty
      Command
        Ident "call"
        TupleConstr
          IntLit 32
          IntLit 33
        Infix
          Ident "+"
          Infix
            Ident "*"
            IntLit 34
            IntLit 35
          IntLit 36
        StmtList
          IntLit 37
    TypeDef
      Ident "R"
      Empty
      Command
        Ident "call"
        Infix
          Ident "@"
          TupleConstr
            IntLit 38
            IntLit 39
          Infix
            Ident "shl"
            IntLit 40
            IntLit 41
        Infix
          Ident "-"
          Infix
            Ident "*"
            IntLit 42
            IntLit 43
          IntLit 44
        StmtList
          IntLit 45
    TypeDef
      Ident "S"
      Empty
      Command
        Ident "call"
        IntLit 46
        StmtList
          IntLit 47
        StmtList
          IntLit 48
    TypeDef
      Ident "T"
      Empty
      Call
        Ident "call"
        StmtList
          IntLit 49
        StmtList
          IntLit 50
        StmtList
          IntLit 51
a: IntLit 1
a: IntLit 2
a: StmtList
  IntLit 3
a: StmtList
  IntLit 4
a: IntLit 5
b: IntLit 6
a: IntLit 7
b: IntLit 8
a: IntLit 9
b: StmtList
  IntLit 10
a: IntLit 11
b: StmtList
  IntLit 12
a: IntLit 13
b: StmtList
  IntLit 14
a: IntLit 15
b: StmtList
  IntLit 16
a: IntLit 17
b: IntLit 18
c: IntLit 19
a: IntLit 20
b: IntLit 21
c: IntLit 22
a: IntLit 23
b: IntLit 24
c: StmtList
  IntLit 25
a: IntLit 26
b: IntLit 27
c: StmtList
  IntLit 28
a: IntLit 29
b: IntLit 30
c: StmtList
  IntLit 31
a: TupleConstr
  IntLit 32
  IntLit 33
b: Infix
  Ident "+"
  Infix
    Ident "*"
    IntLit 34
    IntLit 35
  IntLit 36
c: StmtList
  IntLit 37
a: Infix
  Ident "@"
  TupleConstr
    IntLit 38
    IntLit 39
  Infix
    Ident "shl"
    IntLit 40
    IntLit 41
b: Infix
  Ident "-"
  Infix
    Ident "*"
    IntLit 42
    IntLit 43
  IntLit 44
c: StmtList
  IntLit 45
a: IntLit 46
b: StmtList
  IntLit 47
c: StmtList
  IntLit 48
a: StmtList
  IntLit 49
b: StmtList
  IntLit 50
c: StmtList
  IntLit 51
'''
"""
import macros

macro call(a): untyped =
  echo "a: ", a.treeRepr
  result = ident"int"
macro call(a, b): untyped =
  echo "a: ", a.treeRepr
  echo "b: ", b.treeRepr
  result = ident"int"
macro call(a, b, c): untyped =
  echo "a: ", a.treeRepr
  echo "b: ", b.treeRepr
  echo "c: ", c.treeRepr
  result = ident"int"

macro sections(x): untyped =
  echo x.treeRepr
  result = newStmtList(x)
  for ts in x:
    for td in ts:
      let t = td[0]
      result.add quote do:
        doAssert `t` is int

sections:
  type A = call(1)
  type
    B = call 2
    C = call: 3
    D = call(): 4
  type
    E = call(5, 6)
    F = call 7, 8
    G = call(9): 10
    H = call(11):
      12
    I = call 13: 14
    J = call 15:
      16
  type
    K = call(17, 18, 19)
    L = call 20, 21, 22
    M = call(23, 24): 25
    N = call 26, 27: 28
    O = call 29, 30:
      31
  type
    P = call (32, 33), 34 * 35 + 36:
      37
    R = call (38, 39) @ 40 shl 41, 42 * 43 - 44:
      45
    S = call 46:
      47
    do:
      48
    T = call:
      49
    do:
      50
    do:
      51