示例#1
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);
            }
        }
示例#2
0
        public BlockWithLabels <Label> GetBlock(Label label)
        {
            IMetaDataProvider metadataDecoder = this.SubroutineFacade.MetaDataProvider;

            BlockWithLabels <Label> block;

            if (!this.LabelsThatStartBlocks.TryGetValue(label, out block))
            {
                Pair <Method, bool> methodVirtualPair;
                Method constructor;

                if (Builder == null)
                {
                    throw new InvalidOperationException("Builder must be not null");
                }

                if (Builder.IsMethodCallSite(label, out methodVirtualPair))
                {
                    int parametersCount = metadataDecoder.Parameters(methodVirtualPair.Key).Count;
                    block = new MethodCallBlock <Label> (methodVirtualPair.Key, this, ref this.BlockIdGenerator, parametersCount, methodVirtualPair.Value);
                }
                else if (Builder.IsNewObjSite(label, out constructor))
                {
                    int parametersCount = metadataDecoder.Parameters(constructor).Count;
                    block = new NewObjCallBlock <Label> (constructor, parametersCount, this, ref this.BlockIdGenerator);
                }
                else
                {
                    block = NewBlock();
                }

                if (Builder.IsTargetLabel(label))
                {
                    this.LabelsThatStartBlocks.Add(label, block);
                }
            }
            return(block);
        }