diff options
-rw-r--r-- | src/binary-reader-linker.cc | 10 | ||||
-rw-r--r-- | src/tools/wasm-link.cc | 20 | ||||
-rw-r--r-- | src/wasm-link.h | 17 |
3 files changed, 17 insertions, 30 deletions
diff --git a/src/binary-reader-linker.cc b/src/binary-reader-linker.cc index 400cbf75..7ad89526 100644 --- a/src/binary-reader-linker.cc +++ b/src/binary-reader-linker.cc @@ -135,8 +135,8 @@ Result BinaryReaderLinker::OnImportFunc(Index import_index, Index sig_index) { binary_->function_imports.emplace_back(); FunctionImport* import = &binary_->function_imports.back(); - import->module_name = string_view_to_string_slice(module_name); - import->name = string_view_to_string_slice(field_name); + import->module_name = module_name.to_string(); + import->name = field_name.to_string(); import->sig_index = sig_index; import->active = true; binary_->active_function_imports++; @@ -151,8 +151,8 @@ Result BinaryReaderLinker::OnImportGlobal(Index import_index, bool mutable_) { binary_->global_imports.emplace_back(); GlobalImport* import = &binary_->global_imports.back(); - import->module_name = string_view_to_string_slice(module_name); - import->name = string_view_to_string_slice(field_name); + import->module_name = module_name.to_string(); + import->name = field_name.to_string(); import->type = type; import->mutable_ = mutable_; binary_->active_global_imports++; @@ -264,7 +264,7 @@ Result BinaryReaderLinker::OnExport(Index index, } binary_->exports.emplace_back(); Export* export_ = &binary_->exports.back(); - export_->name = string_view_to_string_slice(name); + export_->name = name.to_string(); export_->kind = kind; export_->index = item_index; return Result::Ok; diff --git a/src/tools/wasm-link.cc b/src/tools/wasm-link.cc index 66ba6917..89cc73ad 100644 --- a/src/tools/wasm-link.cc +++ b/src/tools/wasm-link.cc @@ -212,10 +212,6 @@ static void write_section_payload(Context* ctx, Section* sec) { ctx->stream.WriteData(payload, sec->payload_size, "section content"); } -static void write_slice(Stream* stream, StringSlice str, const char* desc) { - write_str(stream, string_slice_to_string(str), desc, PrintChars::Yes); -} - #define WRITE_UNKNOWN_SIZE(STREAM) \ { \ Offset fixup_offset = (STREAM)->offset(); \ @@ -262,7 +258,7 @@ static void write_export_section(Context* ctx) { for (const std::unique_ptr<LinkerInputBinary>& binary : ctx->inputs) { for (const Export& export_ : binary->exports) { - write_slice(stream, export_.name, "export name"); + write_str(stream, export_.name, "export name"); stream->WriteU8Enum(export_.kind, "export kind"); Index index = export_.index; switch (export_.kind) { @@ -330,16 +326,16 @@ static void write_memory_section(Context* ctx, static void write_function_import(Context* ctx, FunctionImport* import, Index offset) { - write_slice(&ctx->stream, import->module_name, "import module name"); - write_slice(&ctx->stream, import->name, "import field name"); + write_str(&ctx->stream, import->module_name, "import module name"); + write_str(&ctx->stream, import->name, "import field name"); ctx->stream.WriteU8Enum(ExternalKind::Func, "import kind"); write_u32_leb128(&ctx->stream, import->sig_index + offset, "import signature index"); } static void write_global_import(Context* ctx, GlobalImport* import) { - write_slice(&ctx->stream, import->module_name, "import module name"); - write_slice(&ctx->stream, import->name, "import field name"); + write_str(&ctx->stream, import->module_name, "import module name"); + write_str(&ctx->stream, import->name, "import field name"); ctx->stream.WriteU8Enum(ExternalKind::Global, "import kind"); write_type(&ctx->stream, import->type); ctx->stream.WriteU8(import->mutable_, "global mutability"); @@ -622,8 +618,7 @@ static void resolve_symbols(Context* ctx) { export_list.emplace_back(export_, binary); /* TODO(sbc): Handle duplicate names */ - export_map.emplace(string_slice_to_string(export_->name), - Binding(export_list.size() - 1)); + export_map.emplace(export_->name, Binding(export_list.size() - 1)); } } @@ -638,8 +633,7 @@ static void resolve_symbols(Context* ctx) { int export_index = export_map.FindIndex(import->name); if (export_index == -1) { if (!s_relocatable) - WABT_FATAL("undefined symbol: " PRIstringslice "\n", - WABT_PRINTF_STRING_SLICE_ARG(import->name)); + WABT_FATAL("undefined symbol: %s\n", import->name.c_str()); continue; } diff --git a/src/wasm-link.h b/src/wasm-link.h index 713ad4c1..c1509802 100644 --- a/src/wasm-link.h +++ b/src/wasm-link.h @@ -29,8 +29,8 @@ namespace link { class LinkerInputBinary; struct FunctionImport { - StringSlice module_name; - StringSlice name; + std::string module_name; + std::string name; Index sig_index; bool active; /* Is this import present in the linked binary */ Index relocated_function_index; @@ -39,8 +39,8 @@ struct FunctionImport { }; struct GlobalImport { - StringSlice module_name; - StringSlice name; + std::string module_name; + std::string name; Type type; bool mutable_; }; @@ -54,15 +54,10 @@ struct DataSegment { struct Export { ExternalKind kind; - StringSlice name; + std::string name; Index index; }; -struct SectionDataCustom { - /* Reference to string data stored in the containing InputBinary */ - StringSlice name; -}; - struct Section { WABT_DISALLOW_COPY_AND_ASSIGN(Section); Section(); @@ -83,8 +78,6 @@ struct Section { Index count; union { - /* CUSTOM section data */ - SectionDataCustom custom; /* DATA section data */ std::vector<DataSegment>* data_segments; /* MEMORY section data */ |