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

Method _WriteModuleInitCall

test/run-spec-wasm2c.py:204–225  ·  view source on GitHub ↗
(self, command, uninstantiable)

Source from the content-addressed store, hash-verified

202 self.unmangled_names[name_idx] = command['as']
203
204 def _WriteModuleInitCall(self, command, uninstantiable):
205 header_filename = utils.ChangeExt(command['filename'], '.h')
206 with open(os.path.join(self.out_dir, header_filename), encoding='utf-8') as f:
207 imported_modules = set()
208 for line in f:
209 if 'import: ' in line:
210 line_split = line.split()
211 import_module_name = MangleModuleName(line_split[2][1:-1])
212 imported_modules.add(import_module_name)
213
214 if uninstantiable:
215 self.out_file.write('ASSERT_TRAP(')
216
217 self.out_file.write('wasm2c_%s_instantiate(&%s_instance' % (self.GetModulePrefix(), self.GetModulePrefix()))
218 for imported_module in sorted(imported_modules):
219 self.out_file.write(', &%s_instance' % imported_module)
220 self.out_file.write(')')
221
222 if uninstantiable:
223 self.out_file.write(')')
224
225 self.out_file.write(';\n')
226
227 def _MaybeWriteDummyModule(self):
228 if len(self.GetModuleFilenames()) == 0:

Callers 2

_WriteModuleCommandMethod · 0.95

Calls 5

GetModulePrefixMethod · 0.95
MangleModuleNameFunction · 0.85
joinMethod · 0.80
splitMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected