summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r--src/wasm-builder.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index e451f9e2b..4591c9c0d 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -54,13 +54,15 @@ public:
for (auto& param : params) {
func->params.push_back(param.type);
- func->localIndices[param.name] = func->localNames.size();
- func->localNames.push_back(param.name);
+ Index index = func->localNames.size();
+ func->localIndices[param.name] = index;
+ func->localNames[index] = param.name;
}
for (auto& var : vars) {
func->vars.push_back(var.type);
- func->localIndices[var.name] = func->localNames.size();
- func->localNames.push_back(var.name);
+ Index index = func->localNames.size();
+ func->localIndices[var.name] = index;
+ func->localNames[index] = var.name;
}
return func;
@@ -321,15 +323,17 @@ public:
func->params.push_back(type);
Index index = func->localNames.size();
func->localIndices[name] = index;
- func->localNames.push_back(name);
+ func->localNames[index] = name;
return index;
}
static Index addVar(Function* func, Name name, WasmType type) {
// always ok to add a var, it does not affect other indices
Index index = func->getNumLocals();
- if (name.is()) func->localIndices[name] = index;
- func->localNames.push_back(name);
+ if (name.is()) {
+ func->localIndices[name] = index;
+ func->localNames[index] = name;
+ }
func->vars.emplace_back(type);
return index;
}