@@ -60,6 +60,15 @@ class BackendRM86 : CompilerBackend {
60
60
foreach (name, ref type ; types) {
61
61
NewConst(format(" %s.sizeof" , name), cast (long ) type.size);
62
62
}
63
+
64
+ // struct Array
65
+ // usize length
66
+ // usize memberSize
67
+ // addr elements
68
+ // end
69
+ NewConst(" Array.length" , 0 );
70
+ NewConst(" Array.memberSize" , 2 );
71
+ NewConst(" Array.elements" , 4 );
63
72
}
64
73
65
74
void NewConst (string name, long value, ErrorInfo error = ErrorInfo.init) {
@@ -120,6 +129,9 @@ class BackendRM86 : CompilerBackend {
120
129
output ~= format(" mov word [si], __global_%s\n " , node.name.Sanitise());
121
130
output ~= " add si, 2\n " ;
122
131
}
132
+ else if (node.name in consts) {
133
+ compiler.CompileNode(consts[node.name].value);
134
+ }
123
135
else {
124
136
Error(node.error, " Undefined identifier '%s'" , node.name);
125
137
}
@@ -142,6 +154,8 @@ class BackendRM86 : CompilerBackend {
142
154
assert (! inScope);
143
155
inScope = true ;
144
156
157
+ words[node.name] = Word(false , []);
158
+
145
159
output ~= format(" jmp __func_end__%s\n " , node.name.Sanitise());
146
160
output ~= format(" __func__%s:\n " , node.name.Sanitise());
147
161
@@ -157,12 +171,10 @@ class BackendRM86 : CompilerBackend {
157
171
}
158
172
output ~= format(" add sp, %d\n " , scopeSize);
159
173
160
- output ~= " ret\n " ;
161
- output ~= format(" __func_end__%s:\n " , node.name.Sanitise());
162
-
163
- words[node.name] = Word(false , []);
164
- variables = [];
165
- inScope = false ;
174
+ output ~= " ret\n " ;
175
+ output ~= format(" __func_end__%s:\n " , node.name.Sanitise());
176
+ variables = [];
177
+ inScope = false ;
166
178
}
167
179
}
168
180
0 commit comments