Skip to content

Commit 2dcf466

Browse files
committed
Renames paramenters from binarymap to sourcemap.
1 parent c48c3c6 commit 2dcf466

File tree

8 files changed

+97
-96
lines changed

8 files changed

+97
-96
lines changed

check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def do_asm2wasm_test():
178178
# verify debug info
179179
if 'debugInfo' in asm:
180180
jsmap = 'a.wasm.map'
181-
cmd += ['--binarymap-file', jsmap,
182-
'--binarymap-url', 'http://example.org/' + jsmap,
181+
cmd += ['--source-map', jsmap,
182+
'--source-map-url', 'http://example.org/' + jsmap,
183183
'-o', 'a.wasm']
184184
run_command(cmd)
185185
if not os.path.isfile(jsmap):
@@ -252,7 +252,7 @@ def do_asm2wasm_test():
252252
print '..', t
253253
t = os.path.join(options.binaryen_test, t)
254254
cmd = WASM_DIS + [t]
255-
if os.path.isfile(t + '.map'): cmd += ['-bm', t + '.map']
255+
if os.path.isfile(t + '.map'): cmd += ['--source-map', t + '.map']
256256

257257
actual = run_command(cmd)
258258

src/tools/asm2wasm.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int main(int argc, const char *argv[]) {
3737
bool runOptimizationPasses = false;
3838
Asm2WasmBuilder::TrapMode trapMode = Asm2WasmBuilder::TrapMode::JS;
3939
bool wasmOnly = false;
40-
std::string binaryMapFile;
41-
std::string binaryMapUrl;
40+
std::string sourceMapFilename;
41+
std::string sourceMapUrl;
4242
std::string symbolMap;
4343
bool emitBinary = true;
4444

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

src/tools/wasm-as.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ using namespace wasm;
3030
int main(int argc, const char *argv[]) {
3131
bool debugInfo = false;
3232
std::string symbolMap;
33-
std::string binaryMapFilename;
34-
std::string binaryMapUrl;
33+
std::string sourceMapFilename;
34+
std::string sourceMapUrl;
3535
Options options("wasm-as", "Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)");
3636
options.extra["validate"] = "wasm";
3737
options
@@ -53,12 +53,12 @@ int main(int argc, const char *argv[]) {
5353
.add("--debuginfo", "-g", "Emit names section and debug info",
5454
Options::Arguments::Zero,
5555
[&](Options *o, const std::string &arguments) { debugInfo = true; })
56-
.add("--binarymap-file", "-bm", "Emit binary map to the specified file",
56+
.add("--source-map", "-sm", "Emit source map to the specified file",
5757
Options::Arguments::One,
58-
[&binaryMapFilename](Options *o, const std::string &argument) { binaryMapFilename = argument; })
59-
.add("--binarymap-url", "-bu", "Use specified string as binary map URL",
58+
[&sourceMapFilename](Options *o, const std::string &argument) { sourceMapFilename = argument; })
59+
.add("--source-map-url", "-su", "Use specified string as source map URL",
6060
Options::Arguments::One,
61-
[&binaryMapUrl](Options *o, const std::string &argument) { binaryMapUrl = argument; })
61+
[&sourceMapUrl](Options *o, const std::string &argument) { sourceMapUrl = argument; })
6262
.add("--symbolmap", "-s", "Emit a symbol map (indexes => names)",
6363
Options::Arguments::One,
6464
[&](Options *o, const std::string &argument) { symbolMap = argument; })
@@ -96,20 +96,20 @@ int main(int argc, const char *argv[]) {
9696
WasmBinaryWriter writer(&wasm, buffer, options.debug);
9797
// if debug info is used, then we want to emit the names section
9898
writer.setNamesSection(debugInfo);
99-
std::unique_ptr<std::ofstream> binaryMapStream = nullptr;
100-
if (binaryMapFilename.size()) {
101-
binaryMapStream = make_unique<std::ofstream>();
102-
binaryMapStream->open(binaryMapFilename);
103-
writer.setBinaryMap(binaryMapStream.get(), binaryMapUrl);
99+
std::unique_ptr<std::ofstream> sourceMapStream = nullptr;
100+
if (sourceMapFilename.size()) {
101+
sourceMapStream = make_unique<std::ofstream>();
102+
sourceMapStream->open(sourceMapFilename);
103+
writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
104104
}
105105
if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap);
106106
writer.write();
107107

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

115115
if (options.debug) std::cerr << "Done." << std::endl;

src/tools/wasm-dis.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ using namespace cashew;
2828
using namespace wasm;
2929

3030
int main(int argc, const char *argv[]) {
31-
std::string binaryMapFilename;
31+
std::string sourceMapFilename;
3232
Options options("wasm-dis", "Un-assemble a .wasm (WebAssembly binary format) into a .wast (WebAssembly text format)");
3333
options.add("--output", "-o", "Output file (stdout if not specified)",
3434
Options::Arguments::One,
3535
[](Options *o, const std::string &argument) {
3636
o->extra["output"] = argument;
3737
Colors::disable();
3838
})
39-
.add("--binarymap-file", "-bm", "Consume binary map from the specified file to add location information",
39+
.add("--source-map", "-sm", "Consume source map from the specified file to add location information",
4040
Options::Arguments::One,
41-
[&binaryMapFilename](Options *o, const std::string &argument) { binaryMapFilename = argument; })
41+
[&sourceMapFilename](Options *o, const std::string &argument) { sourceMapFilename = argument; })
4242
.add_positional("INFILE", Options::Arguments::One,
4343
[](Options *o, const std::string &argument) {
4444
o->extra["infile"] = argument;
@@ -50,16 +50,16 @@ int main(int argc, const char *argv[]) {
5050
if (options.debug) std::cerr << "parsing binary..." << std::endl;
5151
Module wasm;
5252
try {
53-
std::unique_ptr<std::ifstream> binaryMapStream;
53+
std::unique_ptr<std::ifstream> sourceMapStream;
5454
WasmBinaryBuilder parser(wasm, input, options.debug);
55-
if (binaryMapFilename.size()) {
56-
binaryMapStream = make_unique<std::ifstream>();
57-
binaryMapStream->open(binaryMapFilename);
58-
parser.setDebugLocations(binaryMapStream.get());
55+
if (sourceMapFilename.size()) {
56+
sourceMapStream = make_unique<std::ifstream>();
57+
sourceMapStream->open(sourceMapFilename);
58+
parser.setDebugLocations(sourceMapStream.get());
5959
}
6060
parser.read();
61-
if (binaryMapStream) {
62-
binaryMapStream->close();
61+
if (sourceMapStream) {
62+
sourceMapStream->close();
6363
}
6464
} catch (ParseException& p) {
6565
p.dump(std::cerr);

src/wasm-binary.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
538538
Function* currFunction = nullptr;
539539
bool debug;
540540
bool debugInfo = true;
541-
std::ostream* binaryMap = nullptr;
542-
std::string binaryMapUrl;
541+
std::ostream* sourceMap = nullptr;
542+
std::string sourceMapUrl;
543543
std::string symbolMap;
544544

545545
MixedArena allocator;
@@ -551,9 +551,9 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
551551
}
552552

553553
void setNamesSection(bool set) { debugInfo = set; }
554-
void setBinaryMap(std::ostream* set, std::string url) {
555-
binaryMap = set;
556-
binaryMapUrl = url;
554+
void setSourceMap(std::ostream* set, std::string url) {
555+
sourceMap = set;
556+
sourceMapUrl = url;
557557
}
558558
void setSymbolMap(std::string set) { symbolMap = set; }
559559

@@ -593,8 +593,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
593593
void writeSourceMapUrl();
594594
void writeSymbolMap();
595595

596-
void writeBinaryMapProlog();
597-
void writeBinaryMapEpilog();
596+
void writeSourceMapProlog();
597+
void writeSourceMapEpilog();
598598
void writeDebugLocation(size_t offset, const Function::DebugLocation& loc);
599599

600600
// helpers
@@ -623,8 +623,8 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
623623
size_t lastBytecodeOffset;
624624

625625
void visit(Expression* curr) {
626-
if (binaryMap && currFunction) {
627-
// Dump the binaryMap debug info
626+
if (sourceMap && currFunction) {
627+
// Dump the sourceMap debug info
628628
auto& debugLocations = currFunction->debugLocations;
629629
auto iter = debugLocations.find(curr);
630630
if (iter != debugLocations.end() && iter->second != lastDebugLocation) {
@@ -668,7 +668,7 @@ class WasmBinaryBuilder {
668668
MixedArena& allocator;
669669
std::vector<char>& input;
670670
bool debug;
671-
std::istream* binaryMap;
671+
std::istream* sourceMap;
672672
std::pair<uint32_t, Function::DebugLocation> nextDebugLocation;
673673

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

680680
public:
681-
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) {}
681+
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) {}
682682

683683
void read();
684684
void readUserSection(size_t payloadLen);
@@ -768,13 +768,13 @@ class WasmBinaryBuilder {
768768
void readNames(size_t);
769769

770770
// Debug information reading helpers
771-
void setDebugLocations(std::istream* binaryMap_) {
772-
binaryMap = binaryMap_;
771+
void setDebugLocations(std::istream* sourceMap_) {
772+
sourceMap = sourceMap_;
773773
}
774774
Function::DebugLocation debugLocation;
775775
std::unordered_map<std::string, Index> debugInfoFileIndices;
776776
void readNextDebugLocation();
777-
void readBinaryMapHeader();
777+
void readSourceMapHeader();
778778

779779
// AST reading
780780
int depth = 0; // only for debugging

src/wasm-io.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class ModuleWriter : public ModuleIO {
4848
bool binary = true;
4949
bool debugInfo = false;
5050
std::string symbolMap;
51-
std::string binaryMapFilename;
52-
std::string binaryMapUrl;
51+
std::string sourceMapFilename;
52+
std::string sourceMapUrl;
5353

5454
public:
5555
void setBinary(bool binary_) { binary = binary_; }
5656
void setDebugInfo(bool debugInfo_) { debugInfo = debugInfo_; }
5757
void setSymbolMap(std::string symbolMap_) { symbolMap = symbolMap_; }
58-
void setBinaryMapFilename(std::string binaryMapFilename_) { binaryMapFilename = binaryMapFilename_; }
59-
void setBinaryMapUrl(std::string binaryMapUrl_) { binaryMapUrl = binaryMapUrl_; }
58+
void setSourceMapFilename(std::string sourceMapFilename_) { sourceMapFilename = sourceMapFilename_; }
59+
void setSourceMapUrl(std::string sourceMapUrl_) { sourceMapUrl = sourceMapUrl_; }
6060

6161
// write text
6262
void writeText(Module& wasm, std::string filename);

0 commit comments

Comments
 (0)