private static void CompileFile(string path, string outPath, TypeStorage typeStorage, ILogger logger, ILogger treeLogger, CSNameConvertor nameConvertor) { using (var fileStream = new FileStream(path, FileMode.Open)) using (var outStream = new StreamWriter(outPath)) { CompileFile(fileStream, path, outStream, typeStorage, logger, treeLogger, nameConvertor); } }
private static void CompileAll(List <string> files, TypeStorage typeStorage, ILogger logger, ILogger treeLogger, CSNameConvertor nameConvertor) { using (var fileWriter = new StreamWriter("out.il")) { foreach (var item in files) { using (var fileStream = new FileStream(item, FileMode.Open)) { CompileFile(fileStream, item, fileWriter, typeStorage, logger, treeLogger, nameConvertor); } } } }
public void Compile(CompilerArgs args) { if (args.SourceFiles.Count == 0) { Console.WriteLine("Файлы для компиляции не заданы"); return; } var nameConvertor = new CSNameConvertor(); var typeLoader = new StandardLibraryTypesLoader(nameConvertor); var typeStorage = typeLoader.Load(args.Libs); ILogger logger = GetLogger(args.OutLogFile); ILogger treeLogger = GetLogger(args.PrintTreeFile); var tree = Parse(args.SourceFiles); var node = Combine(tree); if (args.PrintTree) { treeLogger.Log(ASTPrinter.Print(node)); } bool ok = Analyze(node, typeStorage, logger); if (!ok) { Console.ReadLine(); return; } Optimize(node); string code = Generate(node, nameConvertor, typeStorage); Write(args.OutFile, code); }
public ClassLoader(TypeStorage storage, CSNameConvertor nameConvertor) : base(storage, nameConvertor) { }
public PackageLoader(TypeStorage storage, CSNameConvertor nameConvertor) : base(storage, nameConvertor) { }
public StandardLibraryTypesLoader(CSNameConvertor nameConvertor) { this.nameConvertor = nameConvertor; }
public GenericLoader(TypeStorage storage, CSNameConvertor nameConvertor) : base(storage, nameConvertor) { }
public AbstractTypeLoader(TypeStorage storage, CSNameConvertor nameConvertor) { this.storage = storage; this.nameConvertor = nameConvertor; }