Index: src/wasm/encoder.h |
diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h |
index f24a847700ff52ceb3121a0b3dcdd86e82d8d61d..8f0fd49bdd58031b45ec83cb0043ca06115a509e 100644 |
--- a/src/wasm/encoder.h |
+++ b/src/wasm/encoder.h |
@@ -121,21 +121,18 @@ |
void Emit(WasmOpcode opcode); |
void EmitGetLocal(uint32_t index); |
void EmitSetLocal(uint32_t index); |
- void EmitTeeLocal(uint32_t index); |
void EmitI32Const(int32_t val); |
void EmitWithU8(WasmOpcode opcode, const byte immediate); |
void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); |
void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); |
void SetExported(); |
void SetName(const char* name, int name_length); |
- |
+ bool exported() { return exported_; } |
+ |
+ // Writing methods. |
void WriteSignature(ZoneBuffer& buffer) const; |
- void WriteExport(ZoneBuffer& buffer) const; |
+ void WriteExport(ZoneBuffer& buffer, uint32_t func_index) const; |
void WriteBody(ZoneBuffer& buffer) const; |
- |
- bool exported() { return exported_; } |
- uint32_t func_index() { return func_index_; } |
- FunctionSig* signature(); |
private: |
explicit WasmFunctionBuilder(WasmModuleBuilder* builder); |
@@ -145,7 +142,6 @@ |
LocalDeclEncoder locals_; |
uint32_t signature_index_; |
bool exported_; |
- uint32_t func_index_; |
ZoneVector<uint8_t> body_; |
ZoneVector<char> name_; |
ZoneVector<uint32_t> i32_temps_; |
@@ -216,17 +212,14 @@ |
explicit WasmModuleBuilder(Zone* zone); |
// Building methods. |
- uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
- void SetImportName(uint32_t index, const char* name, int name_length) { |
- imports_[index].name = name; |
- imports_[index].name_length = name_length; |
- } |
- WasmFunctionBuilder* AddFunction(FunctionSig* sig = nullptr); |
- uint32_t AddGlobal(LocalType type, bool exported, bool mutability = true); |
+ uint32_t AddFunction(); |
+ uint32_t AddGlobal(LocalType type, bool exported); |
+ WasmFunctionBuilder* FunctionAt(size_t index); |
void AddDataSegment(WasmDataSegmentEncoder* data); |
uint32_t AddSignature(FunctionSig* sig); |
void AddIndirectFunction(uint32_t index); |
- void MarkStartFunction(WasmFunctionBuilder* builder); |
+ void MarkStartFunction(uint32_t index); |
+ uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
// Writing methods. |
void WriteTo(ZoneBuffer& buffer) const; |
@@ -238,24 +231,17 @@ |
Zone* zone() { return zone_; } |
- FunctionSig* GetSignature(uint32_t index) { return signatures_[index]; } |
- |
- private: |
- friend class WasmFunctionBuilder; |
+ private: |
Zone* zone_; |
ZoneVector<FunctionSig*> signatures_; |
ZoneVector<WasmFunctionImport> imports_; |
ZoneVector<WasmFunctionBuilder*> functions_; |
ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
ZoneVector<uint32_t> indirect_functions_; |
- ZoneVector<std::tuple<LocalType, bool, bool>> globals_; |
+ ZoneVector<std::pair<LocalType, bool>> globals_; |
SignatureMap signature_map_; |
int start_function_index_; |
}; |
- |
-inline FunctionSig* WasmFunctionBuilder::signature() { |
- return builder_->signatures_[signature_index_]; |
-} |
} // namespace wasm |
} // namespace internal |