Example #1
0
 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);
         }
 }
Example #2
0
 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);
             }
         }
     }
 }
Example #3
0
        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);
        }
Example #4
0
 public ClassLoader(TypeStorage storage, CSNameConvertor nameConvertor)
     : base(storage, nameConvertor)
 {
 }
Example #5
0
 public PackageLoader(TypeStorage storage, CSNameConvertor nameConvertor)
     : base(storage, nameConvertor)
 {
 }
Example #6
0
 public StandardLibraryTypesLoader(CSNameConvertor nameConvertor)
 {
     this.nameConvertor = nameConvertor;
 }
Example #7
0
 public GenericLoader(TypeStorage storage, CSNameConvertor nameConvertor)
     : base(storage, nameConvertor)
 {
 }
 public AbstractTypeLoader(TypeStorage storage, CSNameConvertor nameConvertor)
 {
     this.storage       = storage;
     this.nameConvertor = nameConvertor;
 }