Skip to content

Commit b693627

Browse files
committed
fix constructors/destructors + 0.12.2
1 parent c07534a commit b693627

File tree

7 files changed

+67
-55
lines changed

7 files changed

+67
-55
lines changed

source/app.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import callisto.backends.rm86;
1818
import callisto.backends.arm64;
1919
import callisto.backends.x86_64;
2020

21-
const static string appVersion = "Beta 0.12.1";
21+
const static string appVersion = "Beta 0.12.2";
2222

2323
const static string usage = "
2424
Callisto Compiler

source/backends/arm64.d

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class BackendARM64 : CompilerBackend {
217217

218218
// call constructors
219219
foreach (global ; globals) {
220-
if (global.type.hasInit) {
220+
if (global.type.hasInit && !global.type.ptr) {
221221
LoadAddress("x9", format("__global_%s", global.name.Sanitise()));
222222
output ~= "str x9, [x19], #8\n";
223223
output ~= format("bl __type_init_%s\n", global.type.name.Sanitise());
@@ -291,7 +291,7 @@ class BackendARM64 : CompilerBackend {
291291
override void End() {
292292
// call destructors
293293
foreach (global ; globals) {
294-
if (global.type.hasDeinit) {
294+
if (global.type.hasDeinit && !global.type.ptr) {
295295
LoadAddress("x9", format("__global_%s", global.name.Sanitise()));
296296
output ~= "str x9, [x19], #8\n";
297297
output ~= format("bl __type_deinit_%s\n", global.type.name.Sanitise());
@@ -705,7 +705,7 @@ class BackendARM64 : CompilerBackend {
705705
foreach (ref var ; variables) {
706706
scopeSize += var.Size();
707707

708-
if (var.type.hasDeinit) {
708+
if (var.type.hasDeinit && !var.type.ptr) {
709709
output ~= format("add x9, x20, #%d\n", var.offset);
710710
output ~= "str x9, [x19], #8\n";
711711
output ~= format("bl __type_deinit_%s\n", var.type.name.Sanitise());
@@ -746,7 +746,7 @@ class BackendARM64 : CompilerBackend {
746746
// remove scope
747747
foreach (ref var ; variables) {
748748
if (oldVars.canFind(var)) continue;
749-
if (!var.type.hasDeinit) continue;
749+
if (!var.type.hasDeinit || var.type.ptr) continue;
750750

751751
output ~= format("add x9, x20, #%d\n", var.offset);
752752
output ~= "str x9, [x19], #8\n";
@@ -775,7 +775,7 @@ class BackendARM64 : CompilerBackend {
775775
// remove scope
776776
foreach (ref var ; variables) {
777777
if (oldVars.canFind(var)) continue;
778-
if (!var.type.hasDeinit) continue;
778+
if (!var.type.hasDeinit || var.type.ptr) continue;
779779

780780
output ~= format("add x9, x20, #%d\n", var.offset);
781781
output ~= "str x9, [x19], #8\n";
@@ -813,7 +813,7 @@ class BackendARM64 : CompilerBackend {
813813
output ~= format("__while_%d_next:\n", blockNum);
814814
foreach (ref var ; variables) {
815815
if (oldVars.canFind(var)) continue;
816-
if (!var.type.hasDeinit) continue;
816+
if (!var.type.hasDeinit || var.type.ptr) continue;
817817

818818
output ~= format("add x9, x20, #%d\n", var.offset);
819819
output ~= "str x9, [x19], #8\n";
@@ -993,7 +993,7 @@ class BackendARM64 : CompilerBackend {
993993
foreach (ref var ; variables) {
994994
scopeSize += var.Size();
995995

996-
if (var.type.hasDeinit) {
996+
if (var.type.hasDeinit && !var.type.ptr) {
997997
output ~= format("add x9, x20, #%d\n", var.offset);
998998
output ~= "str x9, [x19], #8\n";
999999
output ~= format("bl __type_deinit_%s\n", var.type.name.Sanitise());
@@ -1166,7 +1166,7 @@ class BackendARM64 : CompilerBackend {
11661166
foreach (ref var ; variables) {
11671167
scopeSize += var.Size();
11681168

1169-
if (var.type.hasDeinit) {
1169+
if (var.type.hasDeinit && !var.type.ptr) {
11701170
output ~= format("add x9, x20, #%d\n", var.offset);
11711171
output ~= "str x9, [x19], #8\n";
11721172
output ~= format("bl __type_deinit_%s\n", var.type.name.Sanitise());
@@ -1334,7 +1334,7 @@ class BackendARM64 : CompilerBackend {
13341334
// remove scope
13351335
foreach (ref var ; variables) {
13361336
if (oldVars.canFind(var)) continue;
1337-
if (!var.type.hasDeinit) continue;
1337+
if (!var.type.hasDeinit || var.type.ptr) continue;
13381338

13391339
output ~= format("add x9, x20, #%d\n", var.offset);
13401340
output ~= "str x9, [x19], #8\n";

source/backends/lua.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class BackendLua : CompilerBackend {
122122
override void End() {
123123
// call destructors
124124
foreach (name, global ; globals) {
125-
if (!global.type.hasDeinit) continue;
125+
if (!global.type.hasDeinit && global.type.ptr) continue;
126126
auto globalExtra = cast(GlobalExtra*) global.extra;
127127

128128
output ~= format("mem[dsp] = %d\n", globalExtra.addr);
@@ -389,7 +389,7 @@ class BackendLua : CompilerBackend {
389389
foreach (ref var ; variables) {
390390
scopeSize += var.Size();
391391

392-
if (var.type.hasDeinit) {
392+
if (var.type.hasDeinit && !var.type.ptr) {
393393
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
394394
output ~= "dsp = dsp + 1\n";
395395
output ~= format("type_deinit_%s()\n", var.type.name.Sanitise());
@@ -428,7 +428,7 @@ class BackendLua : CompilerBackend {
428428
// remove scope
429429
foreach (ref var ; variables) {
430430
if (oldVars.canFind(var)) continue;
431-
if (!var.type.hasDeinit) continue;
431+
if (!var.type.hasDeinit || var.type.ptr) continue;
432432

433433
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
434434
output ~= "dsp = dsp + 1\n";
@@ -457,7 +457,7 @@ class BackendLua : CompilerBackend {
457457
// remove scope
458458
foreach (ref var ; variables) {
459459
if (oldVars.canFind(var)) continue;
460-
if (!var.type.hasDeinit) continue;
460+
if (!var.type.hasDeinit || var.type.ptr) continue;
461461

462462
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
463463
output ~= "dsp = dsp + 1\n";
@@ -495,7 +495,7 @@ class BackendLua : CompilerBackend {
495495
output ~= format("::while_%d_next::\n", blockNum);
496496
foreach (ref var ; variables) {
497497
if (oldVars.canFind(var)) continue;
498-
if (!var.type.hasDeinit) continue;
498+
if (!var.type.hasDeinit || var.type.ptr) continue;
499499

500500
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
501501
output ~= "dsp = dsp + 1\n";
@@ -551,7 +551,7 @@ class BackendLua : CompilerBackend {
551551
output ~= "mem[vsp] = 0\n";
552552
}
553553

554-
if (var.type.hasInit) { // call constructor
554+
if (var.type.hasInit && !var.type.ptr) { // call constructor
555555
output ~= "mem[dsp] = vsp\n";
556556
output ~= "dsp = dsp + 1\n";
557557
output ~= format("type_init_%s()\n", var.type.name.Sanitise());
@@ -576,7 +576,7 @@ class BackendLua : CompilerBackend {
576576

577577
globalStack += global.Size();
578578

579-
if (global.type.hasInit) { // call constructor
579+
if (global.type.hasInit && !global.type.ptr) { // call constructor
580580
output ~= format("mem[dsp] = %d\n", extra.addr);
581581
output ~= "dsp = dsp + 1\n";
582582
output ~= format("type_init_%s()\n", global.type.name.Sanitise());
@@ -700,7 +700,7 @@ class BackendLua : CompilerBackend {
700700
foreach (ref var ; variables) {
701701
scopeSize += var.Size();
702702

703-
if (var.type.hasDeinit) {
703+
if (var.type.hasDeinit && !var.type.ptr) {
704704
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
705705
output ~= "dsp = dsp + 1\n";
706706
output ~= format("type_deinit_%s()\n", var.type.name.Sanitise());
@@ -831,7 +831,7 @@ class BackendLua : CompilerBackend {
831831
foreach (ref var ; variables) {
832832
scopeSize += var.Size();
833833

834-
if (var.type.hasDeinit) {
834+
if (var.type.hasDeinit && !var.type.ptr) {
835835
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
836836
output ~= "dsp = dsp + 1\n";
837837
output ~= format("type_deinit_%s()\n", var.type.name.Sanitise());
@@ -981,7 +981,7 @@ class BackendLua : CompilerBackend {
981981
// remove scope
982982
foreach (ref var ; variables) {
983983
if (oldVars.canFind(var)) continue;
984-
if (!var.type.hasDeinit) continue;
984+
if (!var.type.hasDeinit || var.type.ptr) continue;
985985

986986
output ~= format("mem[dsp] = vsp + %d\n", var.offset);
987987
output ~= "dsp = dsp + 1\n";

source/backends/rm86.d

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BackendRM86 : CompilerBackend {
111111
// call globals
112112
// what?
113113
foreach (global ; globals) {
114-
if (global.type.hasInit) {
114+
if (global.type.hasInit && !global.type.ptr) {
115115
output ~= format(
116116
"mov word [si], word __global_%s\n", global.name.Sanitise()
117117
);
@@ -162,7 +162,7 @@ class BackendRM86 : CompilerBackend {
162162

163163
override void End() {
164164
foreach (global ; globals) {
165-
if (global.type.hasDeinit) {
165+
if (global.type.hasDeinit && !global.type.ptr) {
166166
output ~= format("mov word [si], word __global_%s\n", Sanitise(global.name));
167167
output ~= "add si, 2\n";
168168
output ~= format("call __type_deinit_%s\n", Sanitise(global.type.name));
@@ -492,7 +492,7 @@ class BackendRM86 : CompilerBackend {
492492
foreach (ref var ; variables) {
493493
scopeSize += var.Size();
494494

495-
if (var.type.hasDeinit) {
495+
if (var.type.hasDeinit && !var.type.ptr) {
496496
output ~= format("lea ax, [sp + %d\n]", var.offset);
497497
output ~= "mov [si], ax\n";
498498
output ~= "add si, 2\n";
@@ -538,7 +538,7 @@ class BackendRM86 : CompilerBackend {
538538
// remove scope
539539
foreach (ref var ; variables) {
540540
if (oldVars.canFind(var)) continue;
541-
if (!var.type.hasDeinit) continue;
541+
if (!var.type.hasDeinit || var.type.ptr) continue;
542542

543543
output ~= format("lea ax, [sp + %d\n]", var.offset);
544544
output ~= "mov [si], ax\n";
@@ -568,7 +568,7 @@ class BackendRM86 : CompilerBackend {
568568
// remove scope
569569
foreach (ref var ; variables) {
570570
if (oldVars.canFind(var)) continue;
571-
if (!var.type.hasDeinit) continue;
571+
if (!var.type.hasDeinit || var.type.ptr) continue;
572572

573573
output ~= format("lea ax, [sp + %d\n]", var.offset);
574574
output ~= "mov [si], ax\n";
@@ -607,7 +607,7 @@ class BackendRM86 : CompilerBackend {
607607
output ~= format("__while_%d_next:\n", blockNum);
608608
foreach (ref var ; variables) {
609609
if (oldVars.canFind(var)) continue;
610-
if (!var.type.hasDeinit) continue;
610+
if (!var.type.hasDeinit || var.type.ptr) continue;
611611

612612
output ~= format("lea ax, [sp + %d\n]", var.offset);
613613
output ~= "mov [si], ax\n";
@@ -666,7 +666,7 @@ class BackendRM86 : CompilerBackend {
666666
output ~= format("sub sp, %d\n", var.Size());
667667
}
668668

669-
if (var.type.hasInit) { // call constructor
669+
if (var.type.hasInit && !var.type.ptr) { // call constructor
670670
output ~= "mov [si], sp\n";
671671
output ~= "add si, 2\n";
672672
output ~= format("call __type_init_%s\n", Sanitise(var.type.name));
@@ -793,7 +793,7 @@ class BackendRM86 : CompilerBackend {
793793
foreach (ref var ; variables) {
794794
scopeSize += var.Size();
795795

796-
if (var.type.hasDeinit) {
796+
if (var.type.hasDeinit && !var.type.ptr) {
797797
output ~= format("lea ax, [sp + %d\n]", var.offset);
798798
output ~= "mov [si], ax\n";
799799
output ~= "add si, 2\n";
@@ -1118,7 +1118,7 @@ class BackendRM86 : CompilerBackend {
11181118
// remove scope
11191119
foreach (ref var ; variables) {
11201120
if (oldVars.canFind(var)) continue;
1121-
if (!var.type.hasDeinit) continue;
1121+
if (!var.type.hasDeinit || var.type.ptr) continue;
11221122

11231123
output ~= format("lea ax, [sp + %d\n]", var.offset);
11241124
output ~= "mov [si], ax\n";

source/backends/uxn.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class BackendUXN : CompilerBackend {
9898
output ~= "@calmain\n";
9999

100100
foreach (global ; globals) {
101-
if (global.type.hasInit) {
101+
if (global.type.hasInit && !global.type.ptr) {
102102
output ~= format(";global_%s\n", global.name.Sanitise());
103103
output ~= format("type_init_%s\n", global.type.name.Sanitise());
104104
}
@@ -135,7 +135,7 @@ class BackendUXN : CompilerBackend {
135135
override void End() {
136136
// call destructors
137137
foreach (global ; globals) {
138-
if (global.type.hasDeinit) {
138+
if (global.type.hasDeinit && !global.type.ptr) {
139139
output ~= format(";global_%s\n", global.name.Sanitise());
140140
output ~= format("type_deinit_%s\n", global.type.name.Sanitise());
141141
}
@@ -449,7 +449,7 @@ class BackendUXN : CompilerBackend {
449449
foreach (ref var ; variables) {
450450
scopeSize += var.Size();
451451

452-
if (var.type.hasDeinit) {
452+
if (var.type.hasDeinit && !var.type.ptr) {
453453
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
454454
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
455455
}
@@ -496,7 +496,7 @@ class BackendUXN : CompilerBackend {
496496
// remove scope
497497
foreach (ref var ; variables) {
498498
if (oldVars.canFind(var)) continue;
499-
if (!var.type.hasDeinit) continue;
499+
if (!var.type.hasDeinit || var.type.ptr) continue;
500500

501501
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
502502
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
@@ -526,7 +526,7 @@ class BackendUXN : CompilerBackend {
526526
// remove scope
527527
foreach (ref var ; variables) {
528528
if (oldVars.canFind(var)) continue;
529-
if (!var.type.hasDeinit) continue;
529+
if (!var.type.hasDeinit || var.type.ptr) continue;
530530

531531
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
532532
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
@@ -565,7 +565,7 @@ class BackendUXN : CompilerBackend {
565565
output ~= format("@while_%d_next\n", blockNum);
566566
foreach (ref var ; variables) {
567567
if (oldVars.canFind(var)) continue;
568-
if (!var.type.hasDeinit) continue;
568+
if (!var.type.hasDeinit || var.type.ptr) continue;
569569

570570
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
571571
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
@@ -624,7 +624,7 @@ class BackendUXN : CompilerBackend {
624624
output ~= format("#0000 .vsp LDZ2 STA2\n");
625625
}
626626

627-
if (var.type.hasInit) {
627+
if (var.type.hasInit && !var.type.ptr) {
628628
output ~= format(".vsp LDZ2 type_init_%s\n", Sanitise(var.type.name));
629629
}
630630
}
@@ -744,7 +744,7 @@ class BackendUXN : CompilerBackend {
744744
foreach (ref var ; variables) {
745745
scopeSize += var.Size();
746746

747-
if (var.type.hasDeinit) {
747+
if (var.type.hasDeinit && !var.type.ptr) {
748748
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
749749
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
750750
}
@@ -869,7 +869,7 @@ class BackendUXN : CompilerBackend {
869869
foreach (ref var ; variables) {
870870
scopeSize += var.Size();
871871

872-
if (var.type.hasDeinit) {
872+
if (var.type.hasDeinit && !var.type.ptr) {
873873
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
874874
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));
875875
}
@@ -1041,7 +1041,7 @@ class BackendUXN : CompilerBackend {
10411041
// remove scope
10421042
foreach (ref var ; variables) {
10431043
if (oldVars.canFind(var)) continue;
1044-
if (!var.type.hasDeinit) continue;
1044+
if (!var.type.hasDeinit || var.type.ptr) continue;
10451045

10461046
output ~= format(".vsp LDZ2 #.2x ADD2", var.offset);
10471047
output ~= format("type_deinit_%s\n", Sanitise(var.type.name));

0 commit comments

Comments
 (0)