Example #1
0
        /// <summary>
        /// Synchronous one-time compilation of the current file
        /// </summary>
        public void CompileOnce()
        {
            if (CompilerOptions.ExecToStep == null)
            {
                CompilerOptions.ExecToStep = ExecutionStep.SemanticCheck;
            }

            if (CompilationResultsForCopy != null)
            {
                CompilationResultsForCopy.UpdateTokensLines(); //Scanner

                if (!(CompilerOptions.ExecToStep > ExecutionStep.Scanner))
                {
                    return;
                }

                CompilationResultsForCopy.RefreshTokensDocumentSnapshot();
                CompilationResultsForCopy.RefreshProcessedTokensDocumentSnapshot(); //Preprocessor
            }
            else
            {
                AnalyticsWrapper.Telemetry.TrackEvent("[Phase] Scanner Step");
                CompilationResultsForProgram.UpdateTokensLines(); //Scanner

                if (!(CompilerOptions.ExecToStep > ExecutionStep.Scanner))
                {
                    return;
                }

                AnalyticsWrapper.Telemetry.TrackEvent("[Phase] Preprocessor Step");
                CompilationResultsForProgram.RefreshTokensDocumentSnapshot();
                CompilationResultsForProgram.RefreshProcessedTokensDocumentSnapshot(); //Preprocessor

                if (!(CompilerOptions.ExecToStep > ExecutionStep.Preprocessor))
                {
                    return;
                }
                if (CompilerOptions.HaltOnMissingCopy && CompilationResultsForProgram.MissingCopies.Count > 0)
                {
                    return;                                                                                            //If the Option is set to true and there is at least one missing copy, we don't have to run the semantic phase
                }
                AnalyticsWrapper.Telemetry.TrackEvent("[Phase] Syntaxic Step");
                CompilationResultsForProgram.RefreshCodeElementsDocumentSnapshot(); //SyntaxCheck

                if (!(CompilerOptions.ExecToStep > ExecutionStep.SyntaxCheck))
                {
                    return;
                }

                AnalyticsWrapper.Telemetry.TrackEvent("[Phase] Semantic Step");
                CompilationResultsForProgram.RefreshProgramClassDocumentSnapshot(); //SemanticCheck
            }
        }
Example #2
0
        /// <summary>
        /// Perform a cmpilation based on an execution step.
        /// </summary>
        /// <param name="exec2Step">The execution step</param>
        /// <param name="haltOnMissingCopy">For preprocessing step, halt on missing copy options</param>
        /// <param name="useAntlrProgramParsing">Shall Antlr be used to parse the program</param>
        public void CompileOnce(ExecutionStep?exec2Step, bool haltOnMissingCopy, bool useAntlrProgramParsing)
        {
            if (exec2Step == null)
            {
                exec2Step = ExecutionStep.CrossCheck;
            }

            if (CompilationResultsForCopy != null)
            {
                CompilationResultsForCopy.UpdateTokensLines(); //Scanner

                if (!(exec2Step > ExecutionStep.Scanner))
                {
                    return;
                }

                CompilationResultsForCopy.RefreshTokensDocumentSnapshot();
                CompilationResultsForCopy.RefreshProcessedTokensDocumentSnapshot(); //Preprocessor
            }
            else
            {
                CompilationResultsForProgram.UpdateTokensLines(); //Scanner
                CompilationResultsForProgram.RefreshTokensDocumentSnapshot();
                ExecutionStepEventHandler?.Invoke(this, new ExecutionStepEventArgs()
                {
                    ExecutionStep = ExecutionStep.Scanner
                });

                if (!(exec2Step > ExecutionStep.Scanner))
                {
                    return;
                }

                CompilationResultsForProgram.RefreshProcessedTokensDocumentSnapshot(); //Preprocessor
                ExecutionStepEventHandler?.Invoke(this, new ExecutionStepEventArgs()
                {
                    ExecutionStep = ExecutionStep.Preprocessor
                });

                if (!(exec2Step > ExecutionStep.Preprocessor))
                {
                    return;
                }
                if (haltOnMissingCopy && CompilationResultsForProgram.MissingCopies.Count > 0)
                {
                    return;                                                         //If the Option is set to true and there is at least one missing copy, we don't have to run the semantic phase
                }
                CompilationResultsForProgram.RefreshCodeElementsDocumentSnapshot(); //SyntaxCheck
                ExecutionStepEventHandler?.Invoke(this, new ExecutionStepEventArgs()
                {
                    ExecutionStep = ExecutionStep.SyntaxCheck
                });

                if (!(exec2Step > ExecutionStep.SyntaxCheck))
                {
                    return;
                }

                CompilationResultsForProgram.ProduceTemporarySemanticDocument(); //SemanticCheck
                ExecutionStepEventHandler?.Invoke(this, new ExecutionStepEventArgs()
                {
                    ExecutionStep = ExecutionStep.SemanticCheck
                });

                if (!(exec2Step > ExecutionStep.SemanticCheck))
                {
                    return;
                }

                CompilationResultsForProgram.RefreshProgramClassDocumentSnapshot(); //Cross Check step
                ExecutionStepEventHandler?.Invoke(this, new ExecutionStepEventArgs()
                {
                    ExecutionStep = ExecutionStep.CrossCheck
                });
            }
        }