public List <CodePart> LoadObjectFile(string filePath, string prefix, byte[] content) { SafeHouse.Logger.SuperVerbose("Volume: LoadObjectFile: " + filePath); List <CodePart> parts = CompiledObject.UnPack(filePath, prefix, content); return(parts); }
/// <summary> /// Constructor. /// </summary> /// <param name="options">Options for the compiler.</param> public CompileAction(CompileOptions options, bool usedExternally = false) { Opcode.InitMachineCodeData(); CompiledObject.InitTypeData(); SafeSerializationMgr.CheckIDumperStatics(); _usedExternally = usedExternally; _options = options; _shared = new SafeSharedObjects(); _shared.FunctionManager = new FunctionManager(_shared); _shared.GameEventDispatchManager = new NoopGameEventDispatchManager(); _shared.Processor = new NoopProcessor(); _shared.ScriptHandler = new KSScript(); _shared.Screen = new Screen(); _shared.UpdateHandler = new UpdateHandler(); _shared.VolumeMgr = new VolumeManager(); _shared.FunctionManager.Load(); _compilerOptions = new CompilerOptions() { LoadProgramsInSameAddressSpace = false, IsCalledFromRun = false, FuncManager = _shared.FunctionManager }; _logger = new CompilerLogger(); _scriptLoader = new KerboscriptLoader(_shared.VolumeMgr as VolumeManager, _logger, _options); _scriptDeleter = new KerboscriptDeleter(_options); }
public virtual bool SaveObjectFile(string fileNameOut, List <CodePart> parts) { var newFile = new ProgramFile(fileNameOut) { BinaryContent = CompiledObject.Pack(parts) }; return(SaveFile(newFile)); }
private bool TryCompileFile(InputFile inputFile, string outputDirectory, IEnumerable <string> includeDirectories, out CompiledObject compiledObject) { Console.WriteLine("Compiling {0}", inputFile.Path); var arguments = ""; var tool = ""; switch (inputFile.FileType) { case InputFileType.CSource: tool = _configSection.CCompilerTool; arguments += _configSection.CFlags + " -c "; // "-Wall -O2 -nostdlib -nostartfiles -ffreestanding -c "; if (_environmentSection.Verbose) { arguments += "-v "; } arguments += string.Join(" ", includeDirectories.Select(t => string.Format("-I {0} ", t)).ToArray()); break; case InputFileType.AsmSource: if (_environmentSection.Verbose) { arguments += "--verbose "; } tool = _configSection.AssemblerTool; break; } arguments += string.Format(@"{0} -o {1}.o", inputFile.Path, Path.Combine(outputDirectory, inputFile.Filename)); compiledObject = null; if (ExecuteTool(tool, arguments)) { compiledObject = new CompiledObject { Name = inputFile.Filename, Path = outputDirectory }; return(true); } return(false); }
public List <CodePart> AsParts(GlobalPath path, string prefix) { return(CompiledObject.UnPack(path, prefix, Bytes)); }
public FileContent(List <CodePart> parts) : this() { Bytes = CompiledObject.Pack(parts); }
// This is what KSP calls during the initial loading screen (the screen // with the progress bar and all of the "Turning correct end toward space" // funny messages.) This is where kOS *should* be putting all the // static initializing that does not change per-part, or per-vessel // or per-CPU. It might be true that some of what we're doing up above // in OnLoad and OnStart might relly belong here. // // At some future point it would be a really good idea to look very carefully // at *everything* being done during those initialzations and see if any of // those steps really are meant to be static do-once steps that belong here // instead: public override void OnAwake() { Opcode.InitMachineCodeData(); CompiledObject.InitTypeData(); }
public List <CodePart> AsParts(string name, string prefix) { return(CompiledObject.UnPack(name, prefix, Bytes)); }
// This is what KSP calls during the initial loading screen (the screen // with the progress bar and all of the "Turning correct end toward space" // funny messages.) This is where kOS *should* be putting all the // static initializing that does not change per-part, or per-vessel // or per-CPU. It might be true that some of what we're doing up above // in OnLoad and OnStart might really belong here. // // At some future point it would be a really good idea to look very carefully // at *everything* being done during those initialzations and see if any of // those steps really are meant to be static do-once steps that belong here // instead: public override void OnAwake() { Opcode.InitMachineCodeData(); CompiledObject.InitTypeData(); SafeSerializationMgr.CheckIDumperStatics(); }
private bool TryCompileFile(string filename, string path, InputFileType fileType, string outputDirectory, IEnumerable <string> includeDirectories, out CompiledObject compiledObject) { Console.WriteLine("Compiling {0}", path); var arguments = ""; //InputFile file = new InputFile {Path = filePath}; // figure out tool based on extension //var extension = (Path.GetExtension(in) ?? string.Empty).ToLower(); var tool = ""; switch (fileType) { case InputFileType.CSource: tool = _configuration.CCompilerTool; arguments += _configuration.CFlags + " -c "; // "-Wall -O2 -nostdlib -nostartfiles -ffreestanding -c "; if (_configuration.Verbose) { arguments += "-v "; } arguments += string.Join(" ", includeDirectories.Select(t => string.Format("-I {0} ", t)).ToArray()); break; case InputFileType.AsmSource: if (_configuration.Verbose) { arguments += "--verbose "; } tool = _configuration.AssemblerTool; break; } arguments += string.Format(@"{0} -o {1}.o", path, Path.Combine(outputDirectory, filename)); compiledObject = null; //if (ExecuteTool(tool, arguments)) //{ // compiledObject = new CompiledObject { Name = filename, Path = outputDirectory }; // return true; //} return(false); }