Skip to content

Commit e8764f0

Browse files
Use string_view for trap
1 parent 9452643 commit e8764f0

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/shell-interface.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,15 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
325325
return true;
326326
}
327327

328-
void trap(const char* why) override {
328+
void trap(std::string_view why) override {
329329
std::cout << "[trap " << why << "]\n";
330330
throw TrapException();
331331
}
332332

333-
void hostLimit(const char* why) override {
333+
void hostLimit(std::string_view why) override {
334334
std::cout << "[host limit " << why << "]\n";
335335
throw HostLimitException();
336336
}
337-
338337
void throwException(const WasmException& exn) override { throw exn; }
339338
};
340339

src/tools/wasm-ctor-eval.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,12 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
451451
throw FailToEvalException("grow table");
452452
}
453453

454-
void trap(const char* why) override {
455-
throw FailToEvalException(std::string("trap: ") + why);
454+
void trap(std::string_view why) override {
455+
throw FailToEvalException(std::string("trap: ") + std::string(why));
456456
}
457457

458-
void hostLimit(const char* why) override {
459-
throw FailToEvalException(std::string("trap: ") + why);
458+
void hostLimit(std::string_view why) override {
459+
throw FailToEvalException(std::string("trap: ") + std::string(why));
460460
}
461461

462462
void throwException(const WasmException& exn) override {

src/wasm-interpreter.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Flow {
8686
}
8787

8888
Literals values;
89-
Name breakTo; // if non-null, a break is going on
89+
Name breakTo; // if non-null, a break is going on
9090
Tag* suspendTag = nullptr; // if non-null, breakTo must be SUSPEND_FLOW, and
9191
// this is the tag being suspended
9292

@@ -2694,9 +2694,9 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
26942694
return makeGCData(std::move(contents), curr->type);
26952695
}
26962696

2697-
virtual void trap(const char* why) { WASM_UNREACHABLE("unimp"); }
2697+
virtual void trap(std::string_view why) { WASM_UNREACHABLE("unimp"); }
26982698

2699-
virtual void hostLimit(const char* why) { WASM_UNREACHABLE("unimp"); }
2699+
virtual void hostLimit(std::string_view why) { WASM_UNREACHABLE("unimp"); }
27002700

27012701
virtual void throwException(const WasmException& exn) {
27022702
WASM_UNREACHABLE("unimp");
@@ -2929,9 +2929,11 @@ class ConstantExpressionRunner : public ExpressionRunner<SubType> {
29292929
Flow visitResumeThrow(ResumeThrow* curr) { return Flow(NONCONSTANT_FLOW); }
29302930
Flow visitStackSwitch(StackSwitch* curr) { return Flow(NONCONSTANT_FLOW); }
29312931

2932-
void trap(const char* why) override { throw NonconstantException(); }
2932+
void trap(std::string_view why) override { throw NonconstantException(); }
29332933

2934-
void hostLimit(const char* why) override { throw NonconstantException(); }
2934+
void hostLimit(std::string_view why) override {
2935+
throw NonconstantException();
2936+
}
29352937

29362938
virtual void throwException(const WasmException& exn) override {
29372939
throw NonconstantException();
@@ -2974,8 +2976,8 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
29742976
const Literal& value,
29752977
Index oldSize,
29762978
Index newSize) = 0;
2977-
virtual void trap(const char* why) = 0;
2978-
virtual void hostLimit(const char* why) = 0;
2979+
virtual void trap(std::string_view why) = 0;
2980+
virtual void hostLimit(std::string_view why) = 0;
29792981
virtual void throwException(const WasmException& exn) = 0;
29802982
// Get the Tag instance for a tag implemented in the host, that is, not
29812983
// among the linked ModuleRunner instances, but imported from the host.
@@ -4741,13 +4743,12 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
47414743
Flow visitResumeThrow(ResumeThrow* curr) { return doResume(curr); }
47424744
Flow visitStackSwitch(StackSwitch* curr) { return Flow(NONCONSTANT_FLOW); }
47434745

4744-
void trap(const char* why) override {
4746+
void trap(std::string_view why) override {
47454747
// Traps break all current continuations - they will never be resumable.
47464748
self()->clearContinuationStore();
47474749
externalInterface->trap(why);
47484750
}
4749-
4750-
void hostLimit(const char* why) override {
4751+
void hostLimit(std::string_view why) override {
47514752
self()->clearContinuationStore();
47524753
externalInterface->hostLimit(why);
47534754
}

0 commit comments

Comments
 (0)