예제 #1
0
        public Compiler(MosaCompiler mosaCompiler)
        {
            TypeSystem      = mosaCompiler.TypeSystem;
            TypeLayout      = mosaCompiler.TypeLayout;
            CompilerOptions = mosaCompiler.CompilerOptions;
            Linker          = mosaCompiler.Linker;
            CompilerTrace   = mosaCompiler.CompilerTrace;
            Architecture    = CompilerOptions.Architecture;

            PostCompilerTraceEvent(CompilerEvent.CompilerStart);

            CompilerExtensions.AddRange(mosaCompiler.CompilerExtensions);

            MethodStagePipelines = new Pipeline <BaseMethodCompilerStage> [mosaCompiler.MaxThreads + 1];

            MethodScheduler = new MethodScheduler(this);
            MethodScanner   = new MethodScanner(this);

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (!type.IsClass)
                {
                    continue;
                }

                foreach (var method in type.GetRuntimeMethods())
                {
                    // Now get all the IntrinsicMethodAttribute attributes
                    var attributes = (IntrinsicMethodAttribute[])method.GetCustomAttributes(typeof(IntrinsicMethodAttribute), true);

                    for (int i = 0; i < attributes.Length; i++)
                    {
                        var d = (InstrinsicMethodDelegate)Delegate.CreateDelegate(typeof(InstrinsicMethodDelegate), method);

                        // Finally add the dictionary entry mapping the target name and the delegate
                        InternalIntrinsicMethods.Add(attributes[i].Target, d);
                    }
                }
            }

            PlugSystem = new PlugSystem(TypeSystem);

            PlatformInternalRuntimeType = GetPlatformInternalRuntimeType();
            InternalRuntimeType         = GeInternalRuntimeType();

            // Build the default compiler pipeline
            CompilerPipeline.Add(GetDefaultCompilerPipeline(CompilerOptions));

            foreach (var extension in CompilerExtensions)
            {
                extension.ExtendCompilerPipeline(CompilerPipeline);
            }

            Architecture.ExtendCompilerPipeline(CompilerPipeline, CompilerOptions);

            IsStopped = false;
            WorkCount = 0;
        }
예제 #2
0
        public MosaCompiler(List <BaseCompilerExtension> compilerExtensions = null, int maxThreads = 0)
        {
            MaxThreads = (maxThreads == 0) ? Environment.ProcessorCount : maxThreads;

            if (compilerExtensions != null)
            {
                CompilerExtensions.AddRange(compilerExtensions);
            }
        }
예제 #3
0
        public MosaCompiler(CompilerOptions compilerOptions = null, List <BaseCompilerExtension> compilerExtensions = null, int maxThreads = 0)
        {
            MaxThreads = (maxThreads == 0) ? Environment.ProcessorCount * 2 : maxThreads;

            CompilerOptions = compilerOptions ?? new CompilerOptions();
            CompilerTrace   = new CompilerTrace(CompilerOptions);

            if (compilerExtensions != null)
            {
                CompilerExtensions.AddRange(compilerExtensions);
            }
        }
예제 #4
0
        public ScriptCompiler(ScriptFile targetScript, ILogger logger) : base()
        {
            _thisDynamic = this.AsDynamic();

            _targetScript = targetScript;
            _logger       = logger;

#if FALLOUT4
            _thisDynamic.pObjectToPath = new Dictionary <string, string>();
            SetPathForObject(_targetScript.Id, _targetScript.FilePath);
#endif

            CompilerExtensions.SetFlagsDictionary(this, _targetScript.Program.FlagsFile.NativeFlagsDict);
        }
예제 #5
0
        public Compiler(MosaCompiler mosaCompiler)
        {
            Architecture = mosaCompiler.CompilerOptions.Architecture;

            TypeSystem           = mosaCompiler.TypeSystem;
            TypeLayout           = mosaCompiler.TypeLayout;
            CompilerTrace        = mosaCompiler.CompilerTrace;
            CompilerOptions      = mosaCompiler.CompilerOptions;
            CompilationScheduler = mosaCompiler.CompilationScheduler;
            Linker = mosaCompiler.Linker;

            CompilerExtensions.AddRange(mosaCompiler.CompilerExtensions);

            methodStagePipelines = new Pipeline <BaseMethodCompilerStage> [mosaCompiler.MaxThreads];

            // Create new dictionary
            IntrinsicTypes = new Dictionary <string, Type>();

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.IsClass && typeof(IIntrinsicInternalMethod).IsAssignableFrom(type))
                {
                    // Now get all the ReplacementTarget attributes
                    var attributes = (ReplacementTargetAttribute[])type.GetCustomAttributes(typeof(ReplacementTargetAttribute), true);
                    for (int i = 0; i < attributes.Length; i++)
                    {
                        // Finally add the dictionary entry mapping the target string and the type
                        IntrinsicTypes.Add(attributes[i].Target, type);
                    }
                }
            }

            PlugSystem = new PlugSystem(TypeSystem);

            PlatformInternalRuntimeType = GetPlatformInternalRuntimeType();
            InternalRuntimeType         = GeInternalRuntimeType();

            // Build the default compiler pipeline
            CompilerPipeline.Add(GetDefaultCompilerPipeline(CompilerOptions));

            foreach (var extension in CompilerExtensions)
            {
                extension.ExtendCompilerPipeline(CompilerPipeline);
            }

            Architecture.ExtendCompilerPipeline(CompilerPipeline);

            IsStopped = false;
        }
예제 #6
0
        public Tester(IFactory <ICompiler> compilers, SubmissionInfo submissionInfo, TestInfo testInfo)
        {
            this.submissionInfo = submissionInfo;
            this.testInfo       = testInfo;

            CompilationResult checkerCompilationResult = CompilerExtensions.CompileToTempDirectory(testInfo.Checker, compilers);

            if (!checkerCompilationResult.Success)
            {
                throw new FailedActionException(
                          "скомпилировать чекер",
                          "Лог компиляции: " + checkerCompilationResult.CompilerOutput);
            }
            checkerPath      = checkerCompilationResult.OutputFileName;
            checkerDirectory = Path.GetDirectoryName(checkerPath);
            CompilationResult sourceCompilationResult = CompilerExtensions.CompileToTempDirectory(submissionInfo.Source, compilers);

            result = new TestLog {
                CompilationReport = sourceCompilationResult.CompilerOutput
            };
            compilationSucceeded = sourceCompilationResult.Success;
            solutionPath         = sourceCompilationResult.OutputFileName;
            solutionDirectory    = Path.GetDirectoryName(solutionPath);
        }