private static void DeclareGlobals(WasmNodeContext context, WasmGlobalSection section) { foreach (var global in section.Entries) { var variable = new GlobalNode(global.Type.Type, global.Type.Mutable) { Name = $"global_{context.Module.Globals.Count}" }; context.Module.Globals.Add(variable); } }
public WasmGlobalSection ReadGlobalSection() { var res = new WasmGlobalSection(); var count = ReadVarUInt32(); for (var i = 0; i < count; i++) { var entry = ReadGlobalEntry(); res.Entries.Add(entry); } return(res); }
private static void AddGlobals(WasmNodeContext context, WasmGlobalSection section) { DeclareGlobals(context, section); for (var i = 0; i < section.Entries.Count; i++) { var global = section.Entries[i]; var variable = context.Module.Globals[i]; var arg = new WasmNodeArg { Context = context }; arg.PushBlock(variable.Init); var visitor = new WasmNode(); foreach (var opcode in global.Init.Opcodes) { opcode.AcceptVistor(visitor, arg); } } }