diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-01-05 11:40:31 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-01-05 11:40:31 -0800 |
commit | 644ef3072d389b9097e3a2709af5c40811e95839 (patch) | |
tree | b33d33a585881ad283342db071ddf20f1d90a833 /src | |
parent | 8452a0b54562590e568b5f86fe35c0fb4001a78c (diff) | |
download | binaryen-644ef3072d389b9097e3a2709af5c40811e95839.tar.gz binaryen-644ef3072d389b9097e3a2709af5c40811e95839.tar.bz2 binaryen-644ef3072d389b9097e3a2709af5c40811e95839.zip |
fix parsing error in s-parser with functions with just a block and then more content
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-s-parser.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index f204d933a..b36740ebd 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -317,6 +317,7 @@ private: localIndex = 0; otherIndex = 0; std::vector<NameType> typeParams; // we may have both params and a type. store the type info here + Block* autoBlock = nullptr; // we may need to add a block for the very top level for (;i < s.size(); i++) { Element& curr = *s[i]; IString id = curr[0]->str(); @@ -368,13 +369,12 @@ private: if (!func->body) { func->body = ex; } else { - auto block = func->body->dyn_cast<Block>(); - if (!block) { - block = allocator.alloc<Block>(); - block->list.push_back(func->body); - func->body = block; + if (!autoBlock) { + autoBlock = allocator.alloc<Block>(); + autoBlock->list.push_back(func->body); + func->body = autoBlock; } - block->list.push_back(ex); + autoBlock->list.push_back(ex); } } } |