コード例 #1
0
        static int InjectAssertionInBpl(string bplFileName, string fileName, int lineNumber, int columnNumber)
        {
            Bpl.CommandLineOptions.Install(new Bpl.CommandLineOptions());
            Bpl.CommandLineOptions.Clo.DoModSetAnalysis = true;
            var returnValue = errorValue;

            Bpl.Program program;
            Bpl.Parser.Parse(bplFileName, new List <string>(), out program);
            int errorCount = program.Resolve();

            if (errorCount != 0)
            {
                Console.WriteLine("{0} name resolution errors detected in {1}", errorCount, bplFileName);
                return(returnValue);
            }
            errorCount = program.Typecheck();
            if (errorCount != 0)
            {
                Console.WriteLine("{0} type checking errors detected in {1}", errorCount, bplFileName);
                return(returnValue);
            }

            GetMeHereBplInjector bplInjector = new GetMeHereBplInjector(fileName, lineNumber, columnNumber);

            bplInjector.Visit(program);
            using (Bpl.TokenTextWriter writer = new Bpl.TokenTextWriter(bplFileName)) {
                Bpl.CommandLineOptions.Clo.PrintInstrumented = true;
                program.Emit(writer);
            }
            return(returnValue);
        }
コード例 #2
0
    static int InjectAssertionInBpl(string bplFileName, string fileName, int lineNumber, int columnNumber) {
      Bpl.CommandLineOptions.Install(new Bpl.CommandLineOptions());
      Bpl.CommandLineOptions.Clo.DoModSetAnalysis = true;
      var returnValue = errorValue; 
      Bpl.Program program;
      Bpl.Parser.Parse(bplFileName, new List<string>(), out program);
      int errorCount = program.Resolve();
      if (errorCount != 0) {
        Console.WriteLine("{0} name resolution errors detected in {1}", errorCount, bplFileName);
        return returnValue;
      }
      errorCount = program.Typecheck();
      if (errorCount != 0) {
        Console.WriteLine("{0} type checking errors detected in {1}", errorCount, bplFileName);
        return returnValue;
      }

      GetMeHereBplInjector bplInjector = new GetMeHereBplInjector(fileName, lineNumber, columnNumber);
      bplInjector.Visit(program);
      using (Bpl.TokenTextWriter writer = new Bpl.TokenTextWriter(bplFileName)) {
        Bpl.CommandLineOptions.Clo.PrintInstrumented = true;
        program.Emit(writer);
      }
      return returnValue;
    }