MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / encodeLEB128

Function encodeLEB128

test/validator/ValidatorRegressionTest.cpp:43–54  ·  view source on GitHub ↗

Helper function to encode an unsigned 32-bit integer as LEB128

Source from the content-addressed store, hash-verified

41
42// Helper function to encode an unsigned 32-bit integer as LEB128
43static std::vector<WasmEdge::Byte> encodeLEB128(uint32_t Value) {
44 std::vector<WasmEdge::Byte> Leb;
45 do {
46 WasmEdge::Byte Byte = Value & 0x7FU;
47 Value >>= 7;
48 if (Value != 0) {
49 Byte |= 0x80U;
50 }
51 Leb.push_back(Byte);
52 } while (Value != 0);
53 return Leb;
54}
55
56// Generates a Wasm module with a chain of subtypes.
57// NumTotalTypes: The total number of types to define. Type k+1 subtypes type

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected