diff options
author | Ben Smith <binji@chromium.org> | 2020-02-20 14:06:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 14:06:19 -0800 |
commit | 94ad3e84817c546b1313e161da565d181b1a470c (patch) | |
tree | 77b94ab9dd8a06fbad94e2931e489950eecd2155 /src/wast-parser.cc | |
parent | 09d712be32398d2ab4174f36228dcac5fbb5f672 (diff) | |
download | wabt-94ad3e84817c546b1313e161da565d181b1a470c.tar.gz wabt-94ad3e84817c546b1313e161da565d181b1a470c.tar.bz2 wabt-94ad3e84817c546b1313e161da565d181b1a470c.zip |
Always run ResolveNames after parsing .wast/.wat (#1337)
Resolving names (i.e. remapping variable names to indexes) is meant to
be part of the parsing process. The spec even considers an unmapped
variable name to be "malformed" text.
This PR moves in that direction, by always running ResolveNames after
parsing text. The next step would be to integrate this more closely with
the parser itself.
Diffstat (limited to 'src/wast-parser.cc')
-rw-r--r-- | src/wast-parser.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 4f86b0dd..c8e3e871 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -21,6 +21,7 @@ #include "src/cast.h" #include "src/expr-visitor.h" #include "src/make-unique.h" +#include "src/resolve-names.h" #include "src/stream.h" #include "src/utf8.h" @@ -2805,7 +2806,9 @@ Result ParseWatModule(WastLexer* lexer, assert(out_module != nullptr); assert(options != nullptr); WastParser parser(lexer, errors, options); - return parser.ParseModule(out_module); + CHECK_RESULT(parser.ParseModule(out_module)); + CHECK_RESULT(ResolveNamesModule(out_module->get(), errors)); + return Result::Ok; } Result ParseWastScript(WastLexer* lexer, @@ -2815,7 +2818,9 @@ Result ParseWastScript(WastLexer* lexer, assert(out_script != nullptr); assert(options != nullptr); WastParser parser(lexer, errors, options); - return parser.ParseScript(out_script); + CHECK_RESULT(parser.ParseScript(out_script)); + CHECK_RESULT(ResolveNamesScript(out_script->get(), errors)); + return Result::Ok; } } // namespace wabt |