summaryrefslogtreecommitdiff
path: root/src/ir.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir.cc')
-rw-r--r--src/ir.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ir.cc b/src/ir.cc
index 8482f281..ad9ae4bd 100644
--- a/src/ir.cc
+++ b/src/ir.cc
@@ -134,6 +134,21 @@ bool Module::IsImport(ExternalKind kind, const Var& var) const {
}
}
+Type Func::GetLocalType(Index index) const {
+ Index num_params = decl.GetNumParams();
+ if (index < num_params) {
+ return GetParamType(index);
+ } else {
+ index -= num_params;
+ assert(index < local_types.size());
+ return local_types[index];
+ }
+}
+
+Type Func::GetLocalType(const Var& var) const {
+ return GetLocalType(GetLocalIndex(var));
+}
+
Index Func::GetLocalIndex(const Var& var) const {
if (var.is_index()) {
return var.index();
@@ -177,6 +192,10 @@ Global* Module::GetGlobal(const Var& var) {
return globals[index];
}
+const Table* Module::GetTable(const Var& var) const {
+ return const_cast<Module*>(this)->GetTable(var);
+}
+
Table* Module::GetTable(const Var& var) {
Index index = table_bindings.FindIndex(var);
if (index >= tables.size()) {
@@ -185,6 +204,10 @@ Table* Module::GetTable(const Var& var) {
return tables[index];
}
+const Memory* Module::GetMemory(const Var& var) const {
+ return const_cast<Module*>(this)->GetMemory(var);
+}
+
Memory* Module::GetMemory(const Var& var) {
Index index = memory_bindings.FindIndex(var);
if (index >= memories.size()) {