Exemplo n.º 1
0
        public void Start(TextWriter error, Encoding encoding)
        {
            _context = new CompilerContext(new CompilerSettings
            {
                Encoding             = encoding,
                Platform             = Platform.AnyCPU,
                StdLibRuntimeVersion = RuntimeVersion.v4,
                Target = Target.Library,
                LoadDefaultReferences = false,
                StdLib = false,
            }, new StreamReportPrinter(error));

            _driver = new CompilerDriver(_context);
            _imports.Clear();

            ImportBuiltinTypes();
        }
Exemplo n.º 2
0
        public bool Build(out ScriptModule module)
        {
            ThrowIfNotStarted();

            try
            {
                var success = _driver.Compile(out var builder);

                module = new ScriptModule
                {
                    Assembly     = builder,
                    ErrorCount   = _context.Report.Errors,
                    WarningCount = _context.Report.Warnings
                };

                return(success);
            }
            finally
            {
                _context = null;
                _driver  = null;
                _imports.Clear();
            }
        }