Index: src/wasm/encoder.h |
diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h |
index 2be7fee2993c9aa5dee712c0b3a1f384c89ffdfd..869a09c01121e13892a7da89884686afce2eb936 100644 |
--- a/src/wasm/encoder.h |
+++ b/src/wasm/encoder.h |
@@ -28,8 +28,7 @@ class WasmFunctionEncoder : public ZoneObject { |
void Serialize(byte* buffer, byte** header, byte** body) const; |
private: |
- WasmFunctionEncoder(Zone* zone, LocalType return_type, bool exported, |
- bool external); |
+ WasmFunctionEncoder(Zone* zone, LocalType return_type, bool exported); |
friend class WasmFunctionBuilder; |
uint16_t signature_index_; |
ZoneVector<LocalType> params_; |
@@ -38,11 +37,10 @@ class WasmFunctionEncoder : public ZoneObject { |
uint16_t local_f32_count_; |
uint16_t local_f64_count_; |
bool exported_; |
- bool external_; |
ZoneVector<uint8_t> body_; |
ZoneVector<char> name_; |
- bool HasName() const { return (exported_ || external_) && name_.size() > 0; } |
+ bool HasName() const { return exported_ && name_.size() > 0; } |
}; |
class WasmFunctionBuilder : public ZoneObject { |
@@ -64,8 +62,7 @@ class WasmFunctionBuilder : public ZoneObject { |
uint32_t EmitEditableVarIntImmediate(); |
void EditVarIntImmediate(uint32_t offset, const uint32_t immediate); |
void Exported(uint8_t flag); |
- void External(uint8_t flag); |
- void SetName(const unsigned char* name, int name_length); |
+ void SetName(const char* name, int name_length); |
WasmFunctionEncoder* Build(Zone* zone, WasmModuleBuilder* mb) const; |
private: |
@@ -75,7 +72,6 @@ class WasmFunctionBuilder : public ZoneObject { |
struct Type; |
ZoneVector<Type> locals_; |
uint8_t exported_; |
- uint8_t external_; |
ZoneVector<uint8_t> body_; |
ZoneVector<uint32_t> local_indices_; |
ZoneVector<char> name_; |
@@ -109,6 +105,12 @@ class WasmModuleIndex : public ZoneObject { |
const byte* end_; |
}; |
+struct WasmFunctionImport { |
+ uint32_t sig_index; |
+ const char* name; |
+ int name_length; |
+}; |
+ |
class WasmModuleWriter : public ZoneObject { |
public: |
WasmModuleIndex* WriteTo(Zone* zone) const; |
@@ -116,6 +118,7 @@ class WasmModuleWriter : public ZoneObject { |
private: |
friend class WasmModuleBuilder; |
explicit WasmModuleWriter(Zone* zone); |
+ ZoneVector<WasmFunctionImport> imports_; |
ZoneVector<WasmFunctionEncoder*> functions_; |
ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
ZoneVector<FunctionSig*> signatures_; |
@@ -127,13 +130,14 @@ class WasmModuleWriter : public ZoneObject { |
class WasmModuleBuilder : public ZoneObject { |
public: |
explicit WasmModuleBuilder(Zone* zone); |
- uint16_t AddFunction(); |
+ uint32_t AddFunction(); |
uint32_t AddGlobal(MachineType type, bool exported); |
WasmFunctionBuilder* FunctionAt(size_t index); |
void AddDataSegment(WasmDataSegmentEncoder* data); |
- uint16_t AddSignature(FunctionSig* sig); |
+ uint32_t AddSignature(FunctionSig* sig); |
void AddIndirectFunction(uint16_t index); |
void MarkStartFunction(uint16_t index); |
+ uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
WasmModuleWriter* Build(Zone* zone); |
struct CompareFunctionSigs { |
@@ -144,6 +148,7 @@ class WasmModuleBuilder : public ZoneObject { |
private: |
Zone* zone_; |
ZoneVector<FunctionSig*> signatures_; |
+ ZoneVector<WasmFunctionImport> imports_; |
ZoneVector<WasmFunctionBuilder*> functions_; |
ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
ZoneVector<uint16_t> indirect_functions_; |