Ejemplo n.º 1
0
        public static int CompareByLexical(LogicalAddress a, LogicalAddress b)
        {
            int cmp = a.Referent.GetHashCode().CompareTo(b.Referent.GetHashCode());

            if (cmp == 0)
            {
                cmp = a.Displacement.CompareTo(b.Displacement);
            }
            return(cmp);
        }
Ejemplo n.º 2
0
        private void GenerateCallGraph()
        {
#if false
            foreach (XRef xref in program.CrossReferences)
            {
                LogicalAddress entryPoint = xref.Target;
                CallType       callType   =
                    (xref.Type == XRefType.NearCall) ?
                    CallType.Near : CallType.Far;

                // If there is already a procedure defined at that entry
                // point, perform some sanity checks.
                // TBD: should check and emit a message if two procedures
                // are defined at the same ResolvedAddress but with different
                // logical address.
                Procedure proc = program.Procedures.Find(entryPoint);
                if (proc != null)
                {
                    if (proc.CallType != callType)
                    {
                        AddError(entryPoint, ErrorCode.InconsistentCall,
                                 "Procedure at entry point {0} has inconsistent call type.",
                                 entryPoint);
                    }
                    // add call graph
                    continue;
                }

                // Create a procedure at the entry point. The entry point must
                // be the first byte of a basic block, or otherwise some flow
                // analysis error must have occurred. On the other hand, note
                // that multiple procedures may share one or more basic blocks
                // as part of their implementation.
                proc          = new Procedure(entryPoint);
                proc.Name     = "TBD";
                proc.CallType = callType;

                program.Procedures.Add(proc);
            }
#endif
        }