MCPcopy Create free account
hub / github.com/WebAssembly/wabt / wabt_write_binary_spec_script

Function wabt_write_binary_spec_script

src/emscripten-helpers.cc:163–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163WabtWriteScriptResult* wabt_write_binary_spec_script(
164 wabt::Script* script,
165 const char* source_filename,
166 const char* out_filename,
167 int log,
168 int canonicalize_lebs,
169 int relocatable,
170 int write_debug_names) {
171 wabt::MemoryStream log_stream;
172 wabt::MemoryStream* log_stream_p = log ? &log_stream : nullptr;
173
174 wabt::WriteBinaryOptions options;
175 options.canonicalize_lebs = canonicalize_lebs;
176 options.relocatable = relocatable;
177 options.write_debug_names = write_debug_names;
178
179 std::vector<wabt::FilenameMemoryStreamPair> module_streams;
180 wabt::MemoryStream json_stream(log_stream_p);
181
182 std::string module_filename_noext(
183 wabt::StripExtension(out_filename ? out_filename : source_filename));
184
185 WabtWriteScriptResult* result = new WabtWriteScriptResult();
186 result->result = WriteBinarySpecScript(&json_stream, script, source_filename,
187 module_filename_noext, options,
188 &module_streams, log_stream_p);
189
190 if (result->result == wabt::Result::Ok) {
191 result->json_buffer = json_stream.ReleaseOutputBuffer();
192 result->log_buffer = log ? log_stream.ReleaseOutputBuffer() : nullptr;
193 std::transform(module_streams.begin(), module_streams.end(),
194 std::back_inserter(result->module_buffers),
195 [](wabt::FilenameMemoryStreamPair& pair) {
196 return WabtFilenameOutputBufferPair(
197 pair.filename, pair.stream->ReleaseOutputBuffer());
198 });
199 }
200 return result;
201}
202
203wabt::Result::Enum wabt_apply_names_module(wabt::Module* module) {
204 return ApplyNames(module);

Callers

nothing calls this directly

Calls 5

StripExtensionFunction · 0.85
WriteBinarySpecScriptFunction · 0.85
ReleaseOutputBufferMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected