summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h28
-rw-r--r--src/asm_v_wasm.h2
-rw-r--r--src/asmjs/asm_v_wasm.cpp6
-rw-r--r--src/passes/Print.cpp8
-rw-r--r--src/passes/RemoveImports.cpp9
-rw-r--r--src/wasm-binary.h29
-rw-r--r--src/wasm-builder.h2
-rw-r--r--src/wasm-linker.cpp6
-rw-r--r--src/wasm-linker.h2
-rw-r--r--src/wasm-s-parser.h10
-rw-r--r--src/wasm-traversal.h18
-rw-r--r--src/wasm.h34
-rw-r--r--src/wasm2asm.h10
13 files changed, 82 insertions, 82 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index ae24358d7..f39c50871 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -216,13 +216,13 @@ private:
// function types. we fill in this information as we see
// uses, in the first pass
- std::map<IString, FunctionType*> importedFunctionTypes;
+ std::map<IString, std::unique_ptr<FunctionType>> importedFunctionTypes;
std::map<IString, std::vector<CallImport*>> importedFunctionCalls;
void noteImportedFunctionCall(Ref ast, WasmType resultType, AsmData *asmData, CallImport* call) {
assert(ast[0] == CALL && ast[1][0] == NAME);
IString importName = ast[1][1]->getIString();
- auto* type = allocator.alloc<FunctionType>();
+ std::unique_ptr<FunctionType> type = make_unique<FunctionType>();
type->name = IString((std::string("type$") + importName.str).c_str(), false); // TODO: make a list of such types
type->result = resultType;
Ref args = ast[2];
@@ -231,7 +231,7 @@ private:
}
// if we already saw this signature, verify it's the same (or else handle that)
if (importedFunctionTypes.find(importName) != importedFunctionTypes.end()) {
- FunctionType* previous = importedFunctionTypes[importName];
+ FunctionType* previous = importedFunctionTypes[importName].get();
#if 0
std::cout << "compare " << importName.str << "\nfirst: ";
type.print(std::cout, 0);
@@ -254,7 +254,7 @@ private:
}
}
} else {
- importedFunctionTypes[importName] = type;
+ importedFunctionTypes[importName].swap(type);
}
importedFunctionCalls[importName].push_back(call);
}
@@ -508,7 +508,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
}
}
}
- auto import = allocator.alloc<Import>();
+ auto import = new Import();
import->name = name;
import->module = moduleName;
import->base = imported[2]->getIString();
@@ -678,7 +678,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
getTempRet0 = value;
}
assert(wasm.checkFunction(value));
- auto export_ = allocator.alloc<Export>();
+ auto export_ = new Export;
export_->name = key;
export_->value = value;
wasm.addExport(export_);
@@ -690,7 +690,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
std::vector<IString> toErase;
- for (auto* import : wasm.imports) {
+ for (auto& import : wasm.imports) {
IString name = import->name;
if (importedFunctionTypes.find(name) != importedFunctionTypes.end()) {
// special math builtins
@@ -699,7 +699,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
import->type = builtin;
continue;
}
- import->type = ensureFunctionType(getSig(importedFunctionTypes[name]), &wasm);
+ import->type = ensureFunctionType(getSig(importedFunctionTypes[name].get()), &wasm);
} else if (import->module != ASM2WASM) { // special-case the special module
// never actually used
toErase.push_back(name);
@@ -714,7 +714,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
for (auto& pair : importedFunctionCalls) {
IString name = pair.first;
auto& list = pair.second;
- auto type = importedFunctionTypes[name];
+ auto type = importedFunctionTypes[name].get();
for (auto* call : list) {
for (size_t i = call->operands.size(); i < type->params.size(); i++) {
auto val = allocator.alloc<Const>();
@@ -754,7 +754,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
{ builder.makeGetLocal(0, i32) }
)
));
- auto export_ = allocator.alloc<Export>();
+ auto export_ = new Export;
export_->name = export_->value = GROW_WASM_MEMORY;
wasm.addExport(export_);
}
@@ -869,7 +869,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
std::cout << '\n';
}
- auto function = allocator.alloc<Function>();
+ auto function = new Function;
function->name = name;
Ref params = ast[2];
Ref body = ast[3];
@@ -1017,7 +1017,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
static bool addedImport = false;
if (!addedImport) {
addedImport = true;
- auto import = allocator.alloc<Import>(); // f64-rem = asm2wasm.f64-rem;
+ auto import = new Import; // f64-rem = asm2wasm.f64-rem;
import->name = F64_REM;
import->module = ASM2WASM;
import->base = F64_REM;
@@ -1055,7 +1055,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
static bool addedImport = false;
if (!addedImport) {
addedImport = true;
- auto import = allocator.alloc<Import>(); // debugger = asm2wasm.debugger;
+ auto import = new Import; // debugger = asm2wasm.debugger;
import->name = DEBUGGER;
import->module = ASM2WASM;
import->base = DEBUGGER;
@@ -1168,7 +1168,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
static bool addedImport = false;
if (!addedImport) {
addedImport = true;
- auto import = allocator.alloc<Import>(); // f64-to-int = asm2wasm.f64-to-int;
+ auto import = new Import; // f64-to-int = asm2wasm.f64-to-int;
import->name = F64_TO_INT;
import->module = ASM2WASM;
import->base = F64_TO_INT;
diff --git a/src/asm_v_wasm.h b/src/asm_v_wasm.h
index cfb4d44d5..52524ecbc 100644
--- a/src/asm_v_wasm.h
+++ b/src/asm_v_wasm.h
@@ -55,7 +55,7 @@ std::string getSig(WasmType result, const ListType& operands) {
WasmType sigToWasmType(char sig);
-FunctionType sigToFunctionType(std::string sig);
+FunctionType* sigToFunctionType(std::string sig);
FunctionType* ensureFunctionType(std::string sig, Module* wasm);
diff --git a/src/asmjs/asm_v_wasm.cpp b/src/asmjs/asm_v_wasm.cpp
index 3e7e0241e..14a7fbdae 100644
--- a/src/asmjs/asm_v_wasm.cpp
+++ b/src/asmjs/asm_v_wasm.cpp
@@ -82,8 +82,8 @@ WasmType sigToWasmType(char sig) {
}
}
-FunctionType* sigToFunctionType(std::string sig, MixedArena& allocator) {
- auto ret = allocator.alloc<FunctionType>();
+FunctionType* sigToFunctionType(std::string sig) {
+ auto ret = new FunctionType;
ret->result = sigToWasmType(sig[0]);
for (size_t i = 1; i < sig.size(); i++) {
ret->params.push_back(sigToWasmType(sig[i]));
@@ -97,7 +97,7 @@ FunctionType* ensureFunctionType(std::string sig, Module* wasm) {
return wasm->getFunctionType(name);
}
// add new type
- auto type = wasm->allocator.alloc<FunctionType>();
+ auto type = new FunctionType;
type->name = name;
type->result = sigToWasmType(sig[0]);
for (size_t i = 1; i < sig.size(); i++) {
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index eb0a6d33b..256968bb7 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -522,17 +522,17 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
}
for (auto& child : curr->functionTypes) {
doIndent(o, indent);
- visitFunctionType(child, true);
+ visitFunctionType(child.get(), true);
o << maybeNewLine;
}
for (auto& child : curr->imports) {
doIndent(o, indent);
- visitImport(child);
+ visitImport(child.get());
o << maybeNewLine;
}
for (auto& child : curr->exports) {
doIndent(o, indent);
- visitExport(child);
+ visitExport(child.get());
o << maybeNewLine;
}
if (curr->table.names.size() > 0) {
@@ -542,7 +542,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
}
for (auto& child : curr->functions) {
doIndent(o, indent);
- visitFunction(child);
+ visitFunction(child.get());
o << maybeNewLine;
}
decIndent();
diff --git a/src/passes/RemoveImports.cpp b/src/passes/RemoveImports.cpp
index 0adb9a448..1ef28292f 100644
--- a/src/passes/RemoveImports.cpp
+++ b/src/passes/RemoveImports.cpp
@@ -48,9 +48,12 @@ struct RemoveImports : public WalkerPass<PostWalker<RemoveImports, Visitor<Remov
}
void visitModule(Module *curr) {
- auto imports = curr->imports; // copy
- for (auto* import : imports) {
- curr->removeImport(import->name);
+ std::vector<Name> names;
+ for (auto& import : curr->imports) {
+ names.push_back(import->name);
+ }
+ for (auto& name : names) {
+ curr->removeImport(name);
}
}
};
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 3f7ad44d4..9d4f567b0 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -447,9 +447,9 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
void prepare() {
// we need function types for all our functions
- for (auto* func : wasm->functions) {
+ for (auto& func : wasm->functions) {
if (func->type.isNull()) {
- func->type = ensureFunctionType(getSig(func), wasm)->name;
+ func->type = ensureFunctionType(getSig(func.get()), wasm)->name;
}
}
}
@@ -523,7 +523,7 @@ public:
if (debug) std::cerr << "== writeSignatures" << std::endl;
auto start = startSection(BinaryConsts::Section::Signatures);
o << U32LEB(wasm->functionTypes.size());
- for (auto* type : wasm->functionTypes) {
+ for (auto& type : wasm->functionTypes) {
if (debug) std::cerr << "write one" << std::endl;
o << int8_t(BinaryConsts::TypeForms::Basic);
o << U32LEB(type->params.size());
@@ -553,7 +553,7 @@ public:
if (debug) std::cerr << "== writeImports" << std::endl;
auto start = startSection(BinaryConsts::Section::ImportTable);
o << U32LEB(wasm->imports.size());
- for (auto* import : wasm->imports) {
+ for (auto& import : wasm->imports) {
if (debug) std::cerr << "write one" << std::endl;
o << U32LEB(getFunctionTypeIndex(import->type->name));
writeInlineString(import->module.str);
@@ -606,7 +606,7 @@ public:
if (debug) std::cerr << "== writeFunctionSignatures" << std::endl;
auto start = startSection(BinaryConsts::Section::FunctionSignatures);
o << U32LEB(wasm->functions.size());
- for (auto* curr : wasm->functions) {
+ for (auto& curr : wasm->functions) {
if (debug) std::cerr << "write one" << std::endl;
o << U32LEB(getFunctionTypeIndex(curr->type));
}
@@ -623,7 +623,7 @@ public:
if (debug) std::cerr << "write one at" << o.size() << std::endl;
size_t sizePos = writeU32LEBPlaceholder();
size_t start = o.size();
- Function* function = wasm->functions[i];
+ Function* function = wasm->getFunction(i);
mappedLocals.clear();
numLocalsByType.clear();
if (debug) std::cerr << "writing" << function->name << std::endl;
@@ -654,7 +654,7 @@ public:
if (debug) std::cerr << "== writeexports" << std::endl;
auto start = startSection(BinaryConsts::Section::ExportTable);
o << U32LEB(wasm->exports.size());
- for (auto* curr : wasm->exports) {
+ for (auto& curr : wasm->exports) {
if (debug) std::cerr << "write one" << std::endl;
o << U32LEB(getFunctionIndex(curr->value));
writeInlineString(curr->name.str);
@@ -720,7 +720,7 @@ public:
if (debug) std::cerr << "== writeNames" << std::endl;
auto start = startSection(BinaryConsts::Section::Names);
o << U32LEB(wasm->functions.size());
- for (auto* curr : wasm->functions) {
+ for (auto& curr : wasm->functions) {
writeInlineString(curr->name.str);
o << U32LEB(0); // TODO: locals
}
@@ -1354,7 +1354,7 @@ public:
if (debug) std::cerr << "num: " << numTypes << std::endl;
for (size_t i = 0; i < numTypes; i++) {
if (debug) std::cerr << "read one" << std::endl;
- auto curr = allocator.alloc<FunctionType>();
+ auto curr = new FunctionType;
auto form = getInt8();
assert(form == BinaryConsts::TypeForms::Basic);
size_t numParams = getU32LEB();
@@ -1379,11 +1379,11 @@ public:
if (debug) std::cerr << "num: " << num << std::endl;
for (size_t i = 0; i < num; i++) {
if (debug) std::cerr << "read one" << std::endl;
- auto curr = allocator.alloc<Import>();
+ auto curr = new Import;
curr->name = Name(std::string("import$") + std::to_string(i));
auto index = getU32LEB();
assert(index < wasm.functionTypes.size());
- curr->type = wasm.functionTypes[index];
+ curr->type = wasm.getFunctionType(index);
assert(curr->type->name.is());
curr->module = getInlineString();
curr->base = getInlineString();
@@ -1400,8 +1400,7 @@ public:
for (size_t i = 0; i < num; i++) {
if (debug) std::cerr << "read one" << std::endl;
auto index = getU32LEB();
- assert(index < wasm.functionTypes.size());
- functionTypes.push_back(wasm.functionTypes[index]);
+ functionTypes.push_back(wasm.getFunctionType(index));
}
}
@@ -1481,7 +1480,7 @@ public:
if (debug) std::cerr << "num: " << num << std::endl;
for (size_t i = 0; i < num; i++) {
if (debug) std::cerr << "read one" << std::endl;
- auto curr = allocator.alloc<Export>();
+ auto curr = new Export;
auto index = getU32LEB();
assert(index < functionTypes.size());
curr->name = getInlineString();
@@ -1774,7 +1773,7 @@ public:
void visitCallIndirect(CallIndirect *curr) {
if (debug) std::cerr << "zz node: CallIndirect" << std::endl;
auto arity = getU32LEB();
- curr->fullType = wasm.functionTypes[getU32LEB()];
+ curr->fullType = wasm.getFunctionType(getU32LEB());
auto num = curr->fullType->params.size();
assert(num == arity);
curr->operands.resize(num);
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index e25dafc60..5d4c90840 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -45,7 +45,7 @@ public:
WasmType resultType,
std::vector<NameType>&& vars,
Expression* body = nullptr) {
- auto* func = allocator.alloc<Function>();
+ auto* func = new Function;
func->name = name;
func->result = resultType;
func->body = body;
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp
index 6dca9e01b..334ea475d 100644
--- a/src/wasm-linker.cpp
+++ b/src/wasm-linker.cpp
@@ -56,7 +56,7 @@ void Linker::layout() {
Name target = f.first;
// Create an import for the target if necessary.
if (!out.wasm.checkImport(target)) {
- auto import = out.wasm.allocator.alloc<Import>();
+ auto import = new Import;
import->name = import->base = target;
import->module = ENV;
import->type = ensureFunctionType(getSig(*f.second.begin()), &out.wasm);
@@ -154,7 +154,7 @@ void Linker::layout() {
if (out.symbolInfo.implementedFunctions.count(start) != 0) {
Fatal() << "Start function already present: `" << start << "`\n";
}
- auto* func = out.wasm.allocator.alloc<Function>();
+ auto* func = new Function;
func->name = start;
out.wasm.addFunction(func);
exportFunction(start, true);
@@ -254,7 +254,7 @@ void Linker::emscriptenGlue(std::ostream& o) {
// add import, if necessary
if (allSigs.count(sig) == 0) {
allSigs.insert(sig);
- auto import = parent->out.wasm.allocator.alloc<Import>();
+ auto import = new Import;
import->name = import->base = curr->target;
import->module = ENV;
import->type = ensureFunctionType(getSig(curr), &parent->out.wasm);
diff --git a/src/wasm-linker.h b/src/wasm-linker.h
index ab336e581..07f270d69 100644
--- a/src/wasm-linker.h
+++ b/src/wasm-linker.h
@@ -246,7 +246,7 @@ class Linker {
return;
}
if (out.wasm.checkExport(name)) return; // Already exported
- auto exp = out.wasm.allocator.alloc<Export>();
+ auto exp = new Export;
exp->name = exp->value = name;
out.wasm.addExport(exp);
}
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 36dacc627..ccaec82d0 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -1113,14 +1113,14 @@ private:
wasm.memory.exportName = s[1]->str();
return;
}
- auto ex = allocator.alloc<Export>();
+ auto ex = new Export;
ex->name = s[1]->str();
ex->value = s[2]->str();
wasm.addExport(ex);
}
void parseImport(Element& s) {
- auto im = allocator.alloc<Import>();
+ auto im = new Import;
size_t i = 1;
if (s.size() > 3 && s[3]->isStr()) {
im->name = s[i++]->str();
@@ -1131,7 +1131,7 @@ private:
im->module = s[i++]->str();
if (!s[i]->isStr()) onError();
im->base = s[i++]->str();
- FunctionType* type = allocator.alloc<FunctionType>();
+ std::unique_ptr<FunctionType> type = make_unique<FunctionType>();
if (s.size() > i) {
Element& params = *s[i];
IString id = params[0]->str();
@@ -1154,7 +1154,7 @@ private:
type->result = stringToWasmType(result[1]->str());
}
}
- im->type = ensureFunctionType(getSig(type), &wasm);
+ im->type = ensureFunctionType(getSig(type.get()), &wasm);
wasm.addImport(im);
}
@@ -1165,7 +1165,7 @@ private:
}
void parseType(Element& s) {
- auto type = allocator.alloc<FunctionType>();
+ auto type = new FunctionType;
size_t i = 1;
if (s[i]->isStr()) {
type->name = s[i]->str();
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h
index a2e29ea77..59fea2a56 100644
--- a/src/wasm-traversal.h
+++ b/src/wasm-traversal.h
@@ -181,14 +181,14 @@ struct Walker : public VisitorType {
// Dispatch statically through the SubType.
SubType* self = static_cast<SubType*>(this);
- for (auto curr : module->functionTypes) {
- self->visitFunctionType(curr);
+ for (auto& curr : module->functionTypes) {
+ self->visitFunctionType(curr.get());
}
- for (auto curr : module->imports) {
- self->visitImport(curr);
+ for (auto& curr : module->imports) {
+ self->visitImport(curr.get());
}
- for (auto curr : module->exports) {
- self->visitExport(curr);
+ for (auto& curr : module->exports) {
+ self->visitExport(curr.get());
}
auto processFunction = [](SubType* instance, Function* func) {
@@ -201,8 +201,8 @@ struct Walker : public VisitorType {
// if this is not a function-parallel traversal, run
// sequentially
if (!self->isFunctionParallel()) {
- for (auto curr : module->functions) {
- processFunction(self, curr);
+ for (auto& curr : module->functions) {
+ processFunction(self, curr.get());
}
} else {
// execute in parallel on helper threads
@@ -222,7 +222,7 @@ struct Walker : public VisitorType {
if (index >= numFunctions) {
return ThreadWorkState::Finished; // nothing left
}
- Function* curr = module->functions[index];
+ Function* curr = module->functions[index].get();
// do the current task
processFunction(instance, curr);
if (index + 1 == numFunctions) {
diff --git a/src/wasm.h b/src/wasm.h
index 62b551433..0982548a2 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -912,9 +912,9 @@ class FunctionType {
public:
Name name;
WasmType result;
- ArenaVector<WasmType> params;
+ std::vector<WasmType> params;
- FunctionType(MixedArena& allocator) : result(none), params(allocator) {}
+ FunctionType() : result(none) {}
bool operator==(FunctionType& b) {
if (name != b.name) return false; // XXX
@@ -1097,7 +1097,7 @@ public:
std::vector<Name> localNames;
std::map<Name, Index> localIndices;
- Function(MixedArena& allocator) : result(none) {}
+ Function() : result(none) {}
size_t getNumParams() {
return params.size();
@@ -1147,7 +1147,7 @@ public:
class Import {
public:
- Import(MixedArena& allocator) : type(nullptr) {}
+ Import() : type(nullptr) {}
Name name, module, base; // name = module.base
FunctionType* type;
@@ -1155,8 +1155,6 @@ public:
class Export {
public:
- Export(MixedArena& allocator) {}
-
Name name; // exported name
Name value; // internal name
};
@@ -1188,10 +1186,10 @@ public:
class Module {
public:
// wasm contents (generally you shouldn't access these from outside, except maybe for iterating; use add*() and the get() functions)
- std::vector<FunctionType*> functionTypes;
- std::vector<Import*> imports;
- std::vector<Export*> exports;
- std::vector<Function*> functions;
+ std::vector<std::unique_ptr<FunctionType>> functionTypes;
+ std::vector<std::unique_ptr<Import>> imports;
+ std::vector<std::unique_ptr<Export>> exports;
+ std::vector<std::unique_ptr<Function>> functions;
Table table;
Memory memory;
@@ -1209,10 +1207,10 @@ private:
public:
Module() : functionTypeIndex(0), importIndex(0), exportIndex(0), functionIndex(0) {}
- FunctionType* getFunctionType(size_t i) { assert(i < functionTypes.size());return functionTypes[i]; }
- Import* getImport(size_t i) { assert(i < imports.size()); return imports[i]; }
- Export* getExport(size_t i) { assert(i < exports.size()); return exports[i]; }
- Function* getFunction(size_t i) { assert(i < functions.size()); return functions[i]; }
+ FunctionType* getFunctionType(size_t i) { assert(i < functionTypes.size()); return functionTypes[i].get(); }
+ Import* getImport(size_t i) { assert(i < imports.size()); return imports[i].get(); }
+ Export* getExport(size_t i) { assert(i < exports.size()); return exports[i].get(); }
+ Function* getFunction(size_t i) { assert(i < functions.size()); return functions[i].get(); }
FunctionType* getFunctionType(Name name) { assert(functionTypesMap[name]); return functionTypesMap[name]; }
Import* getImport(Name name) { assert(importsMap[name]); return importsMap[name]; }
@@ -1229,7 +1227,7 @@ public:
if (curr->name.isNull()) {
curr->name = numericName;
}
- functionTypes.push_back(curr);
+ functionTypes.push_back(std::unique_ptr<FunctionType>(curr));
functionTypesMap[curr->name] = curr;
functionTypesMap[numericName] = curr;
functionTypeIndex++;
@@ -1239,7 +1237,7 @@ public:
if (curr->name.isNull()) {
curr->name = numericName;
}
- imports.push_back(curr);
+ imports.push_back(std::unique_ptr<Import>(curr));
importsMap[curr->name] = curr;
importsMap[numericName] = curr;
importIndex++;
@@ -1249,7 +1247,7 @@ public:
if (curr->name.isNull()) {
curr->name = numericName;
}
- exports.push_back(curr);
+ exports.push_back(std::unique_ptr<Export>(curr));
exportsMap[curr->name] = curr;
exportsMap[numericName] = curr;
exportIndex++;
@@ -1259,7 +1257,7 @@ public:
if (curr->name.isNull()) {
curr->name = numericName;
}
- functions.push_back(curr);
+ functions.push_back(std::unique_ptr<Function>(curr));
functionsMap[curr->name] = curr;
functionsMap[numericName] = curr;
functionIndex++;
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index 82eb0b1a9..e0b071f9b 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -205,8 +205,8 @@ Ref Wasm2AsmBuilder::processWasm(Module* wasm) {
asmFunc[3]->push_back(ValueBuilder::makeStatement(ValueBuilder::makeString(USE_ASM)));
// create heaps, etc
addBasics(asmFunc[3]);
- for (auto import : wasm->imports) {
- addImport(asmFunc[3], import);
+ for (auto& import : wasm->imports) {
+ addImport(asmFunc[3], import.get());
}
// figure out the table size
tableSize = wasm->table.names.size();
@@ -216,8 +216,8 @@ Ref Wasm2AsmBuilder::processWasm(Module* wasm) {
}
tableSize = pow2ed;
// functions
- for (auto func : wasm->functions) {
- asmFunc[3]->push_back(processFunction(func));
+ for (auto& func : wasm->functions) {
+ asmFunc[3]->push_back(processFunction(func.get()));
}
addTables(asmFunc[3], wasm);
// memory XXX
@@ -320,7 +320,7 @@ void Wasm2AsmBuilder::addTables(Ref ast, Module *wasm) {
void Wasm2AsmBuilder::addExports(Ref ast, Module *wasm) {
Ref exports = ValueBuilder::makeObject();
- for (auto export_ : wasm->exports) {
+ for (auto& export_ : wasm->exports) {
ValueBuilder::appendToObject(exports, fromName(export_->name), ValueBuilder::makeName(fromName(export_->value)));
}
ast->push_back(ValueBuilder::makeStatement(ValueBuilder::makeReturn(exports)));