about summary refs log tree commit diff stats
path: root/linux/braces.subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-14 22:36:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-14 22:36:38 -0700
commit7bad89bdf93ca36c80be5dcb6799c6e46d23b7d1 (patch)
tree60e91ea2002c125dcc1a15f094bd51591e3800a7 /linux/braces.subx
parent56c9248109e0bd56d4e7913bef78231ab8112c85 (diff)
downloadmu-7bad89bdf93ca36c80be5dcb6799c6e46d23b7d1.tar.gz
free up '_' for top-level SubX functions
Diffstat (limited to 'linux/braces.subx')
-rw-r--r--linux/braces.subx80
1 files changed, 40 insertions, 40 deletions
diff --git a/linux/braces.subx b/linux/braces.subx
index 57853985..e09229a9 100644
--- a/linux/braces.subx
+++ b/linux/braces.subx
@@ -11,10 +11,10 @@
 #     74/jump-if-= loop/disp8
 #   }
 #   $ cat x.subx |braces
-#   _loop1:
-#     7c/jump-if-< _break1/disp8
-#     74/jump-if-= _loop1/disp8
-#   _break1:
+#   @loop1:
+#     7c/jump-if-< @break1/disp8
+#     74/jump-if-= @loop1/disp8
+#   @break1:
 #
 # Example 2:
 #   $ cat x.subx
@@ -25,12 +25,12 @@
 #     74/jump-if-= loop/disp8
 #   }
 #   $ cat x.subx |braces
-#   _loop1:
-#     7c/jump-if-< _break1/disp8
-#   _break1:
-#   _loop2:
-#     74/jump-if-= _loop2/disp8
-#   _break2:
+#   @loop1:
+#     7c/jump-if-< @break1/disp8
+#   @break1:
+#   @loop2:
+#     74/jump-if-= @loop2/disp8
+#   @break2:
 #
 # Example 3:
 #   $ cat x.subx
@@ -41,12 +41,12 @@
 #     7c/jump-if-< loop/disp8
 #   }
 #   $ cat x.subx |braces
-#   _loop1:
-#     _loop2:
-#       74/jump-if-= _loop2/disp8
-#     _break2:
-#     7c/jump-if-< _loop1/disp8
-#   _break1:
+#   @loop1:
+#     @loop2:
+#       74/jump-if-= @loop2/disp8
+#     @break2:
+#     7c/jump-if-< @loop1/disp8
+#   @break1:
 
 == code
 
@@ -85,13 +85,13 @@ subx-braces:  # in: (addr buffered-file), out: (addr buffered-file)
     #     if (line->write == 0) break                           # end of file
     #     skip-chars-matching-whitespace(line)
     #     if line->data[line->read] == '{'
-    #       print(out, "_loop" next-label-id ":\n")
+    #       print(out, "@loop" next-label-id ":\n")
     #       push(label-stack, next-label-id)
     #       ++next-label-id
     #       continue
     #     if line->data[line->read] == '}'
     #       var top = pop(label-stack)
-    #       print(out, "_break" top ":\n")
+    #       print(out, "@break" top ":\n")
     #       continue
     #     while true
     #       var word-slice: (addr slice) = next-word-or-string(line)
@@ -101,11 +101,11 @@ subx-braces:  # in: (addr buffered-file), out: (addr buffered-file)
     #         continue
     #       if slice-starts-with?(word-slice, "break/")
     #         var top = top(label-stack)
-    #         print(out, "_break" top)
+    #         print(out, "@break" top)
     #         word-slice->start += len("break")
     #       else if slice-starts-with?(word-slice, "loop/")
     #         var top = top(label-stack)
-    #         print(out, "_loop" top)
+    #         print(out, "@loop" top)
     #         word-slice->start += len("loop")
     #       print(out, word-slice " ")
     #     print(out, "\n")
@@ -157,8 +157,8 @@ $subx-braces:check-for-curly-open:
     3d/compare-eax-and 0x7b/imm32/open-curly
     0f 85/jump-if-!= $subx-braces:check-for-curly-closed/disp32
 $subx-braces:emit-curly-open:
-    # print(out, "_loop" next-label-id ":")
-    (write-buffered *(ebp+0xc) "_loop")
+    # print(out, "@loop" next-label-id ":")
+    (write-buffered *(ebp+0xc) "@loop")
     (write-int32-hex-buffered *(ebp+0xc) %ebx)
     (write-buffered *(ebp+0xc) ":")
     # push(label-stack, next-label-id)
@@ -174,8 +174,8 @@ $subx-braces:check-for-curly-closed:
 $subx-braces:emit-curly-closed:
     # eax = pop(label-stack)
     (pop %edx)
-    # print(out, "_break" eax ":")
-    (write-buffered *(ebp+0xc) "_break")
+    # print(out, "@break" eax ":")
+    (write-buffered *(ebp+0xc) "@break")
     (write-int32-hex-buffered *(ebp+0xc) %eax)
     (write-buffered *(ebp+0xc) ":")
     # continue
@@ -205,8 +205,8 @@ $subx-braces:check-for-break:
     74/jump-if-= $subx-braces:check-for-loop/disp8
 $subx-braces:emit-break:
     (top %edx)
-    # print(out, "_break" eax)
-    (write-buffered *(ebp+0xc) "_break")
+    # print(out, "@break" eax)
+    (write-buffered *(ebp+0xc) "@break")
     (write-int32-hex-buffered *(ebp+0xc) %eax)
     # word-slice->start += len("break")
     81 0/subop/add *edi 5/imm32/strlen
@@ -221,8 +221,8 @@ $subx-braces:check-for-loop:
     74/jump-if-= $subx-braces:emit-word-slice/disp8
 $subx-braces:emit-loop:
     (top %edx)
-    # print(out, "_loop" eax)
-    (write-buffered *(ebp+0xc) "_loop")
+    # print(out, "@loop" eax)
+    (write-buffered *(ebp+0xc) "@loop")
     (write-int32-hex-buffered *(ebp+0xc) %eax)
     # word-slice->start += len("loop")
     81 0/subop/add *edi 4/imm32/strlen
@@ -288,10 +288,10 @@ test-subx-braces-1:
     #   }
     #
     # output:
-    #   _loop1:
-    #   ab _break1/imm32
-    #   cd _loop1/imm32
-    #   _break1:
+    #   @loop1:
+    #   ab @break1/imm32
+    #   cd @loop1/imm32
+    #   @break1:
     #
     # . prologue
     55/push-ebp
@@ -311,7 +311,7 @@ test-subx-braces-1:
 #?     (write-stream 2 _test-output-stream)
 #?     (write 2 "$\n")
 #?     # }}}
-    (check-stream-equal _test-output-stream "_loop0x00000001:\nab _break0x00000001/imm32 \ncd _loop0x00000001/imm32 \n_break0x00000001:\n" "F - test-subx-braces-1")
+    (check-stream-equal _test-output-stream "@loop0x00000001:\nab @break0x00000001/imm32 \ncd @loop0x00000001/imm32 \n@break0x00000001:\n" "F - test-subx-braces-1")
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp
@@ -327,12 +327,12 @@ test-subx-braces-2:
     #   }
     #
     # output:
-    #   _loop1:
-    #   _loop2:
-    #   ab _break2/imm32
-    #   _break2:
-    #   cd _loop1/imm32
-    #   _break1:
+    #   @loop1:
+    #   @loop2:
+    #   ab @break2/imm32
+    #   @break2:
+    #   cd @loop1/imm32
+    #   @break1:
     #
     # . prologue
     55/push-ebp
@@ -352,7 +352,7 @@ test-subx-braces-2:
 #?     (write-stream 2 _test-output-stream)
 #?     (write 2 "$\n")
 #?     # }}}
-    (check-stream-equal _test-output-stream "_loop0x00000001:\n_loop0x00000002:\nab _break0x00000002/imm32 \n_break0x00000002:\ncd _loop0x00000001/imm32 \n_break0x00000001:\n" "F - test-subx-braces-2")
+    (check-stream-equal _test-output-stream "@loop0x00000001:\n@loop0x00000002:\nab @break0x00000002/imm32 \n@break0x00000002:\ncd @loop0x00000001/imm32 \n@break0x00000001:\n" "F - test-subx-braces-2")
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp
2019-08-26 11:59:21 -0700 5592 - switch register names to lowercase' href='/akkartik/mu/commit/059stop.subx?h=hlt&id=333525360b22f3d3ea31db46a4d2f1b4edbfebdb'>33352536 ^
9d27e966 ^
33352536 ^

6030d7e2 ^

33352536 ^



6030d7e2 ^
33352536 ^
261b1b80 ^
33352536 ^

261b1b80 ^
33352536 ^




6030d7e2 ^
33352536 ^
cf02c20b ^
ee9a9237 ^
33352536 ^

7a583220 ^
33352536 ^

6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

80f53f4a ^


1639687b ^
33352536 ^
80f53f4a ^
261b1b80 ^
6030d7e2 ^
33352536 ^


1639687b ^
33352536 ^
80f53f4a ^



13ef4258 ^
80f53f4a ^



6030d7e2 ^
f3612481 ^

7a583220 ^
33352536 ^
6030d7e2 ^
33352536 ^
6030d7e2 ^
33352536 ^


6030d7e2 ^


71eb22a5 ^
64e8faba ^

33352536 ^
6030d7e2 ^

ee9a9237 ^
6030d7e2 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
9d27e966 ^
ee9a9237 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
33352536 ^
93be389b ^
33352536 ^
6030d7e2 ^
328a8e11 ^
ee9a9237 ^
6030d7e2 ^

9d27e966 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
7a583220 ^
33352536 ^


6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

6030d7e2 ^
ee9a9237 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
cf02c20b ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
7a583220 ^
33352536 ^

6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

9d27e966 ^
ee9a9237 ^
6030d7e2 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
cf02c20b ^
7a583220 ^
33352536 ^

6030d7e2 ^
6ee77ba7 ^
ee9a9237 ^
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