Skip to content

Commit 3ce02b6

Browse files
authored
[NFC] printHeapType => printHeapTypeName in Print.cpp (#7443)
Rename the function in anticipation of exact heap types appearing in the IR. When an expression like `StructNew` has an exact heap type, the `exact` does not appear in `struct.new $foo`. In this case `$foo` is not the full heap type, but rather than name of the heap type definition.
1 parent 9cef51c commit 3ce02b6

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/passes/Print.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
232232

233233
std::ostream& printType(Type type) { return o << typePrinter(type); }
234234

235-
std::ostream& printHeapType(HeapType type) {
235+
std::ostream& printHeapTypeName(HeapType type) {
236236
if (type.isBasic()) {
237237
return o << type;
238238
}
@@ -257,7 +257,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
257257
if (sig.results.isTuple()) {
258258
if (auto it = signatureTypes.find(sig); it != signatureTypes.end()) {
259259
o << "(type ";
260-
printHeapType(it->second);
260+
printHeapTypeName(it->second);
261261
o << ") ";
262262
}
263263
}
@@ -471,8 +471,8 @@ struct PrintExpressionContents
471471

472472
std::ostream& printType(Type type) { return parent.printType(type); }
473473

474-
std::ostream& printHeapType(HeapType type) {
475-
return parent.printHeapType(type);
474+
std::ostream& printHeapTypeName(HeapType type) {
475+
return parent.printHeapTypeName(type);
476476
}
477477

478478
std::ostream& printResultType(Type type) {
@@ -563,7 +563,7 @@ struct PrintExpressionContents
563563
o << '(';
564564
printMinor(o, "type ");
565565

566-
printHeapType(curr->heapType);
566+
printHeapTypeName(curr->heapType);
567567

568568
o << ')';
569569
}
@@ -2144,7 +2144,7 @@ struct PrintExpressionContents
21442144
}
21452145
void visitRefNull(RefNull* curr) {
21462146
printMedium(o, "ref.null ");
2147-
printHeapType(curr->type.getHeapType());
2147+
printHeapTypeName(curr->type.getHeapType());
21482148
}
21492149
void visitRefIsNull(RefIsNull* curr) { printMedium(o, "ref.is_null"); }
21502150
void visitRefFunc(RefFunc* curr) {
@@ -2253,7 +2253,7 @@ struct PrintExpressionContents
22532253

22542254
void visitCallRef(CallRef* curr) {
22552255
printMedium(o, curr->isReturn ? "return_call_ref " : "call_ref ");
2256-
printHeapType(curr->target->type.getHeapType());
2256+
printHeapTypeName(curr->target->type.getHeapType());
22572257
}
22582258
void visitRefTest(RefTest* curr) {
22592259
printMedium(o, "ref.test ");
@@ -2310,7 +2310,7 @@ struct PrintExpressionContents
23102310
printMedium(o, "_default");
23112311
}
23122312
o << ' ';
2313-
printHeapType(curr->type.getHeapType());
2313+
printHeapTypeName(curr->type.getHeapType());
23142314
}
23152315
void printFieldName(HeapType type, Index index) {
23162316
auto names = parent.typePrinter.getNames(type).fieldNames;
@@ -2350,7 +2350,7 @@ struct PrintExpressionContents
23502350
printMedium(o, ".get ");
23512351
}
23522352
printMemoryOrder(curr->order);
2353-
printHeapType(heapType);
2353+
printHeapTypeName(heapType);
23542354
o << ' ';
23552355
printFieldName(heapType, curr->index);
23562356
}
@@ -2362,7 +2362,7 @@ struct PrintExpressionContents
23622362
}
23632363
printMemoryOrder(curr->order);
23642364
auto heapType = curr->ref->type.getHeapType();
2365-
printHeapType(heapType);
2365+
printHeapTypeName(heapType);
23662366
o << ' ';
23672367
printFieldName(heapType, curr->index);
23682368
}
@@ -2375,7 +2375,7 @@ struct PrintExpressionContents
23752375
printMemoryOrder(curr->order);
23762376
printMemoryOrder(curr->order);
23772377
auto heapType = curr->ref->type.getHeapType();
2378-
printHeapType(heapType);
2378+
printHeapTypeName(heapType);
23792379
o << ' ';
23802380
printFieldName(heapType, curr->index);
23812381
}
@@ -2386,7 +2386,7 @@ struct PrintExpressionContents
23862386
printMemoryOrder(curr->order);
23872387
printMemoryOrder(curr->order);
23882388
auto heapType = curr->ref->type.getHeapType();
2389-
printHeapType(heapType);
2389+
printHeapTypeName(heapType);
23902390
o << ' ';
23912391
printFieldName(heapType, curr->index);
23922392
}
@@ -2396,26 +2396,26 @@ struct PrintExpressionContents
23962396
printMedium(o, "_default");
23972397
}
23982398
o << ' ';
2399-
printHeapType(curr->type.getHeapType());
2399+
printHeapTypeName(curr->type.getHeapType());
24002400
}
24012401
void visitArrayNewData(ArrayNewData* curr) {
24022402
printMedium(o, "array.new_data");
24032403
o << ' ';
2404-
printHeapType(curr->type.getHeapType());
2404+
printHeapTypeName(curr->type.getHeapType());
24052405
o << ' ';
24062406
curr->segment.print(o);
24072407
}
24082408
void visitArrayNewElem(ArrayNewElem* curr) {
24092409
printMedium(o, "array.new_elem");
24102410
o << ' ';
2411-
printHeapType(curr->type.getHeapType());
2411+
printHeapTypeName(curr->type.getHeapType());
24122412
o << ' ';
24132413
curr->segment.print(o);
24142414
}
24152415
void visitArrayNewFixed(ArrayNewFixed* curr) {
24162416
printMedium(o, "array.new_fixed");
24172417
o << ' ';
2418-
printHeapType(curr->type.getHeapType());
2418+
printHeapTypeName(curr->type.getHeapType());
24192419
o << ' ';
24202420
o << curr->values.size();
24212421
}
@@ -2430,32 +2430,32 @@ struct PrintExpressionContents
24302430
} else {
24312431
printMedium(o, "array.get ");
24322432
}
2433-
printHeapType(curr->ref->type.getHeapType());
2433+
printHeapTypeName(curr->ref->type.getHeapType());
24342434
}
24352435
void visitArraySet(ArraySet* curr) {
24362436
printMedium(o, "array.set ");
2437-
printHeapType(curr->ref->type.getHeapType());
2437+
printHeapTypeName(curr->ref->type.getHeapType());
24382438
}
24392439
void visitArrayLen(ArrayLen* curr) { printMedium(o, "array.len"); }
24402440
void visitArrayCopy(ArrayCopy* curr) {
24412441
printMedium(o, "array.copy ");
2442-
printHeapType(curr->destRef->type.getHeapType());
2442+
printHeapTypeName(curr->destRef->type.getHeapType());
24432443
o << ' ';
2444-
printHeapType(curr->srcRef->type.getHeapType());
2444+
printHeapTypeName(curr->srcRef->type.getHeapType());
24452445
}
24462446
void visitArrayFill(ArrayFill* curr) {
24472447
printMedium(o, "array.fill ");
2448-
printHeapType(curr->ref->type.getHeapType());
2448+
printHeapTypeName(curr->ref->type.getHeapType());
24492449
}
24502450
void visitArrayInitData(ArrayInitData* curr) {
24512451
printMedium(o, "array.init_data ");
2452-
printHeapType(curr->ref->type.getHeapType());
2452+
printHeapTypeName(curr->ref->type.getHeapType());
24532453
o << ' ';
24542454
curr->segment.print(o);
24552455
}
24562456
void visitArrayInitElem(ArrayInitElem* curr) {
24572457
printMedium(o, "array.init_elem ");
2458-
printHeapType(curr->ref->type.getHeapType());
2458+
printHeapTypeName(curr->ref->type.getHeapType());
24592459
o << ' ';
24602460
curr->segment.print(o);
24612461
}
@@ -2547,14 +2547,14 @@ struct PrintExpressionContents
25472547
void visitContNew(ContNew* curr) {
25482548
assert(curr->type.isContinuation());
25492549
printMedium(o, "cont.new ");
2550-
printHeapType(curr->type.getHeapType());
2550+
printHeapTypeName(curr->type.getHeapType());
25512551
}
25522552
void visitContBind(ContBind* curr) {
25532553
assert(curr->cont->type.isContinuation() && curr->type.isContinuation());
25542554
printMedium(o, "cont.bind ");
2555-
printHeapType(curr->cont->type.getHeapType());
2555+
printHeapTypeName(curr->cont->type.getHeapType());
25562556
o << ' ';
2557-
printHeapType(curr->type.getHeapType());
2557+
printHeapTypeName(curr->type.getHeapType());
25582558
}
25592559
void visitSuspend(Suspend* curr) {
25602560
printMedium(o, "suspend ");
@@ -2582,7 +2582,7 @@ struct PrintExpressionContents
25822582
printMedium(o, "resume");
25832583

25842584
o << ' ';
2585-
printHeapType(curr->cont->type.getHeapType());
2585+
printHeapTypeName(curr->cont->type.getHeapType());
25862586

25872587
handleResumeTable(o, curr);
25882588
}
@@ -2591,7 +2591,7 @@ struct PrintExpressionContents
25912591
printMedium(o, "resume_throw");
25922592

25932593
o << ' ';
2594-
printHeapType(curr->cont->type.getHeapType());
2594+
printHeapTypeName(curr->cont->type.getHeapType());
25952595
o << ' ';
25962596
curr->tag.print(o);
25972597

@@ -2602,7 +2602,7 @@ struct PrintExpressionContents
26022602
printMedium(o, "switch");
26032603

26042604
o << ' ';
2605-
printHeapType(curr->cont->type.getHeapType());
2605+
printHeapTypeName(curr->cont->type.getHeapType());
26062606
o << ' ';
26072607
curr->tag.print(o);
26082608
}
@@ -3022,7 +3022,7 @@ void PrintSExpression::handleSignature(Function* curr,
30223022
if ((currModule && currModule->features.hasGC()) ||
30233023
requiresExplicitFuncType(curr->type)) {
30243024
o << " (type ";
3025-
printHeapType(curr->type) << ')';
3025+
printHeapTypeName(curr->type) << ')';
30263026
}
30273027
bool inParam = false;
30283028
Index i = 0;
@@ -3247,7 +3247,7 @@ void PrintSExpression::visitDefinedTag(Tag* curr) {
32473247

32483248
void PrintSExpression::printTagType(HeapType type) {
32493249
o << "(type ";
3250-
printHeapType(type);
3250+
printHeapTypeName(type);
32513251
o << ')';
32523252
if (auto params = type.getSignature().params; params != Type::none) {
32533253
o << maybeSpace << "(param";

0 commit comments

Comments
 (0)