diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-02-13 20:31:03 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-13 20:31:03 +0900 |
commit | ac3188facecb78ebaea1eec6cd6e4723a1a161fe (patch) | |
tree | 157c41d47848defb3ecb2aa407013192f6d8e8ee /src/wasm/wasm-validator.cpp | |
parent | df9389509c703ec0583d16a70306dbdd07426c56 (diff) | |
download | binaryen-ac3188facecb78ebaea1eec6cd6e4723a1a161fe.tar.gz binaryen-ac3188facecb78ebaea1eec6cd6e4723a1a161fe.tar.bz2 binaryen-ac3188facecb78ebaea1eec6cd6e4723a1a161fe.zip |
[EH] Rename delegateTarget to exceptionTarget (NFC) (#3562)
So far `Try`'s label is only targetted by `delegate`s, but it turns out
`rethrow` also has to follow the same rule as `delegate` so it needs to
target a `Try` label. So this renames variables like
`delegateTargetNames` to `exceptionTargetNames` and methods like
`replaceDelegateTargets` to `replaceExceptionTargets`.
I considered `tryTarget`, but the branch/block counterpart name we use
is not `blockTarget` but `branchTarget`, so I chose `exceptionTarget`.
The patch that fixes `rethrow`'s target will follow; this is the
preparation for that.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index beb994390..736d669fb 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -236,7 +236,7 @@ struct FunctionValidator : public WalkerPass<PostWalker<FunctionValidator>> { }; std::unordered_map<Name, BreakInfo> breakInfos; - std::unordered_set<Name> delegateTargetNames; + std::unordered_set<Name> exceptionTargetNames; std::set<Type> returnTypes; // types used in returns @@ -280,7 +280,7 @@ public: static void visitPreTry(FunctionValidator* self, Expression** currp) { auto* curr = (*currp)->cast<Try>(); if (curr->name.is()) { - self->delegateTargetNames.insert(curr->name); + self->exceptionTargetNames.insert(curr->name); } } @@ -300,7 +300,7 @@ public: static void visitPreCatch(FunctionValidator* self, Expression** currp) { auto* curr = (*currp)->cast<Try>(); if (curr->name.is()) { - self->delegateTargetNames.erase(curr->name); + self->exceptionTargetNames.erase(curr->name); } } @@ -376,7 +376,7 @@ public: void visitRefIs(RefIs* curr); void visitRefFunc(RefFunc* curr); void visitRefEq(RefEq* curr); - void noteDelegate(Name name, Expression* curr); + void noteException(Name name, Expression* curr); void visitTry(Try* curr); void visitThrow(Throw* curr); void visitRethrow(Rethrow* curr); @@ -2073,9 +2073,9 @@ void FunctionValidator::visitRefEq(RefEq* curr) { "ref.eq's right argument should be a subtype of eqref"); } -void FunctionValidator::noteDelegate(Name name, Expression* curr) { +void FunctionValidator::noteException(Name name, Expression* curr) { if (name != DELEGATE_CALLER_TARGET) { - shouldBeTrue(delegateTargetNames.find(name) != delegateTargetNames.end(), + shouldBeTrue(exceptionTargetNames.find(name) != exceptionTargetNames.end(), curr, "all delegate targets must be valid"); } @@ -2122,7 +2122,7 @@ void FunctionValidator::visitTry(Try* curr) { "try should have either catches or a delegate"); if (curr->isDelegate()) { - noteDelegate(curr->delegateTarget, curr); + noteException(curr->delegateTarget, curr); } } @@ -2533,7 +2533,7 @@ void FunctionValidator::visitFunction(Function* curr) { shouldBeTrue( breakInfos.empty(), curr->body, "all named break targets must exist"); - shouldBeTrue(delegateTargetNames.empty(), + shouldBeTrue(exceptionTargetNames.empty(), curr->body, "all named delegate targets must exist"); returnTypes.clear(); |