@@ -50,6 +50,7 @@ class BackendX86_64 : CompilerBackend {
50
50
uint tempLabelNum;
51
51
bool useGas = false ;
52
52
bool useFramePtr = true ;
53
+ int [string ] fileID;
53
54
54
55
this () {
55
56
output = new Output();
@@ -112,6 +113,21 @@ class BackendX86_64 : CompilerBackend {
112
113
);
113
114
}
114
115
116
+ int GetMaxFileID () {
117
+ int ret = 0 ;
118
+ foreach (key, value ; fileID) {
119
+ if (value > ret) ret = value;
120
+ }
121
+ return ret;
122
+ }
123
+
124
+ int GetOrCreateFileID (string file) {
125
+ if (file ! in fileID) {
126
+ fileID[file] = GetMaxFileID() + 1 ;
127
+ }
128
+ return fileID[file];
129
+ }
130
+
115
131
string TempLabel () {
116
132
++ tempLabelNum;
117
133
return format (" __temp_%d" , tempLabelNum);
@@ -260,6 +276,28 @@ class BackendX86_64 : CompilerBackend {
260
276
}
261
277
}
262
278
279
+ override void BeforeCompile (Node node) {
280
+ static string thisFile;
281
+
282
+ if (useDebug && useGas) {
283
+ if (thisFile != node.error.file) {
284
+ thisFile = node.error.file;
285
+
286
+ if (node.error.file ! in fileID) {
287
+ output ~= format(
288
+ " .file %d \" %s\"\n " , GetOrCreateFileID(node.error.file),
289
+ node.error.file
290
+ );
291
+ }
292
+ }
293
+
294
+ output ~= format(
295
+ " .loc %d %d %d\n " , GetOrCreateFileID(node.error.file),
296
+ node.error.line + 1 , node.error.col + 1
297
+ );
298
+ }
299
+ }
300
+
263
301
override void BeginMain () {
264
302
output ~= " __calmain:\n " ;
265
303
@@ -774,11 +812,6 @@ class BackendX86_64 : CompilerBackend {
774
812
}
775
813
776
814
if (node.inline) {
777
- if (node.errors) {
778
- output ~= format(" lea rax, __global_%s\n " , Sanitise(" _cal_exception" ));
779
- output ~= " mov [rax], 0\n " ;
780
- }
781
-
782
815
words[node.name] = Word(
783
816
WordType.Callisto, true , node.nodes, node.errors, params
784
817
);
0 commit comments