Esempio n. 1
0
        /// <summary>
        /// Processes the statements of a basic block by using the architecture-specific
        /// Rewriter to obtain a stream of low-level RTL instructions. RTL assignments are
        /// simply added to the instruction list of the basic block. Jumps, returns, and
        /// calls to procedures that terminate the thread of executationresult in the
        /// termination of processing.
        /// </summary>
        public override void Process()
        {
            state.ErrorListener = (message) => { scanner.Warn(ric.Address, message); };
            blockCur            = scanner.FindContainingBlock(addrStart);
            if (blockCur == null || BlockHasBeenScanned(blockCur))
            {
                return;
            }

            frame          = blockCur.Procedure.Frame;
            this.stackReg  = frame.EnsureRegister(arch.StackRegister);
            this.vaScanner = new VarargsFormatScanner(program, frame, state, scanner.Services);
            rtlStream      = scanner.GetTrace(addrStart, state, frame)
                             .GetEnumerator();

            while (rtlStream.MoveNext())
            {
                this.ric = rtlStream.Current;
                if (blockCur != scanner.FindContainingBlock(ric.Address))
                {
                    break;  // Fell off the end of this block.
                }
                if (!ProcessRtlCluster(ric))
                {
                    break;
                }
                var addrInstrEnd = ric.Address + ric.Length;
                var blNext       = FallenThroughNextProcedure(ric.Address, addrInstrEnd);
                if (blNext != null)
                {
                    EnsureEdge(blockCur.Procedure, blockCur, blNext);
                    return;
                }
                blNext = FallenThroughNextBlock(addrInstrEnd);
                if (blNext != null)
                {
                    EnsureEdge(blockCur.Procedure, blockCur, blNext);
                    return;
                }
            }
        }