Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Feb 7, 2024
1 parent e94c216 commit 856ab25
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/passes/StringLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ struct StringLowering : public StringGathering {
// string.length: string -> i32
lengthImport = addImport(module, "length", nullExt, Type::i32);
// string.codePointAt: string, offset -> i32
codePointAtImport = addImport(module, "codePointAt", {nullExt, Type::i32}, Type::i32);
codePointAtImport =
addImport(module, "codePointAt", {nullExt, Type::i32}, Type::i32);
// string.substring: string, start, end -> string
substringImport = addImport(module, "substring", {nullExt, Type::i32, Type::i32}, nnExt);
substringImport =
addImport(module, "substring", {nullExt, Type::i32, Type::i32}, nnExt);

// Replace the string instructions in parallel.
struct Replacer : public WalkerPass<PostWalker<Replacer>> {
Expand Down Expand Up @@ -370,16 +372,17 @@ struct StringLowering : public StringGathering {

void visitStringWTF16Get(StringWTF16Get* curr) {
Builder builder(*getModule());
replaceCurrent(
builder.makeCall(lowering.codePointAtImport, {curr->ref, curr->pos}, Type::i32));
replaceCurrent(builder.makeCall(
lowering.codePointAtImport, {curr->ref, curr->pos}, Type::i32));
}

void visitStringSliceWTF(StringSliceWTF* curr) {
Builder builder(*getModule());
switch (curr->op) {
case StringSliceWTF16:
replaceCurrent(
builder.makeCall(lowering.substringImport, {curr->ref, curr->start, curr->end}, lowering.nnExt));
replaceCurrent(builder.makeCall(lowering.substringImport,
{curr->ref, curr->start, curr->end},
lowering.nnExt));
return;
default:
WASM_UNREACHABLE("TODO: all string.slice*");
Expand Down

0 comments on commit 856ab25

Please sign in to comment.