Ejemplo n.º 1
0
 public static void Install(CommandLineOptions options)
 {
     Contract.Requires(options != null);
       clo = options;
 }
Ejemplo n.º 2
0
        public static int Inline(string bplFileName)
        {
            Bpl.CommandLineOptions options = new Bpl.CommandLineOptions();
            Bpl.CommandLineOptions.Install(options);
            Bpl.CommandLineOptions.Clo.DoModSetAnalysis = true;
            Bpl.Program program;
            string      _bplFileName = "_" + bplFileName;

            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(-1);
            }
            errorCount = program.Typecheck();
            if (errorCount != 0)
            {
                Console.WriteLine("{0} type checking errors detected in {1}", errorCount, _bplFileName);
                return(-1);
            }
            bool inline = false;

            foreach (var d in program.TopLevelDeclarations)
            {
                if (d.FindExprAttribute("inline") != null)
                {
                    inline = true;
                }
            }
            if (inline)
            {
                foreach (var d in program.TopLevelDeclarations)
                {
                    var impl = d as Bpl.Implementation;
                    if (impl != null)
                    {
                        impl.OriginalBlocks  = impl.Blocks;
                        impl.OriginalLocVars = impl.LocVars;
                    }
                }
                foreach (var d in program.TopLevelDeclarations)
                {
                    var impl = d as Bpl.Implementation;
                    if (impl != null && !impl.SkipVerification)
                    {
                        Bpl.Inliner.ProcessImplementation(program, impl);
                    }
                }
                foreach (var d in program.TopLevelDeclarations)
                {
                    var impl = d as Bpl.Implementation;
                    if (impl != null)
                    {
                        impl.OriginalBlocks  = null;
                        impl.OriginalLocVars = null;
                    }
                }
            }
            Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter(bplFileName);
            options.PrintInstrumented = true;
            program.Emit(writer);
            writer.Close();
            return(0);
        }
Ejemplo n.º 3
0
        private static bool ReParseBoogieOptions(List<string> options, bool runningFromCommandLine)
        {
            var clo = new CommandLineOptions();
              if (clo.Parse(options.ToArray())) {
            clo.RunningBoogieFromCommandLine = runningFromCommandLine;
            CommandLineOptions.Install(clo);
            return true;
              }

              return false;
        }
Ejemplo n.º 4
0
    public static int Inline(string bplFileName) {
      Bpl.CommandLineOptions options = new Bpl.CommandLineOptions();
      Bpl.CommandLineOptions.Install(options);
      Bpl.CommandLineOptions.Clo.DoModSetAnalysis = true;
      Bpl.Program program;
      string _bplFileName = "_" + bplFileName;

      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 -1;
      }
      errorCount = program.Typecheck();
      if (errorCount != 0) {
        Console.WriteLine("{0} type checking errors detected in {1}", errorCount, _bplFileName);
        return -1;
      }
      bool inline = false;
      foreach (var d in program.TopLevelDeclarations) {
        if (d.FindExprAttribute("inline") != null) {
          inline = true;
        }
      }
      if (inline) {
        foreach (var d in program.TopLevelDeclarations) {
          var impl = d as Bpl.Implementation;
          if (impl != null) {
            impl.OriginalBlocks = impl.Blocks;
            impl.OriginalLocVars = impl.LocVars;
          }
        }
        foreach (var d in program.TopLevelDeclarations) {
          var impl = d as Bpl.Implementation;
          if (impl != null && !impl.SkipVerification) {
            Bpl.Inliner.ProcessImplementation(program, impl);
          }
        }
        foreach (var d in program.TopLevelDeclarations) {
          var impl = d as Bpl.Implementation;
          if (impl != null) {
            impl.OriginalBlocks = null;
            impl.OriginalLocVars = null;
          }
        }
      }
      Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter(bplFileName);
      options.PrintInstrumented = true;
      program.Emit(writer);
      writer.Close();
      return 0;
    }