Пример #1
0
        public override void Commit()
        {
            base.Commit();

            var visitor = new OldScanStateMachine <Label> (this);
            EnsuresBlock <Label> priorBlock = null;

            foreach (CFGBlock block in Blocks)
            {
                var ensuresBlock = block as EnsuresBlock <Label>;
                if (ensuresBlock != null)
                {
                    priorBlock = ensuresBlock;
                    int count = ensuresBlock.Count;
                    visitor.StartBlock(ensuresBlock);

                    for (int i = 0; i < count; i++)
                    {
                        if (ensuresBlock.OriginalForwardDecode <int, Boolean, OldScanStateMachine <Label> > (i, visitor, i))
                        {
                            ensuresBlock.AddInstruction(i);
                        }
                    }
                }
                else
                {
                    visitor.HandlePotentialCallBlock(block as MethodCallBlock <Label>, priorBlock);
                }
                foreach (CFGBlock succ in SuccessorBlocks(block))
                {
                    visitor.SetStartState(succ);
                }
            }
        }
Пример #2
0
        public void HandlePotentialCallBlock(MethodCallBlock <Label> block, EnsuresBlock <Label> priorBlock)
        {
            if (block == null || this.state != ScanState.InsertingOld)
            {
                return;
            }

            int count = this.subroutine.SubroutineFacade.MetaDataProvider.Parameters(block.CalledMethod).Count;

            if (!this.subroutine.SubroutineFacade.MetaDataProvider.IsStatic(block.CalledMethod))
            {
                ++count;
            }
            if (count > 1)
            {
                this.state = ScanState.OutsideOld;
                TypeNode mp = this.subroutine.SubroutineFacade.MetaDataProvider.ManagedPointer(this.next_end_old_type);
                priorBlock.EndOldWithoutInstruction(mp);
            }
            else
            {
                this.state             = ScanState.InsertingOldAfterCall;
                this.next_end_old_type = this.subroutine.SubroutineFacade.MetaDataProvider.ReturnType(block.CalledMethod);
            }
        }
Пример #3
0
 public void StartBlock(EnsuresBlock <Label> block)
 {
     if (!this.block_start_state.TryGetValue(block, out this.state))
     {
         this.state = ScanState.OutsideOld;
         this.block_start_state.Add(block, this.state);
     }
     if (this.state == ScanState.InsertingOld)
     {
         block.StartOverridingLabels();
     }
     if (this.state == ScanState.InsertingOldAfterCall)
     {
         block.StartOverridingLabels();
         block.EndOldWithoutInstruction(this.next_end_old_type);
         this.state = ScanState.OutsideOld;
     }
     this.current_block = block;
 }