Esempio n. 1
0
 public Compiler(string outputDirPath = "output", bool verbose = true)
 {
     Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
     _assemblyBuilder = new AssemblyBuilder(verbose);
     _ouBuilder       = new OutputUnitsBuilder(verbose);
     _outputDirPath   = outputDirPath;
 }
        public Compiler(CompilationOptions options)
        {
            _scriptPaths = new List <string>();

            string absoluteSrcFilePath = Path.GetFullPath(options.SrcFilePath);

            _runtimePath = options.RuntimePath;
            if (_runtimePath == String.Empty)
            {
                string srcFileNameLowerWithoutExtension = Path.GetFileNameWithoutExtension(absoluteSrcFilePath).ToLower();
                _runtimePath = Path.Combine(GetBuiltinsPath(), srcFileNameLowerWithoutExtension + ".d");
            }

            if (File.Exists(_runtimePath))
            {
                _scriptPaths.Add(_runtimePath);
            }
            else
            {
                if (_verbose && options.RuntimePath != String.Empty)
                {
                    Console.WriteLine($"Specified runtime {_runtimePath} doesn't exist.");
                }
                _runtimePath = null;
            }

            _scriptPaths.AddRange(SrcFileHelper.LoadScriptsFilePaths(absoluteSrcFilePath));

            _outputPathDat           = options.OutputPathDat;
            _generateOutputUnits     = options.GenerateOutputUnits;
            _outputPathOuDir         = options.OutputPathOuDir;
            _zenPaths                = options.ZenPaths;
            _strictSyntax            = options.StrictSyntax;
            _globallySuppressedCodes = options.GloballySuppressedCodes;
            _verbose = options.Verbose;


            if (_generateOutputUnits)
            {
                _ouBuilder = new OutputUnitsBuilder(_verbose);
            }

            DatFile      = null;
            _errorLogger = new StdErrorLogger();
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
        }