File tree Expand file tree Collapse file tree 6 files changed +69
-28
lines changed Expand file tree Collapse file tree 6 files changed +69
-28
lines changed Original file line number Diff line number Diff line change @@ -858,6 +858,14 @@ public class GenC : GenCCpp
858
858
}
859
859
}
860
860
861
+ void StartDestructCall!(FuClassType klass)
862
+ {
863
+ bool addressOf = WriteDestructMethodName(klass);
864
+ WriteChar('(');
865
+ if (addressOf)
866
+ WriteChar('&');
867
+ }
868
+
861
869
static bool HasDictionaryDestroy(FuType? type) => type is FuOwningType || type is FuStringStorageType;
862
870
863
871
void WriteDictionaryDestroy!(FuType? type)
@@ -1151,9 +1159,8 @@ public class GenC : GenCCpp
1151
1159
if (!NeedToDestructType(temp.Type)
1152
1160
|| (temp is FuPrefixExpr dynamicObjectLiteral && dynamicObjectLiteral.Inner is FuAggregateInitializer)) // FIXME: if temporary, still needs to be destructed
1153
1161
return;
1154
- WriteDestructMethodName(temp.Type.AsClassType());
1155
- Write("(futemp");
1156
- VisitLiteralLong(i);
1162
+ StartDestructCall(temp.Type.AsClassType());
1163
+ WriteTemporaryName(i);
1157
1164
WriteLine(");");
1158
1165
}
1159
1166
@@ -1368,10 +1375,7 @@ public class GenC : GenCCpp
1368
1375
type = array.GetElementType();
1369
1376
}
1370
1377
assert type is FuClassType klass;
1371
- bool addressOf = WriteDestructMethodName(klass);
1372
- WriteChar('(');
1373
- if (addressOf)
1374
- WriteChar('&');
1378
+ StartDestructCall(klass);
1375
1379
WriteLocalName(symbol, FuPriority.Primary);
1376
1380
for (int i = 0; i < nesting; i++) {
1377
1381
Write("[_i");
Original file line number Diff line number Diff line change @@ -9772,6 +9772,14 @@ bool GenC::writeDestructMethodName(const FuClassType * klass)
9772
9772
}
9773
9773
}
9774
9774
9775
+ void GenC::startDestructCall(const FuClassType * klass)
9776
+ {
9777
+ bool addressOf = writeDestructMethodName(klass);
9778
+ writeChar('(');
9779
+ if (addressOf)
9780
+ writeChar('&');
9781
+ }
9782
+
9775
9783
bool GenC::hasDictionaryDestroy(const FuType * type)
9776
9784
{
9777
9785
return dynamic_cast<const FuOwningType *>(type) || dynamic_cast<const FuStringStorageType *>(type);
@@ -10054,9 +10062,8 @@ void GenC::cleanupTemporary(int i, const FuExpr * temp)
10054
10062
const FuPrefixExpr * dynamicObjectLiteral;
10055
10063
if (!needToDestructType(temp->type.get()) || ((dynamicObjectLiteral = dynamic_cast<const FuPrefixExpr *>(temp)) && dynamic_cast<const FuAggregateInitializer *>(dynamicObjectLiteral->inner.get())))
10056
10064
return;
10057
- writeDestructMethodName(temp->type->asClassType());
10058
- write("(futemp");
10059
- visitLiteralLong(i);
10065
+ startDestructCall(temp->type->asClassType());
10066
+ writeTemporaryName(i);
10060
10067
writeLine(");");
10061
10068
}
10062
10069
@@ -10259,10 +10266,7 @@ void GenC::writeDestruct(const FuSymbol * symbol)
10259
10266
type = array->getElementType().get();
10260
10267
}
10261
10268
const FuClassType * klass = static_cast<const FuClassType *>(type);
10262
- bool addressOf = writeDestructMethodName(klass);
10263
- writeChar('(');
10264
- if (addressOf)
10265
- writeChar('&');
10269
+ startDestructCall(klass);
10266
10270
writeLocalName(symbol, FuPriority::primary);
10267
10271
for (int i = 0; i < nesting; i++) {
10268
10272
write("[_i");
Original file line number Diff line number Diff line change @@ -10073,6 +10073,14 @@ bool WriteDestructMethodName(FuClassType klass)
10073
10073
}
10074
10074
}
10075
10075
10076
+ void StartDestructCall(FuClassType klass)
10077
+ {
10078
+ bool addressOf = WriteDestructMethodName(klass);
10079
+ WriteChar('(');
10080
+ if (addressOf)
10081
+ WriteChar('&');
10082
+ }
10083
+
10076
10084
static bool HasDictionaryDestroy(FuType type) => type is FuOwningType || type is FuStringStorageType;
10077
10085
10078
10086
void WriteDictionaryDestroy(FuType type)
@@ -10363,9 +10371,8 @@ protected override void CleanupTemporary(int i, FuExpr temp)
10363
10371
{
10364
10372
if (!NeedToDestructType(temp.Type) || (temp is FuPrefixExpr dynamicObjectLiteral && dynamicObjectLiteral.Inner is FuAggregateInitializer))
10365
10373
return;
10366
- WriteDestructMethodName(temp.Type.AsClassType());
10367
- Write("(futemp");
10368
- VisitLiteralLong(i);
10374
+ StartDestructCall(temp.Type.AsClassType());
10375
+ WriteTemporaryName(i);
10369
10376
WriteLine(");");
10370
10377
}
10371
10378
@@ -10567,10 +10574,7 @@ void WriteDestruct(FuSymbol symbol)
10567
10574
type = array.GetElementType();
10568
10575
}
10569
10576
FuClassType klass = (FuClassType) type;
10570
- bool addressOf = WriteDestructMethodName(klass);
10571
- WriteChar('(');
10572
- if (addressOf)
10573
- WriteChar('&');
10577
+ StartDestructCall(klass);
10574
10578
WriteLocalName(symbol, FuPriority.Primary);
10575
10579
for (int i = 0; i < nesting; i++) {
10576
10580
Write("[_i");
Original file line number Diff line number Diff line change @@ -2163,6 +2163,7 @@ class GenC : public GenCCpp
2163
2163
static const FuExpr * getStringSubstringLength (const FuCallExpr * call);
2164
2164
void writeStringStorageValue (const FuExpr * expr);
2165
2165
bool writeDestructMethodName (const FuClassType * klass);
2166
+ void startDestructCall (const FuClassType * klass);
2166
2167
static bool hasDictionaryDestroy (const FuType * type);
2167
2168
void writeDictionaryDestroy (const FuType * type);
2168
2169
void writeHashEqual (const FuType * keyType);
Original file line number Diff line number Diff line change @@ -10416,6 +10416,14 @@ export class GenC extends GenCCpp
10416
10416
}
10417
10417
}
10418
10418
10419
+ #startDestructCall(klass)
10420
+ {
10421
+ let addressOf = this.#writeDestructMethodName(klass);
10422
+ this.writeChar(40);
10423
+ if (addressOf)
10424
+ this.writeChar(38);
10425
+ }
10426
+
10419
10427
static #hasDictionaryDestroy(type)
10420
10428
{
10421
10429
return type instanceof FuOwningType || type instanceof FuStringStorageType;
@@ -10724,9 +10732,8 @@ export class GenC extends GenCCpp
10724
10732
let dynamicObjectLiteral;
10725
10733
if (!GenC.#needToDestructType(temp.type) || ((dynamicObjectLiteral = temp) instanceof FuPrefixExpr && dynamicObjectLiteral.inner instanceof FuAggregateInitializer))
10726
10734
return;
10727
- this.#writeDestructMethodName(temp.type.asClassType());
10728
- this.write("(futemp");
10729
- this.visitLiteralLong(BigInt(i));
10735
+ this.#startDestructCall(temp.type.asClassType());
10736
+ this.writeTemporaryName(i);
10730
10737
this.writeLine(");");
10731
10738
}
10732
10739
@@ -10934,10 +10941,7 @@ export class GenC extends GenCCpp
10934
10941
type = array.getElementType();
10935
10942
}
10936
10943
let klass = type;
10937
- let addressOf = this.#writeDestructMethodName(klass);
10938
- this.writeChar(40);
10939
- if (addressOf)
10940
- this.writeChar(38);
10944
+ this.#startDestructCall(klass);
10941
10945
this.writeLocalName(symbol, FuPriority.PRIMARY);
10942
10946
for (let i = 0; i < nesting; i++) {
10943
10947
this.write("[_i");
Original file line number Diff line number Diff line change
1
+ class Data
2
+ {
3
+ internal string() S; //FAIL: cl
4
+ }
5
+
6
+ public static class Test
7
+ {
8
+ static Data() ReturnStorage()
9
+ {
10
+ Data() o;
11
+ o.S = "foo";
12
+ return o; //FAIL: c TODO
13
+ }
14
+
15
+ static string AcceptPtr(Data d)
16
+ {
17
+ return d.S;
18
+ }
19
+
20
+ public static bool Run()
21
+ {
22
+ return AcceptPtr(ReturnStorage()) == "foo";
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments