(globalType)
| 149 | * @returns {t.Instruction} init expression |
| 150 | */ |
| 151 | const 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: |
no outgoing calls
no test coverage detected