diff options
author | Dmitry Bezhetskov <Dima00782@gmail.com> | 2021-07-26 00:41:32 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 10:41:32 -0700 |
commit | 9aac0a28896a714b698ab489a473b9bc05deb7c3 (patch) | |
tree | 7e3e40abd22146f2d76981c30dfa693290956448 /src/type-checker.cc | |
parent | 7eadc12f71483b1d9d8cf16877efa33361d1e493 (diff) | |
download | wabt-9aac0a28896a714b698ab489a473b9bc05deb7c3.tar.gz wabt-9aac0a28896a714b698ab489a473b9bc05deb7c3.tar.bz2 wabt-9aac0a28896a714b698ab489a473b9bc05deb7c3.zip |
Begin support for typed function references proposal: added the flag and supported call_ref (#1691)
Diffstat (limited to 'src/type-checker.cc')
-rw-r--r-- | src/type-checker.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc index 1daa5ecf..3e875a31 100644 --- a/src/type-checker.cc +++ b/src/type-checker.cc @@ -489,6 +489,27 @@ Result TypeChecker::OnCallIndirect(const TypeVector& param_types, return result; } +Result TypeChecker::OnFuncRef(Index* out_index) { + Type type; + Result result = PeekType(0, &type); + if (!type.IsIndex()) { + TypeVector actual; + if (Succeeded(result)) { + actual.push_back(type); + } + std::string message = + "type mismatch in call_ref, expected reference but got " + + TypesToString(actual); + PrintError("%s", message.c_str()); + result = Result::Error; + } + if (Succeeded(result)) { + *out_index = type.GetIndex(); + } + result |= DropTypes(1); + return result; +} + Result TypeChecker::OnReturnCall(const TypeVector& param_types, const TypeVector& result_types) { Result result = PopAndCheckSignature(param_types, "return_call"); @@ -728,8 +749,12 @@ Result TypeChecker::OnTableFill(Type elem_type) { return PopAndCheck3Types(Type::I32, elem_type, Type::I32, "table.fill"); } -Result TypeChecker::OnRefFuncExpr(Index) { - PushType(Type::FuncRef); +Result TypeChecker::OnRefFuncExpr(Index func_index) { + if (features_.function_references_enabled()) { + PushType(Type(func_index)); + } else { + PushType(Type::FuncRef); + } return Result::Ok; } |