diff options
Diffstat (limited to 'src/wasm-stack.h')
-rw-r--r-- | src/wasm-stack.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/wasm-stack.h b/src/wasm-stack.h index 7564fbcdb..fbd28b0d5 100644 --- a/src/wasm-stack.h +++ b/src/wasm-stack.h @@ -83,8 +83,16 @@ class BinaryInstWriter : public OverriddenVisitor<BinaryInstWriter> { public: BinaryInstWriter(WasmBinaryWriter& parent, BufferWithRandomAccess& o, - Function* func) - : parent(parent), o(o), func(func) {} + Function* func, + bool sourceMap) + : parent(parent), o(o), func(func), sourceMap(sourceMap) {} + + void visit(Expression* curr) { + if (func && !sourceMap) { + parent.writeDebugLocation(curr, func); + } + OverriddenVisitor<BinaryInstWriter>::visit(curr); + } void visitBlock(Block* curr); void visitIf(If* curr); @@ -144,6 +152,8 @@ private: WasmBinaryWriter& parent; BufferWithRandomAccess& o; Function* func = nullptr; + bool sourceMap; + std::vector<Name> breakStack; // type => number of locals of that type in the compact form @@ -758,7 +768,7 @@ public: Function* func = nullptr, bool sourceMap = false) : BinaryenIRWriter<BinaryenIRToBinaryWriter>(func), parent(parent), - writer(parent, o, func), sourceMap(sourceMap) {} + writer(parent, o, func, sourceMap), sourceMap(sourceMap) {} void visit(Expression* curr) { BinaryenIRWriter<BinaryenIRToBinaryWriter>::visit(curr); @@ -833,7 +843,7 @@ public: StackIRToBinaryWriter(WasmBinaryWriter& parent, BufferWithRandomAccess& o, Function* func) - : writer(parent, o, func), func(func) {} + : writer(parent, o, func, false /* sourceMap */), func(func) {} void write(); |