Esempio n. 1
0
    protected static void ProcessImplementation(Implementation impl, Inliner inliner) {
      Contract.Requires(impl != null);
      Contract.Requires(impl.Proc != null);

      inliner.newLocalVars = new List<Variable>(impl.LocVars);
      inliner.newModifies = new List<IdentifierExpr>(impl.Proc.Modifies);

      bool inlined = false;
      List<Block> newBlocks = inliner.DoInlineBlocks(impl.Blocks, ref inlined);
      Contract.Assert(cce.NonNullElements(newBlocks));

      if (!inlined)
        return;

      impl.InParams = new List<Variable>(impl.InParams);
      impl.OutParams = new List<Variable>(impl.OutParams);
      impl.LocVars = inliner.newLocalVars;
      impl.Proc.Modifies = inliner.newModifies;
      impl.Blocks = newBlocks;

      impl.ResetImplFormalMap();

      // we need to resolve the new code
      inliner.ResolveImpl(impl);

      if (CommandLineOptions.Clo.PrintInlined) {
        inliner.EmitImpl(impl);
      }
    }
Esempio n. 2
0
 public override Expr VisitCodeExpr(CodeExpr node)
 {
   Inliner codeExprInliner = new Inliner(program, inlineCallback, CommandLineOptions.Clo.InlineDepth);
   codeExprInliner.newLocalVars.AddRange(node.LocVars);
   codeExprInliner.inlinedProcLblMap = this.inlinedProcLblMap;
   List<Block> newCodeExprBlocks = codeExprInliner.DoInlineBlocks(node.Blocks, ref inlinedSomething);
   return new CodeExpr(codeExprInliner.newLocalVars, newCodeExprBlocks);
 }
Esempio n. 3
0
 public override Expr VisitCodeExpr(CodeExpr node)
 {
     Inliner codeExprInliner = new Inliner(program, inlineCallback, CommandLineOptions.Clo.InlineDepth);
     codeExprInliner.newLocalVars.AddRange(node.LocVars);
     codeExprInliner.inlinedProcLblMap = this.inlinedProcLblMap;
     List<Block> newCodeExprBlocks = codeExprInliner.DoInlineBlocks(node.Blocks, ref inlinedSomething);
     return new CodeExpr(codeExprInliner.newLocalVars, newCodeExprBlocks);
 }
Esempio n. 4
0
    protected static void ProcessImplementation(Program program, Implementation impl, Inliner inliner) {
      Contract.Requires(impl != null);
      Contract.Requires(impl.Proc != null);

      inliner.ComputePrefix(program, impl);

      inliner.newLocalVars.AddRange(impl.LocVars);
      inliner.newModifies.AddRange(impl.Proc.Modifies);

      bool inlined = false;
      List<Block> newBlocks = inliner.DoInlineBlocks(impl.Blocks, ref inlined);
      Contract.Assert(cce.NonNullElements(newBlocks));

      if (!inlined)
        return;

      impl.InParams = new List<Variable>(impl.InParams);
      impl.OutParams = new List<Variable>(impl.OutParams);
      impl.LocVars = inliner.newLocalVars;
      impl.Proc.Modifies = inliner.newModifies;
      impl.Blocks = newBlocks;

      impl.ResetImplFormalMap();

      // we need to resolve the new code
      inliner.ResolveImpl(impl);

      if (CommandLineOptions.Clo.PrintInlined) {
        inliner.EmitImpl(impl);
      }
    }