Skip to content

Commit

Permalink
Renames paramenters from binarymap to sourcemap.
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed May 23, 2017
1 parent db10f1a commit 9facd16
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 96 deletions.
6 changes: 3 additions & 3 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def do_asm2wasm_test():
# verify debug info
if 'debugInfo' in asm:
jsmap = 'a.wasm.map'
cmd += ['--binarymap-file', jsmap,
'--binarymap-url', 'http://example.org/' + jsmap,
cmd += ['--source-map', jsmap,
'--source-map-url', 'http://example.org/' + jsmap,
'-o', 'a.wasm']
run_command(cmd)
if not os.path.isfile(jsmap):
Expand Down Expand Up @@ -252,7 +252,7 @@ def do_asm2wasm_test():
print '..', t
t = os.path.join(options.binaryen_test, t)
cmd = WASM_DIS + [t]
if os.path.isfile(t + '.map'): cmd += ['-bm', t + '.map']
if os.path.isfile(t + '.map'): cmd += ['--source-map', t + '.map']

actual = run_command(cmd)

Expand Down
18 changes: 9 additions & 9 deletions src/tools/asm2wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ int main(int argc, const char *argv[]) {
bool runOptimizationPasses = false;
Asm2WasmBuilder::TrapMode trapMode = Asm2WasmBuilder::TrapMode::JS;
bool wasmOnly = false;
std::string binaryMapFile;
std::string binaryMapUrl;
std::string sourceMapFilename;
std::string sourceMapUrl;
std::string symbolMap;
bool emitBinary = true;

Expand Down Expand Up @@ -106,12 +106,12 @@ int main(int argc, const char *argv[]) {
.add("--debuginfo", "-g", "Emit names section in wasm binary (or full debuginfo in wast)",
Options::Arguments::Zero,
[&](Options *o, const std::string &arguments) { passOptions.debugInfo = true; })
.add("--binarymap-file", "-bm", "Emit binary map (if using binary output) to the specified file",
.add("--source-map", "-sm", "Emit source map (if using binary output) to the specified file",
Options::Arguments::One,
[&binaryMapFile](Options *o, const std::string &argument) { binaryMapFile = argument; })
.add("--binarymap-url", "-bu", "Use specified string as binary map URL",
[&sourceMapFilename](Options *o, const std::string &argument) { sourceMapFilename = argument; })
.add("--source-map-url", "-su", "Use specified string as source map URL",
Options::Arguments::One,
[&binaryMapUrl](Options *o, const std::string &argument) { binaryMapUrl = argument; })
[&sourceMapUrl](Options *o, const std::string &argument) { sourceMapUrl = argument; })
.add("--symbolmap", "-s", "Emit a symbol map (indexes => names)",
Options::Arguments::One,
[&](Options *o, const std::string &argument) { symbolMap = argument; })
Expand Down Expand Up @@ -142,7 +142,7 @@ int main(int argc, const char *argv[]) {
Asm2WasmPreProcessor pre;
// wasm binaries can contain a names section, but not full debug info --
// debug info is disabled if a map file is not specified with wasm binary
pre.debugInfo = passOptions.debugInfo && (!emitBinary || binaryMapFile.size());
pre.debugInfo = passOptions.debugInfo && (!emitBinary || sourceMapFilename.size());
auto input(
read_file<std::vector<char>>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release));
char *start = pre.process(input.data());
Expand Down Expand Up @@ -210,8 +210,8 @@ int main(int argc, const char *argv[]) {
writer.setSymbolMap(symbolMap);
writer.setBinary(emitBinary);
if (emitBinary) {
writer.setBinaryMapFilename(binaryMapFile);
writer.setBinaryMapUrl(binaryMapUrl);
writer.setSourceMapFilename(sourceMapFilename);
writer.setSourceMapUrl(sourceMapUrl);
}
writer.write(wasm, options.extra["output"]);

Expand Down
26 changes: 13 additions & 13 deletions src/tools/wasm-as.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ using namespace wasm;
int main(int argc, const char *argv[]) {
bool debugInfo = false;
std::string symbolMap;
std::string binaryMapFilename;
std::string binaryMapUrl;
std::string sourceMapFilename;
std::string sourceMapUrl;
Options options("wasm-as", "Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)");
options.extra["validate"] = "wasm";
options
Expand All @@ -53,12 +53,12 @@ int main(int argc, const char *argv[]) {
.add("--debuginfo", "-g", "Emit names section and debug info",
Options::Arguments::Zero,
[&](Options *o, const std::string &arguments) { debugInfo = true; })
.add("--binarymap-file", "-bm", "Emit binary map to the specified file",
.add("--source-map", "-sm", "Emit source map to the specified file",
Options::Arguments::One,
[&binaryMapFilename](Options *o, const std::string &argument) { binaryMapFilename = argument; })
.add("--binarymap-url", "-bu", "Use specified string as binary map URL",
[&sourceMapFilename](Options *o, const std::string &argument) { sourceMapFilename = argument; })
.add("--source-map-url", "-su", "Use specified string as source map URL",
Options::Arguments::One,
[&binaryMapUrl](Options *o, const std::string &argument) { binaryMapUrl = argument; })
[&sourceMapUrl](Options *o, const std::string &argument) { sourceMapUrl = argument; })
.add("--symbolmap", "-s", "Emit a symbol map (indexes => names)",
Options::Arguments::One,
[&](Options *o, const std::string &argument) { symbolMap = argument; })
Expand Down Expand Up @@ -95,20 +95,20 @@ int main(int argc, const char *argv[]) {
BufferWithRandomAccess buffer(options.debug);
WasmBinaryWriter writer(&wasm, buffer, options.debug);
writer.setNamesSection(debugInfo);
std::unique_ptr<std::ofstream> binaryMapStream = nullptr;
if (binaryMapFilename.size()) {
binaryMapStream = make_unique<std::ofstream>();
binaryMapStream->open(binaryMapFilename);
writer.setBinaryMap(binaryMapStream.get(), binaryMapUrl);
std::unique_ptr<std::ofstream> sourceMapStream = nullptr;
if (sourceMapFilename.size()) {
sourceMapStream = make_unique<std::ofstream>();
sourceMapStream->open(sourceMapFilename);
writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
}
if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap);
writer.write();

if (options.debug) std::cerr << "writing to output..." << std::endl;
Output output(options.extra["output"], Flags::Binary, options.debug ? Flags::Debug : Flags::Release);
buffer.writeTo(output);
if (binaryMapStream) {
binaryMapStream->close();
if (sourceMapStream) {
sourceMapStream->close();
}

if (options.debug) std::cerr << "Done." << std::endl;
Expand Down
20 changes: 10 additions & 10 deletions src/tools/wasm-dis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ using namespace cashew;
using namespace wasm;

int main(int argc, const char *argv[]) {
std::string binaryMapFilename;
std::string sourceMapFilename;
Options options("wasm-dis", "Un-assemble a .wasm (WebAssembly binary format) into a .wast (WebAssembly text format)");
options.add("--output", "-o", "Output file (stdout if not specified)",
Options::Arguments::One,
[](Options *o, const std::string &argument) {
o->extra["output"] = argument;
Colors::disable();
})
.add("--binarymap-file", "-bm", "Consume binary map from the specified file to add location information",
.add("--source-map", "-sm", "Consume source map from the specified file to add location information",
Options::Arguments::One,
[&binaryMapFilename](Options *o, const std::string &argument) { binaryMapFilename = argument; })
[&sourceMapFilename](Options *o, const std::string &argument) { sourceMapFilename = argument; })
.add_positional("INFILE", Options::Arguments::One,
[](Options *o, const std::string &argument) {
o->extra["infile"] = argument;
Expand All @@ -50,16 +50,16 @@ int main(int argc, const char *argv[]) {
if (options.debug) std::cerr << "parsing binary..." << std::endl;
Module wasm;
try {
std::unique_ptr<std::ifstream> binaryMapStream;
std::unique_ptr<std::ifstream> sourceMapStream;
WasmBinaryBuilder parser(wasm, input, options.debug);
if (binaryMapFilename.size()) {
binaryMapStream = make_unique<std::ifstream>();
binaryMapStream->open(binaryMapFilename);
parser.setDebugLocations(binaryMapStream.get());
if (sourceMapFilename.size()) {
sourceMapStream = make_unique<std::ifstream>();
sourceMapStream->open(sourceMapFilename);
parser.setDebugLocations(sourceMapStream.get());
}
parser.read();
if (binaryMapStream) {
binaryMapStream->close();
if (sourceMapStream) {
sourceMapStream->close();
}
} catch (ParseException& p) {
p.dump(std::cerr);
Expand Down
28 changes: 14 additions & 14 deletions src/wasm-binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
Function* currFunction = nullptr;
bool debug;
bool debugInfo = true;
std::ostream* binaryMap = nullptr;
std::string binaryMapUrl;
std::ostream* sourceMap = nullptr;
std::string sourceMapUrl;
std::string symbolMap;

MixedArena allocator;
Expand All @@ -551,9 +551,9 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
}

void setNamesSection(bool set) { debugInfo = set; }
void setBinaryMap(std::ostream* set, std::string url) {
binaryMap = set;
binaryMapUrl = url;
void setSourceMap(std::ostream* set, std::string url) {
sourceMap = set;
sourceMapUrl = url;
}
void setSymbolMap(std::string set) { symbolMap = set; }

Expand Down Expand Up @@ -593,8 +593,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
void writeSourceMapUrl();
void writeSymbolMap();

void writeBinaryMapProlog();
void writeBinaryMapEpilog();
void writesourceMapProlog();
void writesourceMapEpilog();
void writeDebugLocation(size_t offset, const Function::DebugLocation& loc);

// helpers
Expand Down Expand Up @@ -623,8 +623,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
size_t lastBytecodeOffset;

void visit(Expression* curr) {
if (binaryMap && currFunction) {
// Dump the binaryMap debug info
if (sourceMap && currFunction) {
// Dump the sourceMap debug info
auto& debugLocations = currFunction->debugLocations;
auto iter = debugLocations.find(curr);
if (iter != debugLocations.end() && iter->second != lastDebugLocation) {
Expand Down Expand Up @@ -668,7 +668,7 @@ class WasmBinaryBuilder {
MixedArena& allocator;
std::vector<char>& input;
bool debug;
std::istream* binaryMap;
std::istream* sourceMap;
std::pair<uint32_t, Function::DebugLocation> nextDebugLocation;

size_t pos = 0;
Expand All @@ -678,7 +678,7 @@ class WasmBinaryBuilder {
std::set<BinaryConsts::Section> seenSections;

public:
WasmBinaryBuilder(Module& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug), binaryMap(nullptr), nextDebugLocation(0, {0,0,0}), useDebugLocation(false) {}
WasmBinaryBuilder(Module& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug), sourceMap(nullptr), nextDebugLocation(0, {0,0,0}), useDebugLocation(false) {}

void read();
void readUserSection(size_t payloadLen);
Expand Down Expand Up @@ -768,13 +768,13 @@ class WasmBinaryBuilder {
void readNames(size_t);

// Debug information reading helpers
void setDebugLocations(std::istream* binaryMap_) {
binaryMap = binaryMap_;
void setDebugLocations(std::istream* sourceMap_) {
sourceMap = sourceMap_;
}
Function::DebugLocation debugLocation;
std::unordered_map<std::string, Index> debugInfoFileIndices;
void readNextDebugLocation();
void readBinaryMapHeader();
void readSourceMapHeader();

// AST reading
int depth = 0; // only for debugging
Expand Down
8 changes: 4 additions & 4 deletions src/wasm-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class ModuleWriter : public ModuleIO {
bool binary = true;
bool debugInfo = false;
std::string symbolMap;
std::string binaryMapFilename;
std::string binaryMapUrl;
std::string sourceMapFilename;
std::string sourceMapUrl;

public:
void setBinary(bool binary_) { binary = binary_; }
void setDebugInfo(bool debugInfo_) { debugInfo = debugInfo_; }
void setSymbolMap(std::string symbolMap_) { symbolMap = symbolMap_; }
void setBinaryMapFilename(std::string binaryMapFilename_) { binaryMapFilename = binaryMapFilename_; }
void setBinaryMapUrl(std::string binaryMapUrl_) { binaryMapUrl = binaryMapUrl_; }
void setSourceMapFilename(std::string sourceMapFilename_) { sourceMapFilename = sourceMapFilename_; }
void setSourceMapUrl(std::string sourceMapUrl_) { sourceMapUrl = sourceMapUrl_; }

// write text
void writeText(Module& wasm, std::string filename);
Expand Down
Loading

0 comments on commit 9facd16

Please sign in to comment.