private ProgramOutput GetCompileOutput(ASTCompiler compiler, Linker linker, Domain globalDomain) { ProgramOutput program = new ProgramOutput(); Dictionary <string, long> offsets = new Dictionary <string, long>(); List <ByteInstruction> allInstructions = new List <ByteInstruction>(); long offset = 0; var context = compiler.GetCompileContext(); var funcs = compiler.GetCompiledBytecode(); if (funcs is not null) { for (int i = 0; i < funcs.Length; i++) { offsets.Add(funcs[i].Name, offset); for (int j = 0; j < funcs[i].Instructions.Count; j++) { ByteInstruction instruction = funcs[i].Instructions[j]; allInstructions.Add(instruction); offset += instruction.GetSize(); } long remainder = offset % 4; if (remainder > 0) { for (int j = 0; j < remainder; j++) { allInstructions.Add(new ByteInstruction(Bytecode.NOP)); } offset += remainder; } } } // Set instructions, offsets, bytes, strings etc... program.SetProgramType(this.m_currentProject.ProjectType); program.SetInstructions(allInstructions.ToArray()); program.SetOffsets(offsets, offset); program.SetBytes(context?.ConstBytes); program.SetStrings(context?.Strings); program.SetDeclaredTypes(linker.ExportTypes); program.SetBindTable(linker.Bindings); // Set program return(program); }