Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/parser/context-defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ ParseDefsCtx::makeTypeUse(Index pos,
return it->second;
}

Result<> ParseDefsCtx::addFunc(Name,
const std::vector<Name>&,
ImportNames*,
TypeUseT,
std::optional<LocalsT>,
Index pos) {
CHECK_ERR(withLoc(pos, irBuilder.visitEnd()));
return Ok{};
}

Result<> ParseDefsCtx::addGlobal(Name,
const std::vector<Name>&,
ImportNames*,
Expand Down
5 changes: 4 additions & 1 deletion src/parser/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -1324,12 +1324,15 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
std::optional<HeapTypeT> type,
ParamsT* params,
ResultsT* results);

Result<> addFunc(Name,
const std::vector<Name>&,
ImportNames*,
TypeUseT,
std::optional<LocalsT>,
Index pos);
Index) {
return Ok{};
}

Result<>
addTable(Name, const std::vector<Name>&, ImportNames*, TableTypeT, Index) {
Expand Down
8 changes: 7 additions & 1 deletion src/parser/wat-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ Result<> parseModule(Module& wasm, std::string_view input) {

for (Index i = 0; i < decls.funcDefs.size(); ++i) {
ctx.index = i;
CHECK_ERR(ctx.visitFunctionStart(wasm.functions[i].get()));
auto* f = wasm.functions[i].get();
if (!f->imported()) {
CHECK_ERR(ctx.visitFunctionStart(f));
}
WithPosition with(ctx, decls.funcDefs[i].pos);
if (auto parsed = func(ctx)) {
CHECK_ERR(parsed);
Expand All @@ -186,6 +189,9 @@ Result<> parseModule(Module& wasm, std::string_view input) {
assert(im);
CHECK_ERR(im);
}
if (!f->imported()) {
CHECK_ERR(ctx.irBuilder.visitEnd());
}
}

// Parse exports.
Expand Down
4 changes: 3 additions & 1 deletion src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ Result<Expression*> IRBuilder::pop(size_t size) {
// Find the suffix of expressions that do not produce values.
auto hoisted = hoistLastValue();
CHECK_ERR(hoisted);

if (!hoisted) {
// There are no expressions that produce values.
if (scope.unreachable) {
Expand Down Expand Up @@ -700,6 +699,9 @@ Result<Expression*> IRBuilder::finishScope(Block* block) {
// the top.
auto hoisted = hoistLastValue();
CHECK_ERR(hoisted);
if (!hoisted) {
return Err{"popping from empty stack"};
}
}

Expression* ret = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions test/lit/wat-kitchen-sink.wast
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@

;; imported functions
(func (export "f5.0") (export "f5.1") (import "mod" "f5"))
(import "mod" "imported-f" (func (param) (result)))
(import "mod" "imported-f" (func (param) (result i32 i64)))

;; imported tags
(tag $imported (export "t0.0") (export "t0.1") (import "mod" "t0") (param i32 i64))
Expand All @@ -283,7 +283,7 @@

;; CHECK: (import "mod" "f5" (func $fimport$0 (type $void)))

;; CHECK: (import "mod" "imported-f" (func $fimport$1 (type $void)))
;; CHECK: (import "mod" "imported-f" (func $fimport$1 (type $3) (result i32 i64)))

;; CHECK: (import "mod" "t0" (tag $imported (param i32 i64)))

Expand Down