summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck.py5
-rw-r--r--src/s2wasm.h16
2 files changed, 11 insertions, 10 deletions
diff --git a/check.py b/check.py
index 10093a3cc..495abfe50 100755
--- a/check.py
+++ b/check.py
@@ -408,8 +408,9 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']:
print '..', s
wasm = s.replace('.s', '.wast')
full = os.path.join('test', dot_s_dir, s)
- start = ['--start'] if s.startswith('start_') else []
- cmd = [os.path.join('bin', 's2wasm'), full] + start
+ cmd = [os.path.join('bin', 's2wasm'), full]
+ if s.startswith('start_'):
+ cmd.append('--start')
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
assert err == '', 'bad err:' + err
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 5f8ba850f..275cf6a9c 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -39,12 +39,12 @@ class S2WasmBuilder {
const char* s;
bool debug;
bool ignoreUnknownSymbols;
- const std::string &startFunction;
+ Name startFunction;
public:
S2WasmBuilder(AllocatingModule& wasm, const char* input, bool debug,
size_t globalBase, size_t stackAllocation,
- bool ignoreUnknownSymbols, const std::string& startFunction)
+ bool ignoreUnknownSymbols, Name startFunction)
: wasm(wasm),
allocator(wasm.allocator),
debug(debug),
@@ -80,7 +80,7 @@ class S2WasmBuilder {
};
std::vector<Relocation> relocations;
- std::map<Name, Function*> implementedFunctions;
+ std::set<Name> implementedFunctions;
std::map<Name, Name> aliasedFunctions;
std::map<size_t, size_t> addressSegments; // address => segment index
@@ -367,7 +367,7 @@ class S2WasmBuilder {
if (match(".hidden")) mustMatch(name.str);
mustMatch(name.str);
if (match(":")) {
- implementedFunctions.insert({name, nullptr});
+ implementedFunctions.insert(name);
} else if (match("=")) {
Name alias = getAtSeparated();
mustMatch("@FUNCTION");
@@ -487,7 +487,6 @@ class S2WasmBuilder {
};
auto func = allocator.alloc<Function>();
- implementedFunctions[name] = func;
func->name = name;
std::map<Name, WasmType> localTypes;
// params and result
@@ -1174,9 +1173,10 @@ class S2WasmBuilder {
if (functionIndexes.count(name) == 0) {
functionIndexes[name] = wasm.table.names.size();
wasm.table.names.push_back(name);
- if (debug)
+ if (debug) {
std::cerr << "function index: " << name << ": "
<< functionIndexes[name] << '\n';
+ }
}
};
for (auto& relocation : relocations) {
@@ -1198,12 +1198,12 @@ class S2WasmBuilder {
}
}
}
- if (startFunction.size()) {
+ if (!!startFunction) {
if (implementedFunctions.count(startFunction) == 0) {
std::cerr << "Unknown start function: `" << startFunction << "`\n";
abort();
}
- const auto *target = implementedFunctions[startFunction];
+ const auto *target = wasm.functionsMap[startFunction];
Name start("_start");
if (implementedFunctions.count(start) != 0) {
std::cerr << "Start function already present: `" << start << "`\n";