MCPcopy Create free account
hub / github.com/WebAssembly/wasm-c-api / globals

Function globals

src/wasm-bin.cc:450–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448// Global section
449
450auto globals(
451 const vec<byte_t>& binary, const ownvec<ImportType>& imports
452) -> ownvec<GlobalType> {
453 auto pos = bin::section(binary, SEC_GLOBAL);
454 size_t size = pos != nullptr ? bin::u32(pos) : 0;
455 auto v = ownvec<GlobalType>::make_uninitialized(
456 size + count(imports, ExternKind::GLOBAL));
457 size_t j = 0;
458 for (uint32_t i = 0; i < imports.size(); ++i) {
459 auto et = imports[i]->type();
460 if (et->kind() == ExternKind::GLOBAL) {
461 v[j++] = et->global()->copy();
462 }
463 }
464 if (pos != nullptr) {
465 for (; j < v.size(); ++j) {
466 v[j] = bin::globaltype(pos);
467 expr_skip(pos);
468 }
469 assert(pos = bin::section_end(binary, SEC_GLOBAL));
470 }
471 return v;
472}
473
474
475// Table section

Callers 1

exportsFunction · 0.85

Calls 11

sectionFunction · 0.85
u32Function · 0.85
countFunction · 0.85
globaltypeFunction · 0.85
expr_skipFunction · 0.85
section_endFunction · 0.85
typeMethod · 0.80
globalMethod · 0.80
sizeMethod · 0.45
kindMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected