MCPcopy
hub / github.com/webpack/webpack / createDefaultInitForGlobal

Function createDefaultInitForGlobal

lib/wasm-sync/WebAssemblyGenerator.js:151–164  ·  view source on GitHub ↗
(globalType)

Source from the content-addressed store, hash-verified

149 * @returns {t.Instruction} init expression
150 */
151const createDefaultInitForGlobal = (globalType) => {
152 if (globalType.valtype[0] === "i") {
153 // create NumberLiteral global initializer
154 return t.objectInstruction("const", globalType.valtype, [
155 t.numberLiteralFromRaw(66)
156 ]);
157 } else if (globalType.valtype[0] === "f") {
158 // create FloatLiteral global initializer
159 return t.objectInstruction("const", globalType.valtype, [
160 t.floatLiteral(66, false, false, "66")
161 ]);
162 }
163 throw new Error(`unknown type: ${globalType.valtype}`);
164};
165
166/**
167 * Rewrite the import globals:

Callers 2

ModuleImportFunction · 0.85
GlobalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected