예제 #1
0
 /// <summary>
 /// Visits the source context
 /// </summary>
 /// <param name="line">Line to add the tag for</param>
 /// <param name="context">SourceContextNode to visit</param>
 /// <param name="lineNo">Current line number</param>
 /// <param name="collectedSpans">Collection of spans found</param>
 private void Visit(ITextSnapshotLine line, SourceContextNode context, int lineNo,
                    List <ClassificationSpan> collectedSpans)
 {
     if (context == null ||
         lineNo < context.Span.StartLine ||
         lineNo > context.Span.EndLine)
     {
         return;
     }
     Visit(line, context.SourceKeywordSpan, lineNo, collectedSpans, _keyword);
     Visit(line, context.SourceFileSpan, lineNo, collectedSpans, _number);
 }
 /// <summary>
 /// Visits the source context
 /// </summary>
 /// <param name="line">Line to add the tag for</param>
 /// <param name="context">SourceContextNode to visit</param>
 /// <param name="lineNo">Current line numer</param>
 /// <param name="collectedSpans">Collection of spancs found</param>
 private void Visit(ITextSnapshotLine line, SourceContextNode context, int lineNo,
                    List <TagSpan <Z80TestTokenTag> > collectedSpans)
 {
     if (context == null ||
         lineNo < context.Span.StartLine ||
         lineNo > context.Span.EndLine)
     {
         return;
     }
     Visit(line, context.SourceKeywordSpan, lineNo, collectedSpans, Z80TestTokenType.Keyword);
     Visit(line, context.SourceFileSpan, lineNo, collectedSpans, Z80TestTokenType.Number);
 }
예제 #3
0
        /// <summary>
        /// Visits the source context of a test set
        /// </summary>
        /// <param name="plan">Test file plan</param>
        /// <param name="testSetPlan">TestSetPlan to visit</param>
        /// <param name="sourceContext">Machine context</param>
        private void VisitSourceContext(TestFilePlan plan, TestSetPlan testSetPlan, SourceContextNode sourceContext)
        {
            if (sourceContext == null)
            {
                return;
            }

            // --- Prepare predefined symbols for Z80 compilation
            var options = new AssemblerOptions();

            foreach (var symbol in sourceContext.Symbols)
            {
                options.PredefinedSymbols.Add(symbol.Id);
            }
            var assembler = new Z80Assembler();

            // --- Check filename existence
            var filename = sourceContext.SourceFile;

            if (!Path.IsPathRooted(filename))
            {
                filename = Path.Combine(DefaultSourceFolder ?? "", filename);
            }
            if (!File.Exists(filename))
            {
                ReportError(Errors.T0003, plan, sourceContext.SourceFileSpan, filename);
                return;
            }

            // --- Compile the Z80 source file
            var output = assembler.CompileFile(filename, options);

            if (output.ErrorCount == 0)
            {
                testSetPlan.CodeOutput = output;
                return;
            }

            // --- Issue cZ80 ompilation error
            ReportError(Errors.T0004, plan, sourceContext.SourceFileSpan, filename, output.ErrorCount);
        }