コード例 #1
0
        static void XRefObjects()
        {
            Console.Write("\nXRef objects ");
            Engine engine = CreateEngine();

            XRef v1 = new XRef(engine);
            XRef v2 = new XRef(engine);
            XRef v3 = new XRef(engine);

            v1.a = v2;
            v1.b = v3;
            v2.a = v1;
            v2.b = v3;
            v3.a = v1;
            v3.b = v2;

            engine.GCExecute();
            v1 = null;
            v2 = null;
            v3 = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            engine.GCExecute();

            DestroyEngine(engine);
        }
コード例 #2
0
ファイル: Shape.cs プロジェクト: trmcnealy/Plotly.WPF
        public bool Equals([AllowNull] Shape other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) &&
                   (Layer == other.Layer && Layer != null && other.Layer != null && Layer.Equals(other.Layer)) &&
                   (XRef == other.XRef && XRef != null && other.XRef != null && XRef.Equals(other.XRef)) &&
                   (XSizeMode == other.XSizeMode && XSizeMode != null && other.XSizeMode != null && XSizeMode.Equals(other.XSizeMode)) &&
                   (XAnchor == other.XAnchor && XAnchor != null && other.XAnchor != null && XAnchor.Equals(other.XAnchor)) &&
                   (X0 == other.X0 && X0 != null && other.X0 != null && X0.Equals(other.X0)) &&
                   (X1 == other.X1 && X1 != null && other.X1 != null && X1.Equals(other.X1)) &&
                   (YRef == other.YRef && YRef != null && other.YRef != null && YRef.Equals(other.YRef)) &&
                   (YSizeMode == other.YSizeMode && YSizeMode != null && other.YSizeMode != null && YSizeMode.Equals(other.YSizeMode)) &&
                   (YAnchor == other.YAnchor && YAnchor != null && other.YAnchor != null && YAnchor.Equals(other.YAnchor)) &&
                   (Y0 == other.Y0 && Y0 != null && other.Y0 != null && Y0.Equals(other.Y0)) &&
                   (Y1 == other.Y1 && Y1 != null && other.Y1 != null && Y1.Equals(other.Y1)) &&
                   (Path == other.Path && Path != null && other.Path != null && Path.Equals(other.Path)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (Line == other.Line && Line != null && other.Line != null && Line.Equals(other.Line)) &&
                   (FillColor == other.FillColor && FillColor != null && other.FillColor != null && FillColor.Equals(other.FillColor)) &&
                   (FillRule == other.FillRule && FillRule != null && other.FillRule != null && FillRule.Equals(other.FillRule)) &&
                   (Editable == other.Editable && Editable != null && other.Editable != null && Editable.Equals(other.Editable)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (TemplateItemName == other.TemplateItemName && TemplateItemName != null && other.TemplateItemName != null && TemplateItemName.Equals(other.TemplateItemName)));
        }
コード例 #3
0
        public void SetExternalXRefSpec()
        {
            var result = new Dictionary <string, XRefSpec>();

            // remove internal xref.
            var xref = XRef.Where(s => !XRefSpecMap.ContainsKey(s)).ToList();

            if (xref.Count == 0)
            {
                return;
            }

            if (ExternalReferencePackages.Length > 0)
            {
                using (var externalReferences = new ExternalReferencePackageCollection(ExternalReferencePackages, MaxParallelism))
                {
                    foreach (var uid in xref)
                    {
                        var spec = GetExternalReference(externalReferences, uid);
                        if (spec != null)
                        {
                            result[uid] = spec;
                        }
                    }
                }

                Logger.LogInfo($"{result.Count} external references found in {ExternalReferencePackages.Length} packages.");
            }

            ExternalXRefSpec = result;
        }
コード例 #4
0
ファイル: Image.cs プロジェクト: trmcnealy/Plotly.WPF
        public bool Equals([AllowNull] Image other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Source == other.Source && Source != null && other.Source != null && Source.Equals(other.Source)) &&
                   (Layer == other.Layer && Layer != null && other.Layer != null && Layer.Equals(other.Layer)) &&
                   (SizeX == other.SizeX && SizeX != null && other.SizeX != null && SizeX.Equals(other.SizeX)) &&
                   (SizeY == other.SizeY && SizeY != null && other.SizeY != null && SizeY.Equals(other.SizeY)) &&
                   (Sizing == other.Sizing && Sizing != null && other.Sizing != null && Sizing.Equals(other.Sizing)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (X == other.X && X != null && other.X != null && X.Equals(other.X)) &&
                   (Y == other.Y && Y != null && other.Y != null && Y.Equals(other.Y)) &&
                   (XAnchor == other.XAnchor && XAnchor != null && other.XAnchor != null && XAnchor.Equals(other.XAnchor)) &&
                   (YAnchor == other.YAnchor && YAnchor != null && other.YAnchor != null && YAnchor.Equals(other.YAnchor)) &&
                   (XRef == other.XRef && XRef != null && other.XRef != null && XRef.Equals(other.XRef)) &&
                   (YRef == other.YRef && YRef != null && other.YRef != null && YRef.Equals(other.YRef)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (TemplateItemName == other.TemplateItemName && TemplateItemName != null && other.TemplateItemName != null && TemplateItemName.Equals(other.TemplateItemName)));
        }
コード例 #5
0
        private static void PrepareIdentifiers()
        {
            namespaces.Clear();

            XNamespace currentNamespace = null;
            XClass     currentClass     = null;
            XRef       currentFile      = null;
            XMethod    currentMethod    = null;

            String path = null;
            int    ante, from, blockAt, to;

            foreach (string line in File.ReadAllLines(file))
            {
                ante    = 0;
                from    = 0;
                blockAt = 0;
                to      = 0;
                string[] elements = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (elements.Length > 0)
                {
                    switch (elements[0])
                    {
                    case "N":
                        currentNamespace = new XNamespace(elements[1]);
                        namespaces.Add(currentNamespace);
                        break;

                    case "\tC":
                        currentClass = new XClass(elements[1]);
                        currentNamespace.Classes.Add(currentClass);
                        break;

                    case "\t\tF":
                        currentFile = new XRef(new FileInfo(elements[1]), 0, 0, 0);
                        currentClass.Files.Add(currentFile);
                        break;

                    case "\t\t\tM":
                        currentMethod = new XMethod(elements[1]);
                        currentFile.Methods.Add(currentMethod);
                        string[] markers = elements[elements.Length - 1].Split(':');
                        if (markers.Length == 4)
                        {
                            int.TryParse(markers[0], out ante);
                            Array.Copy(markers, 1, markers, 0, markers.Length - 1);
                        }
                        if (int.TryParse(markers[0], out from) && int.TryParse(markers[1], out blockAt) && int.TryParse(markers[2], out to))
                        {
                            currentMethod.File = new XRef(currentFile.File, from, blockAt, to);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #6
0
ファイル: Title.cs プロジェクト: valu8/Plotly.Blazor
        /// <inheritdoc />
        public bool Equals([AllowNull] Title other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Text == other.Text ||
                     Text != null &&
                     Text.Equals(other.Text)
                     ) &&
                 (
                     Font == other.Font ||
                     Font != null &&
                     Font.Equals(other.Font)
                 ) &&
                 (
                     XRef == other.XRef ||
                     XRef != null &&
                     XRef.Equals(other.XRef)
                 ) &&
                 (
                     YRef == other.YRef ||
                     YRef != null &&
                     YRef.Equals(other.YRef)
                 ) &&
                 (
                     X == other.X ||
                     X != null &&
                     X.Equals(other.X)
                 ) &&
                 (
                     Y == other.Y ||
                     Y != null &&
                     Y.Equals(other.Y)
                 ) &&
                 (
                     XAnchor == other.XAnchor ||
                     XAnchor != null &&
                     XAnchor.Equals(other.XAnchor)
                 ) &&
                 (
                     YAnchor == other.YAnchor ||
                     YAnchor != null &&
                     YAnchor.Equals(other.YAnchor)
                 ) &&
                 (
                     Pad == other.Pad ||
                     Pad != null &&
                     Pad.Equals(other.Pad)
                 ));
        }
コード例 #7
0
        public bool Equals([AllowNull] Annotation other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) &&
                   (TextAngle == other.TextAngle && TextAngle != null && other.TextAngle != null && TextAngle.Equals(other.TextAngle)) &&
                   (Font == other.Font && Font != null && other.Font != null && Font.Equals(other.Font)) &&
                   (Width == other.Width && Width != null && other.Width != null && Width.Equals(other.Width)) &&
                   (Height == other.Height && Height != null && other.Height != null && Height.Equals(other.Height)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (Align == other.Align && Align != null && other.Align != null && Align.Equals(other.Align)) &&
                   (VAlign == other.VAlign && VAlign != null && other.VAlign != null && VAlign.Equals(other.VAlign)) &&
                   (BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (BorderPad == other.BorderPad && BorderPad != null && other.BorderPad != null && BorderPad.Equals(other.BorderPad)) &&
                   (BorderWidth == other.BorderWidth && BorderWidth != null && other.BorderWidth != null && BorderWidth.Equals(other.BorderWidth)) &&
                   (ShowArrow == other.ShowArrow && ShowArrow != null && other.ShowArrow != null && ShowArrow.Equals(other.ShowArrow)) &&
                   (ArrowColor == other.ArrowColor && ArrowColor != null && other.ArrowColor != null && ArrowColor.Equals(other.ArrowColor)) &&
                   (Arrowhead == other.Arrowhead && Arrowhead != null && other.Arrowhead != null && Arrowhead.Equals(other.Arrowhead)) &&
                   (StartArrowhead == other.StartArrowhead && StartArrowhead != null && other.StartArrowhead != null && StartArrowhead.Equals(other.StartArrowhead)) &&
                   (ArrowSide == other.ArrowSide && ArrowSide != null && other.ArrowSide != null && ArrowSide.Equals(other.ArrowSide)) &&
                   (ArrowSize == other.ArrowSize && ArrowSize != null && other.ArrowSize != null && ArrowSize.Equals(other.ArrowSize)) &&
                   (StartArrowSize == other.StartArrowSize && StartArrowSize != null && other.StartArrowSize != null && StartArrowSize.Equals(other.StartArrowSize)) &&
                   (ArrowWidth == other.ArrowWidth && ArrowWidth != null && other.ArrowWidth != null && ArrowWidth.Equals(other.ArrowWidth)) &&
                   (Standoff == other.Standoff && Standoff != null && other.Standoff != null && Standoff.Equals(other.Standoff)) &&
                   (StartStandoff == other.StartStandoff && StartStandoff != null && other.StartStandoff != null && StartStandoff.Equals(other.StartStandoff)) &&
                   (Ax == other.Ax && Ax != null && other.Ax != null && Ax.Equals(other.Ax)) &&
                   (Ay == other.Ay && Ay != null && other.Ay != null && Ay.Equals(other.Ay)) &&
                   (AXref == other.AXref && AXref != null && other.AXref != null && AXref.Equals(other.AXref)) &&
                   (AyRef == other.AyRef && AyRef != null && other.AyRef != null && AyRef.Equals(other.AyRef)) &&
                   (XRef == other.XRef && XRef != null && other.XRef != null && XRef.Equals(other.XRef)) &&
                   (X == other.X && X != null && other.X != null && X.Equals(other.X)) &&
                   (XAnchor == other.XAnchor && XAnchor != null && other.XAnchor != null && XAnchor.Equals(other.XAnchor)) &&
                   (XShift == other.XShift && XShift != null && other.XShift != null && XShift.Equals(other.XShift)) &&
                   (YRef == other.YRef && YRef != null && other.YRef != null && YRef.Equals(other.YRef)) &&
                   (Y == other.Y && Y != null && other.Y != null && Y.Equals(other.Y)) &&
                   (YAnchor == other.YAnchor && YAnchor != null && other.YAnchor != null && YAnchor.Equals(other.YAnchor)) &&
                   (YShift == other.YShift && YShift != null && other.YShift != null && YShift.Equals(other.YShift)) &&
                   (ClickToShow == other.ClickToShow && ClickToShow != null && other.ClickToShow != null && ClickToShow.Equals(other.ClickToShow)) &&
                   (XClick == other.XClick && XClick != null && other.XClick != null && XClick.Equals(other.XClick)) &&
                   (YClick == other.YClick && YClick != null && other.YClick != null && YClick.Equals(other.YClick)) &&
                   (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) &&
                   (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) &&
                   (CaptureEvents == other.CaptureEvents && CaptureEvents != null && other.CaptureEvents != null && CaptureEvents.Equals(other.CaptureEvents)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (TemplateItemName == other.TemplateItemName && TemplateItemName != null && other.TemplateItemName != null && TemplateItemName.Equals(other.TemplateItemName)));
        }
コード例 #8
0
ファイル: Title.cs プロジェクト: trmcnealy/Plotly.WPF
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Text != null)
                {
                    hashCode = hashCode * 59 + Text.GetHashCode();
                }

                if (Font != null)
                {
                    hashCode = hashCode * 59 + Font.GetHashCode();
                }

                if (XRef != null)
                {
                    hashCode = hashCode * 59 + XRef.GetHashCode();
                }

                if (YRef != null)
                {
                    hashCode = hashCode * 59 + YRef.GetHashCode();
                }

                if (X != null)
                {
                    hashCode = hashCode * 59 + X.GetHashCode();
                }

                if (Y != null)
                {
                    hashCode = hashCode * 59 + Y.GetHashCode();
                }

                if (XAnchor != null)
                {
                    hashCode = hashCode * 59 + XAnchor.GetHashCode();
                }

                if (YAnchor != null)
                {
                    hashCode = hashCode * 59 + YAnchor.GetHashCode();
                }

                if (Pad != null)
                {
                    hashCode = hashCode * 59 + Pad.GetHashCode();
                }

                return(hashCode);
            }
        }
コード例 #9
0
        public void SetExternalXRefSpec()
        {
            var result = new Dictionary <string, XRefSpec>();

            // remove internal xref.
            var xref = XRef.Where(s => !UidMap.ContainsKey(s.Key)).ToDictionary(s => s.Key, s => s.Value);

            if (xref.Count == 0)
            {
                return;
            }

            var missingUids = new List <KeyValuePair <string, HashSet <string> > >();

            if (ExternalReferencePackages.Length > 0)
            {
                using (var externalReferences = new ExternalReferencePackageCollection(ExternalReferencePackages))
                {
                    foreach (var uid in xref.Keys)
                    {
                        var spec = GetExternalReference(externalReferences, uid);
                        if (spec != null)
                        {
                            result[uid] = spec;
                        }
                        else
                        {
                            if (missingUids.Count < 100)
                            {
                                missingUids.Add(new KeyValuePair <string, HashSet <string> >(uid, xref[uid]));
                            }
                        }
                    }
                }
            }
            else
            {
                missingUids.AddRange(xref.Take(100));
            }
            if (missingUids.Count > 0)
            {
                var uidLines = string.Join(Environment.NewLine + "\t", missingUids.Select(s => "@" + s.Key + " in files \"" + string.Join(",", s.Value.Select(p => p.ToDisplayPath())) + "\""));
                if (missingUids.Count < 100)
                {
                    Logger.LogWarning($"Missing following definitions of cross-reference:{Environment.NewLine}\t{uidLines}");
                }
                else
                {
                    Logger.LogWarning($"Too many missing definitions of cross-reference, following is top 100:{Environment.NewLine}\t{uidLines}");
                }
            }
            ExternalXRefSpec = result;
        }
コード例 #10
0
ファイル: BE.cs プロジェクト: areyram/cursos
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        internal static Type[] BackTrack(Type t)
        {
            var l = new List <Type>(new[] { t });

            if (t != null && XRef.ContainsKey(t))
            {
                var o = XRef[t].ToList();
                foreach (var u in o)
                {
                    l.AddRange(BackTrack(u));
                }
                o.AddRange(l.Where(p => !o.Contains(p)));
                return(o.ToArray());
            }
            return(l.ToArray());
        }
コード例 #11
0
        public void AddEdge(BasicBlock source, BasicBlock target, XRef xref)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (target == null)
                throw new ArgumentNullException("target");
            if (xref == null)
                throw new ArgumentNullException("xref");

            System.Diagnostics.Debug.Assert(blocks.Contains(source));
            System.Diagnostics.Debug.Assert(blocks.Contains(target));

            XRef xFlow = new XRef(
                type: xref.Type,
                source: source.Location,
                target: target.Location,
                dataLocation: xref.Source
            );
            graph.Add(xFlow);
        }
コード例 #12
0
        public void UseCustomRemotionReflector_NonExistingAssembly()
        {
            var assemblyDir = Path.GetFullPath(@".");
            var outputDir   = Path.GetFullPath(@"CustomReflectorOutput");

            var sender = MockRepository.GenerateStub <IMessageSender> ();

            sender.Expect(s => s.SendError("Custom reflector can not be found"));

            var result = XRef.Run(new XRefArguments
            {
                AssemblyDirectory = assemblyDir,
                OutputDirectory   = outputDir,
                ReflectorSource   = ReflectorSource.CustomReflector,
                CustomReflectorAssemblyQualifiedTypeName =
                    "MixinXRef.UnitTests.CustomRemotionReflector.CustomRemotionReflector, NonExistingAssembly",
                OverwriteExistingFiles = true
            }, sender);

            Assert.That(result, Is.False);
        }
コード例 #13
0
ファイル: CallGraph.cs プロジェクト: meloscheng/dos-debugger
        public void AddEdge(Procedure caller, Procedure callee, XRef xref)
        {
            if (caller == null)
                throw new ArgumentNullException("caller");
            if (callee == null)
                throw new ArgumentNullException("callee");
            if (xref == null)
                throw new ArgumentNullException("xref");

            System.Diagnostics.Debug.Assert(procedures.Contains(caller));
            System.Diagnostics.Debug.Assert(procedures.Contains(callee));

            // TBD: check that the xref indeed refers to these two
            // procedures.
            XRef xCall = new XRef(
                type: xref.Type,
                source: caller.EntryPoint,
                target: callee.EntryPoint,
                dataLocation: xref.Source
            );
            graph.Add(xCall);
        }
コード例 #14
0
ファイル: Shape.cs プロジェクト: valu8/Plotly.Blazor
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Layer != null)
         {
             hashCode = hashCode * 59 + Layer.GetHashCode();
         }
         if (XRef != null)
         {
             hashCode = hashCode * 59 + XRef.GetHashCode();
         }
         if (XSizeMode != null)
         {
             hashCode = hashCode * 59 + XSizeMode.GetHashCode();
         }
         if (XAnchor != null)
         {
             hashCode = hashCode * 59 + XAnchor.GetHashCode();
         }
         if (X0 != null)
         {
             hashCode = hashCode * 59 + X0.GetHashCode();
         }
         if (X1 != null)
         {
             hashCode = hashCode * 59 + X1.GetHashCode();
         }
         if (YRef != null)
         {
             hashCode = hashCode * 59 + YRef.GetHashCode();
         }
         if (YSizeMode != null)
         {
             hashCode = hashCode * 59 + YSizeMode.GetHashCode();
         }
         if (YAnchor != null)
         {
             hashCode = hashCode * 59 + YAnchor.GetHashCode();
         }
         if (Y0 != null)
         {
             hashCode = hashCode * 59 + Y0.GetHashCode();
         }
         if (Y1 != null)
         {
             hashCode = hashCode * 59 + Y1.GetHashCode();
         }
         if (Path != null)
         {
             hashCode = hashCode * 59 + Path.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Line != null)
         {
             hashCode = hashCode * 59 + Line.GetHashCode();
         }
         if (FillColor != null)
         {
             hashCode = hashCode * 59 + FillColor.GetHashCode();
         }
         if (FillRule != null)
         {
             hashCode = hashCode * 59 + FillRule.GetHashCode();
         }
         if (Editable != null)
         {
             hashCode = hashCode * 59 + Editable.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (TemplateItemName != null)
         {
             hashCode = hashCode * 59 + TemplateItemName.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #15
0
        /// <summary>
        /// Creates an instruction starting at the given address. If the
        /// decoded instruction covers bytes that are already analyzed,
        /// returns null.
        /// </summary>
        /// <param name="image"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        protected virtual Instruction CreateInstruction(Address address, XRef entry)
        {
            Instruction instruction = DecodeInstruction(address);
            if (instruction == null)
                return null;

            // Check that the bytes covered by the decoded instruction are
            // unanalyzed.
            if (!image.CheckByteType(address, address + instruction.EncodedLength, ByteType.Unknown))
            {
                AddError(address, ErrorCode.OverlappingInstruction,
                    "Ran into the middle of code when processing block {0} referred from {1}",
                    entry.Target, entry.Source);
                return null;
            }

            // Create a code piece for this instruction.
            image.UpdateByteType(address, address + instruction.EncodedLength, ByteType.Code);
            image.Instructions.Add(address, instruction);

            // Return the decoded instruction.
            return instruction;
        }
コード例 #16
0
        /// <summary>
        ///     The implementation of VsShell.ISelectionContainer.SelectObjects in
        ///     ModelingWindowPane calls DoSelectObjects()
        ///     - base calls to DiagramDocView : ModelingDocView : ModelingWindowPane
        ///     if (this.CurrentDesigner != null) -> sets selection in the current designer
        ///     else calls to ModelingWindowPane which is a no-op
        ///     This seems to only be called when the user chooses an item from the
        ///     drop down box at the top of the properties screen
        /// </summary>
        /// <returns></returns>
        protected override void DoSelectObjects(uint count, object[] objects, uint flags)
        {
            // We have to reverse the logic of the GetSelectX fn above; that is, convert the
            // array of our ItemDescriptors back into an array of Dsl ModelElements before
            // calling the base impl; the base impl will then select the shape
            var  objectsSelected         = new ArrayList();
            var  selectedModelObjects    = new List <EFObject>();
            uint nonPropertyObjectsCount = 0;

            if (count > 0)
            {
                foreach (var o in objects)
                {
                    var typeDesc = o as ObjectDescriptor;
                    Debug.Assert(typeDesc != null, "Something unexpected was selected");
                    if (typeDesc != null)
                    {
                        selectedModelObjects.Add(typeDesc.WrappedItem);

                        // Properties do not have a corresponding ShapeElement; the instance of the DomainClass is just an item
                        // within the ElementListCompartment. Since this override only accepts a list of ShapeElements, we will
                        // have to use the DSLDesignerNavigationHelper to create a DiagramItem that uniquely identifies the
                        // list compartment item and select that.
                        if (typeDesc.WrappedItem is PropertyBase)
                        {
                            DSLDesignerNavigationHelper.NavigateTo(typeDesc.WrappedItem);
                        }
                        else
                        {
                            // For all other EFObjects, we can attempt to get a ShapeElement
                            nonPropertyObjectsCount++;
                            var dslElem  = XRef.GetExisting(typeDesc.WrappedItem);
                            var presElem = dslElem as DslDiagrams.PresentationElement;
                            if (presElem == null)
                            {
                                var shapes =
                                    DslDiagrams.PresentationViewsSubject.GetPresentation(dslElem);

                                // just select the first shape for this item
                                if (shapes != null &&
                                    shapes.Count > 0)
                                {
                                    presElem = shapes[0];
                                }
                            }

                            Debug.Assert(presElem != null, "Why couldn't we find the shape for this ModelElement?");

                            if (presElem != null)
                            {
                                objectsSelected.Add(presElem);
                            }
                        }
                    }
                }

                Debug.Assert(
                    nonPropertyObjectsCount == objectsSelected.Count,
                    "nonPropertyObjectsCount(" + nonPropertyObjectsCount + ") != objectsSelected.Count (" + objectsSelected.Count + ")");
            }

            // update the selection for the Entity Designer in case anyone else is interested
            Context.Items.SetValue(new EntityDesignerSelection(selectedModelObjects));

            if (nonPropertyObjectsCount > 0 &&
                nonPropertyObjectsCount == objectsSelected.Count)
            {
                // If we didn't encounter any property descriptors and the number of those descriptors equals the objects selected,
                // then we can pass this on to the base implementation to perform the selection
                var objectsToSelect = new object[objectsSelected.Count];
                objectsSelected.CopyTo(objectsToSelect, 0);
                base.DoSelectObjects(nonPropertyObjectsCount, objectsToSelect, flags);
            }
            else if (nonPropertyObjectsCount != objectsSelected.Count)
            {
                // We should have found objects to select from all the non-property descriptors. If for some reason we didn't,
                // then we pass this onto the base implementation
                base.DoSelectObjects(count, objects, flags);
            }
        }
コード例 #17
0
ファイル: XRefAuthority.cs プロジェクト: AArnott/dotnetxri
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty())
            {
                return false;
            }

            ParseStream oTempStream = oStream.begin();

            // make sure we have a valid XRI Value
            XRef oXRef = new XRef();
            if (!oXRef.scan(oTempStream))
            {
                return false;
            }

            // at this point, we know we have enough for a valid xref
            oStream.end(oTempStream);
            moXRoot = oXRef;

            // the cross-reference MAY be followed by an XRI Segment
            // where the star cannot be assumed
            XRISegment oSegment = new XRISegment(false, true, true);
            if (oSegment.scan(oStream))
            {
                moSegment = oSegment;
            }

            return true;
        }
コード例 #18
0
 public PDFLink(XRef xref, int objNo)
 {
     _xref  = xref;
     _objNo = objNo;
 }
コード例 #19
0
        /// <summary>
        ///     This uses the XRef in our context to find the Model item that is the basis for
        ///     each DSL object in the selection collection.  For each Model item, we get the correct
        ///     item descriptor and create a new selection array of these.
        /// </summary>
        /// <param name="objects"></param>
        /// <returns></returns>
        private ArrayList ConvertDslModelElementArrayToItemDescriptors(object[] objects, bool gettingAllObjects)
        {
            // save off this reference
            var selectedDesignerObjects = objects;

            // create a new array to hold the item descriptors
            var selectedModelObjects           = new List <EFObject>();
            var selectedModelObjectDescriptors = new ArrayList();

            foreach (var o in selectedDesignerObjects)
            {
                DslModeling.ModelElement dslElem = null;
                var elemList = o as DslDiagrams.ElementListCompartment;
                var presElem = o as DslDiagrams.PresentationElement;
                if (elemList != null)
                {
                    // if the user selects a compartment element, we want to display the entity-type and the shape property.
                    if (elemList.IsNestedChild &&
                        elemList.ParentShape != null)
                    {
                        presElem = elemList.ParentShape;
                        dslElem  = presElem.ModelElement;
                    }
                    else
                    {
                        // they have selected one of the compartments, probably wanting to show
                        // the right-click context menu
                        continue;
                    }
                }
                else if (presElem != null)
                {
                    // if this is a shape, gets it corresponding DSL object
                    dslElem = presElem.ModelElement;
                }
                else
                {
                    // o is a non-shape
                    dslElem = o as DslModeling.ModelElement;
                }

                // there might be no ModelElement corresponding to the selected object
                if (dslElem != null)
                {
                    EFObject modelElem;
                    // If an EntityType is selected in DSL canvas, we want to show the property of the EntityTypeShape.
                    if (dslElem is EntityType &&
                        presElem != null)
                    {
                        modelElem = XRef.GetExisting(presElem);
                    }
                    else
                    {
                        modelElem = XRef.GetExisting(dslElem);
                    }
                    // model element might not be yet created
                    if (modelElem != null)
                    {
                        selectedModelObjects.Add(modelElem);
                        selectedModelObjectDescriptors.Add(PropertyWindowViewModel.GetObjectDescriptor(modelElem, Context, true));
                    }
                }
            }

            if (gettingAllObjects == false)
            {
                // update the selection for the Entity Designer in case anyone else is interested
                if (Context != null &&
                    Context.Items != null)
                {
                    Context.Items.SetValue(new EntityDesignerSelection(selectedModelObjects));
                }
            }

            return(selectedModelObjectDescriptors);
        }
コード例 #20
0
        public void DefaultValuesTest()
        {
            using (var session = Domain.OpenSession()) {
                Key keyX;
                Key keyY = null;
                Key keyZ = null;
                using (var t = session.OpenTransaction()) {
                    // To be sure that the reference field (X.Ref) would have meaning
                    _    = new XRef(new Guid(CodeRegistry.GuidKeyValue));
                    _    = new EnumKeyEntity(CodeRegistry.EnumKeyValue);
                    keyX = new X().Key;

                    if (SupportsDefaultForLongString())
                    {
                        keyY = new Y().Key;
                    }

                    if (SupportsDefaultForArrays())
                    {
                        keyZ = new Z().Key;
                    }
                    t.Complete();
                }

                using (var t = session.OpenTransaction()) {
                    var x = session.Query.SingleOrDefault <X>(keyX);
                    Assert.AreEqual(true, x.FBool);
                    Assert.AreEqual(byte.MaxValue, x.FByte);
                    Assert.AreEqual(DateTime.Parse("2012.12.12"), x.FDateTime);
                    Assert.AreEqual(12.12M, x.FDecimal);
                    Assert.AreEqual(float.MaxValue, x.FDouble);
                    Assert.AreEqual(EByte.Max, x.FEByte);
                    Assert.AreEqual(EInt.Max, x.FEInt);
                    Assert.AreEqual(ELong.Max, x.FELong);
                    Assert.AreEqual(ESByte.Max, x.FESByte);
                    Assert.AreEqual(EShort.Max, x.FEShort);
                    Assert.AreEqual(EUInt.Max, x.FEUInt);
                    Assert.AreEqual(EULong.Max, x.FEULong);
                    Assert.AreEqual(EUShort.Max, x.FEUShort);
                    Assert.AreEqual(float.MaxValue, x.FFloat);
                    Assert.AreEqual(new Guid(CodeRegistry.GuidDefaultValue), x.FGuid);
                    Assert.AreEqual(int.MaxValue, x.FInt);
                    Assert.AreEqual(long.MaxValue, x.FLong);

                    Assert.AreEqual(sbyte.MaxValue, x.FSByte);
                    Assert.AreEqual(short.MaxValue, x.FShort);
                    Assert.AreEqual("default value", x.FString);
                    Assert.AreEqual(TimeSpan.FromTicks(1000), x.FTimeSpan);
                    Assert.AreEqual(uint.MaxValue, x.FUInt);
                    Assert.AreEqual(long.MaxValue, x.FULong);
                    Assert.AreEqual(ushort.MaxValue, x.FUShort);

                    Assert.AreEqual(true, x.FNBool);
                    Assert.AreEqual(byte.MaxValue, x.FNByte);
                    Assert.AreEqual(DateTime.Parse("2012.12.12"), x.FNDateTime);
                    Assert.AreEqual(12.12M, x.FNDecimal);
                    Assert.AreEqual(float.MaxValue, x.FNDouble);
                    Assert.AreEqual(EByte.Max, x.FNEByte);
                    Assert.AreEqual(EInt.Max, x.FNEInt);
                    Assert.AreEqual(ELong.Max, x.FNELong);
                    Assert.AreEqual(ESByte.Max, x.FNESByte);
                    Assert.AreEqual(EShort.Max, x.FNEShort);
                    Assert.AreEqual(EUInt.Max, x.FNEUInt);
                    Assert.AreEqual(EULong.Max, x.FNEULong);
                    Assert.AreEqual(EUShort.Max, x.FNEUShort);
                    Assert.AreEqual(float.MaxValue, x.FNFloat);
                    Assert.AreEqual(new Guid(CodeRegistry.GuidDefaultValue), x.FNGuid);
                    Assert.AreEqual(int.MaxValue, x.FNInt);
                    Assert.AreEqual(long.MaxValue, x.FNLong);
                    Assert.AreEqual(sbyte.MaxValue, x.FNSByte);
                    Assert.AreEqual(short.MaxValue, x.FNShort);
                    Assert.AreEqual(TimeSpan.FromTicks(1000), x.FNTimeSpan);
                    Assert.AreEqual(uint.MaxValue, x.FNUInt);
                    Assert.AreEqual(long.MaxValue, x.FNULong);
                    Assert.AreEqual(ushort.MaxValue, x.FNUShort);
                    Assert.IsNotNull(x.Ref);
                    Assert.IsNotNull(x.EnumKeyEntityRef);

                    if (SupportsDefaultForLongString())
                    {
                        var y = session.Query.SingleOrDefault <Y>(keyY);
                        Assert.AreEqual("default value", y.FLongString);
                    }
                    if (SupportsDefaultForArrays())
                    {
                        var z = session.Query.SingleOrDefault <Z>(keyZ);
                        Assert.AreEqual(new byte[] { 10, 10, 10, 10 }, z.FByteArray);
                        Assert.AreEqual(new byte[] { 10, 10, 10, 10 }, z.FLongByteArray);
                    }

                    t.Complete();
                }
            }
        }
コード例 #21
0
 public void Collect(XRef xref)
 {
 }
コード例 #22
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (Text != null)
         {
             hashCode = hashCode * 59 + Text.GetHashCode();
         }
         if (TextAngle != null)
         {
             hashCode = hashCode * 59 + TextAngle.GetHashCode();
         }
         if (Font != null)
         {
             hashCode = hashCode * 59 + Font.GetHashCode();
         }
         if (Width != null)
         {
             hashCode = hashCode * 59 + Width.GetHashCode();
         }
         if (Height != null)
         {
             hashCode = hashCode * 59 + Height.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Align != null)
         {
             hashCode = hashCode * 59 + Align.GetHashCode();
         }
         if (VAlign != null)
         {
             hashCode = hashCode * 59 + VAlign.GetHashCode();
         }
         if (BgColor != null)
         {
             hashCode = hashCode * 59 + BgColor.GetHashCode();
         }
         if (BorderColor != null)
         {
             hashCode = hashCode * 59 + BorderColor.GetHashCode();
         }
         if (BorderPad != null)
         {
             hashCode = hashCode * 59 + BorderPad.GetHashCode();
         }
         if (BorderWidth != null)
         {
             hashCode = hashCode * 59 + BorderWidth.GetHashCode();
         }
         if (ShowArrow != null)
         {
             hashCode = hashCode * 59 + ShowArrow.GetHashCode();
         }
         if (ArrowColor != null)
         {
             hashCode = hashCode * 59 + ArrowColor.GetHashCode();
         }
         if (Arrowhead != null)
         {
             hashCode = hashCode * 59 + Arrowhead.GetHashCode();
         }
         if (StartArrowhead != null)
         {
             hashCode = hashCode * 59 + StartArrowhead.GetHashCode();
         }
         if (ArrowSide != null)
         {
             hashCode = hashCode * 59 + ArrowSide.GetHashCode();
         }
         if (ArrowSize != null)
         {
             hashCode = hashCode * 59 + ArrowSize.GetHashCode();
         }
         if (StartArrowSize != null)
         {
             hashCode = hashCode * 59 + StartArrowSize.GetHashCode();
         }
         if (ArrowWidth != null)
         {
             hashCode = hashCode * 59 + ArrowWidth.GetHashCode();
         }
         if (Standoff != null)
         {
             hashCode = hashCode * 59 + Standoff.GetHashCode();
         }
         if (StartStandoff != null)
         {
             hashCode = hashCode * 59 + StartStandoff.GetHashCode();
         }
         if (Ax != null)
         {
             hashCode = hashCode * 59 + Ax.GetHashCode();
         }
         if (Ay != null)
         {
             hashCode = hashCode * 59 + Ay.GetHashCode();
         }
         if (AXref != null)
         {
             hashCode = hashCode * 59 + AXref.GetHashCode();
         }
         if (AyRef != null)
         {
             hashCode = hashCode * 59 + AyRef.GetHashCode();
         }
         if (XRef != null)
         {
             hashCode = hashCode * 59 + XRef.GetHashCode();
         }
         if (X != null)
         {
             hashCode = hashCode * 59 + X.GetHashCode();
         }
         if (XAnchor != null)
         {
             hashCode = hashCode * 59 + XAnchor.GetHashCode();
         }
         if (XShift != null)
         {
             hashCode = hashCode * 59 + XShift.GetHashCode();
         }
         if (YRef != null)
         {
             hashCode = hashCode * 59 + YRef.GetHashCode();
         }
         if (Y != null)
         {
             hashCode = hashCode * 59 + Y.GetHashCode();
         }
         if (YAnchor != null)
         {
             hashCode = hashCode * 59 + YAnchor.GetHashCode();
         }
         if (YShift != null)
         {
             hashCode = hashCode * 59 + YShift.GetHashCode();
         }
         if (ClickToShow != null)
         {
             hashCode = hashCode * 59 + ClickToShow.GetHashCode();
         }
         if (XClick != null)
         {
             hashCode = hashCode * 59 + XClick.GetHashCode();
         }
         if (YClick != null)
         {
             hashCode = hashCode * 59 + YClick.GetHashCode();
         }
         if (HoverText != null)
         {
             hashCode = hashCode * 59 + HoverText.GetHashCode();
         }
         if (HoverLabel != null)
         {
             hashCode = hashCode * 59 + HoverLabel.GetHashCode();
         }
         if (CaptureEvents != null)
         {
             hashCode = hashCode * 59 + CaptureEvents.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (TemplateItemName != null)
         {
             hashCode = hashCode * 59 + TemplateItemName.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #23
0
        /// <summary>
        /// Analyzes a contiguous sequence of instructions that form a basic
        /// block. A basic block terminates as soon as any of the following
        /// conditions is true:
        /// - An analysis error occurs
        /// - An block terminating instructions: RET, RETF, IRET, HLT.
        /// - A b/c/j instruction: Jcc, JMP, JMPF, LOOPcc.
        /// </summary>
        /// <param name="start">Address to begin analysis.</param>
        /// <param name="xrefs">Collection to add xrefs to.</param>
        /// <returns>
        /// A new BasicBlock if one was created during the analysis.
        /// If no new BasicBlocks are created, or if an existing block was
        /// split into two, returns null.
        /// </returns>
        // TODO: should be roll-back the entire basic block if we
        // encounters an error on our way? maybe not.
        protected virtual BasicBlock AnalyzeBasicBlock(XRef start, ICollection<XRef> xrefs)
        {
            Address ip = start.Target; // instruction pointer

            if (!image.IsAddressValid(ip))
            {
                AddError(ip, ErrorCode.OutOfImage,
                   "XRef target is outside of the image (referred from {0})",
                   start.Source);
                return null;
            }

            // Check if the entry address is already analyzed.
            ByteAttribute b = image[ip];
            if (b.Type != ByteType.Unknown)
            {
                // Fail if we ran into data or padding while expecting code.
                if (b.Type != ByteType.Code)
                {
                    AddError(ip, ErrorCode.RanIntoData,
                        "XRef target is in the middle of data (referred from {0})",
                        start.Source);
                    return null;
                }

                // Now the byte was previously analyzed as code. We must have
                // already created a basic block that contains this byte.
                BasicBlock block = BasicBlocks.Find(ip);
                System.Diagnostics.Debug.Assert(block != null);

                // If the existing block starts at this address, we're done.
                if (block.Location == ip)
                    return null;

                // TBD: recover the following in some way...
            #if false
                    if (image[b.BasicBlock.StartAddress].Address.Segment != pos.Segment)
                    {
                        AddError(pos, ErrorCategory.Error,
                            "Ran into the middle of a block [{0},{1}) from another segment " +
                            "when processing block {2} referred from {3}",
                            b.BasicBlock.StartAddress, b.BasicBlock.EndAddress,
                            start.Target, start.Source);
                        return null;
                    }
            #endif

                // Now split the existing basic block into two. This requires
                // that the cut-off point is at instruction boundary.
                if (!b.IsLeadByte)
                {
                    AddError(ip, ErrorCode.RanIntoCode,
                        "XRef target is in the middle of an instruction (referred from {0})",
                        start.Source);
                    return null;
                }
                BasicBlock[] subBlocks = BasicBlocks.SplitBasicBlock(block, ip, image);

                // Create a xref from the previous block to this block.
                XRef xref = CreateFallThroughXRef(GetLastInstructionInBasicBlock(subBlocks[0]), ip);
                xrefs.Add(xref);

                return null;
            }
            // TODO: Move the above into a separate procedure.

            // Analyze each instruction in sequence until we encounter
            // analyzed code, flow instruction, or an error condition.
            BasicBlockType blockType = BasicBlockType.Unknown;
            while (true)
            {
                // Decode an instruction at this location.
                Address instructionStart = ip;
                Instruction insn = CreateInstruction(ip, start);
                if (insn == null)
                {
                    AddError(ip, ErrorCode.BrokenBasicBlock,
                        "Basic block ended prematurally because of invalid instruction.");
                    blockType = BasicBlockType.Broken;
                    break;
                }
                Address instructionEnd = ip + insn.EncodedLength;

                // Advance the instruction pointer.
                ip = instructionEnd;

                // Determine whether this instruction affects control flow.
                XRefType flowType = GetFlowInstructionType(insn.Operation);

                if (flowType != XRefType.None)
                {
                    // Creates an active cross reference if necessary.
                    if (NeedsActiveXRef(flowType))
                    {
                        XRef xref = CreateFlowXRef(flowType, instructionStart, insn);
                        if (xref != null)
                            xrefs.Add(xref);
                    }

                    // Creates a fall-through cross reference if necessary.
                    if (CanFallThrough(flowType))
                    {
                        XRef xref = CreateFallThroughXRef(instructionStart, instructionEnd);
                        xrefs.Add(xref);
                    }

                    // Terminate the block.
                    blockType = GetBasicBlockType(flowType);
                    break;
                }

                // If the new location is already analyzed as code, create a
                // control-flow edge from the previous block to the existing
                // block, and we are done.
                if (!image.IsAddressValid(ip))
                {
                    blockType = BasicBlockType.Broken;
                    break;
                }
                if (image[ip].Type == ByteType.Code)
                {
                    System.Diagnostics.Debug.Assert(image[ip].IsLeadByte);

                    XRef xref = CreateFallThroughXRef(instructionStart, instructionEnd);
                    xrefs.Add(xref);
                    blockType = BasicBlockType.FallThrough;
                    break;
                }
            }

            // Create a basic block unless we failed on the first instruction.
            if (ip.Offset > start.Target.Offset)
            {
                BasicBlock block = new BasicBlock(start.Target, ip, blockType, image);
                BasicBlocks.Add(block);
            }
            return null;
        }
コード例 #24
0
        public OBO_Instance(List <KeyValuePair <string, string> > data = null)
        {
            if (data != null)
            {
                foreach (var datum in data)
                {
                    switch (datum.Key.ToLower())
                    {
                    case "id":
                        Id = datum.Value;
                        break;

                    case "is_anonymous":
                        IsAnonymous = Convert.ToBoolean(datum.Value);
                        break;

                    case "name":
                        Name = datum.Value;
                        break;

                    case "namespace":
                        Namespace = datum.Value;
                        break;

                    case "alt_id":
                        AltId.Add(datum.Value);
                        break;

                    case "comment":
                        Comment = datum.Value;
                        break;

                    case "synonym":
                        Synonym.Add(datum.Value);
                        break;

                    case "xref":
                        XRef.Add(datum.Value);
                        break;

                    case "instance_of":
                        InstanceOf = datum.Value;
                        break;

                    case "property_value":
                        Property_Value.Add(datum.Value);
                        break;

                    case "is_obsolete":
                        IsObsolete = Convert.ToBoolean(datum.Value);
                        break;

                    case "replaced_by":
                        ReplacedBy.Add(datum.Value);
                        break;

                    case "consider":
                        Consider.Add(datum.Value);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #25
0
            public OBO_Term(List <KeyValuePair <string, string> > data = null)
            {
                if (data != null)
                {
                    foreach (var datum in data)
                    {
                        switch (datum.Key.ToLower())
                        {
                        case "id":
                            Id = datum.Value;
                            break;

                        case "is_anonymous":
                            IsAnonymous = Convert.ToBoolean(datum.Value);
                            break;

                        case "name":
                            Name = datum.Value;
                            break;

                        case "namespace":
                            Namespace = datum.Value;
                            break;

                        case "alt_id":
                            AltId.Add(datum.Value);
                            break;

                        case "def":
                            Def = datum.Value;
                            break;

                        case "comment":
                            Comment = datum.Value;
                            break;

                        case "subset":
                            Subset.Add(datum.Value);
                            break;

                        case "synonym":
                            Synonym.Add(datum.Value);
                            break;

                        case "xref":
                            XRef.Add(datum.Value);
                            break;

                        case "is_a":
                            IsA.Add(datum.Value);
                            break;

                        case "intersection_of":
                            IntersectionOf.Add(datum.Value);
                            break;

                        case "union_of":
                            UnionOf.Add(datum.Value);
                            break;

                        case "disjoint_from":
                            DisjointFrom.Add(datum.Value);
                            break;

                        case "relationship":
                            Relationship.Add(datum.Value);
                            break;

                        case "is_obsolete":
                            IsObsolete = Convert.ToBoolean(datum.Value);
                            break;

                        case "replaced_by":
                            ReplacedBy.Add(datum.Value);
                            break;

                        case "consider":
                            Consider.Add(datum.Value);
                            break;

                        case "created_by":
                            CreatedBy = datum.Value;
                            break;

                        case "creation_date":
                            CreationDate = datum.Value;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
コード例 #26
0
        private BasicBlock AnalyzeBasicBlock(XRef start, ICollection<XRef> xrefs)
        {
            Pointer pos = start.Target;

            // Check if we are running into the middle of code or data. This
            // can only happen when we process the first instruction in the
            // block.
            if (image[pos].Type != ByteType.Unknown && !image[pos].IsLeadByte)
            {
                AddError(pos, ErrorCategory.Error,
                    "XRef target is in the middle of code/data (referred from {0})",
                    start.Source);
                return null;
            }

            // Check if this location is already analyzed as code.
            if (image[pos].Type == ByteType.Code)
            {
                ByteProperties b = image[pos];

                // Now we are already covered by a basic block. If the
                // basic block *starts* from this address, do nothing.
                // Otherwise, split the basic block into two.
                if (b.BasicBlock.StartAddress == pos.LinearAddress)
                {
                    return null;
                }
                else
                {
                    if (image[b.BasicBlock.StartAddress].Address.Segment != pos.Segment)
                    {
                        AddError(pos, ErrorCategory.Error,
                            "Ran into the middle of a block [{0},{1}) from another segment " +
                            "when processing block {2} referred from {3}",
                            b.BasicBlock.StartAddress, b.BasicBlock.EndAddress,
                            start.Target, start.Source);
                        return null;
                    }
                    BasicBlock newBlock = b.BasicBlock.Split(pos.LinearAddress);
                    return null; // newBlock;
                }
            }

            // Analyze each instruction in sequence until we encounter
            // analyzed code, flow instruction, or an error condition.
            while (true)
            {
                // Decode an instruction at this location.
                Pointer insnPos = pos;
                Instruction insn;
                try
                {
                    insn = image.DecodeInstruction(pos);
                }
                catch (Exception ex)
                {
                    AddError(pos, ErrorCategory.Error, "Bad instruction: {0}", ex.Message);
                    break;
                }

                // Create a code piece for this instruction.
                if (!image.CheckByteType(pos, pos + insn.EncodedLength, ByteType.Unknown))
                {
                    AddError(pos, 
                        "Ran into the middle of code when processing block {0} referred from {1}",
                        start.Target, start.Source);
                    break;
                }

                // Advance the byte pointer. Note: the IP may wrap around 0xFFFF 
                // if pos.off + count > 0xFFFF. This is probably not intended.
                try
                {
                    Piece piece = image.CreatePiece(pos, pos + insn.EncodedLength, ByteType.Code);
                    pos += insn.EncodedLength;
                }
                catch (AddressWrappedException)
                {
                    AddError(pos, ErrorCategory.Error,
                        "CS:IP wrapped when processing block {1} referred from {2}",
                        start.Target, start.Source);
                    break;
                }

                // Check if this instruction terminates the block.
                if (insn.Operation == Operation.RET ||
                    insn.Operation == Operation.RETF ||
                    insn.Operation == Operation.HLT)
                    break;

                // Analyze BCJ (branch, jump, call) instructions. Such an
                // instruction will create a cross reference.
                XRef xref = AnalyzeFlowInstruction(insnPos, insn);
                if (xref != null)
                {
                    xrefs.Add(xref);

                    // If the instruction is a conditional jump, add xref to
                    // the 'no-jump' branch.
                    // TODO: adding a no-jump xref causes confusion when we
                    // browse xrefs in the disassembly listing window. Is it
                    // truely necessary to add these xrefs?
                    if (xref.Type == XRefType.ConditionalJump)
                    {
                        xrefs.Add(new XRef(
                            type: XRefType.ConditionalJump,
                            source: insnPos,
                            target: pos
                        ));
                    }

                    // Finish basic block unless this is a CALL instruction.
                    if (xref.Type == XRefType.ConditionalJump ||
                        xref.Type == XRefType.NearJump ||
                        xref.Type == XRefType.FarJump ||
                        xref.Type == XRefType.NearIndexedJump)
                        break;
                }

                // If the new location is already analyzed as code, create a
                // control-flow edge from the previous block to the existing
                // block, and we are done.
                if (image[pos].Type == ByteType.Code)
                {
                    System.Diagnostics.Debug.Assert(image[pos].IsLeadByte);
                    break;
                }
            }

            // Create a basic block unless we failed on the first instruction.
            if (pos.LinearAddress > start.Target.LinearAddress)
                return image.CreateBasicBlock(start.Target.LinearAddress, pos.LinearAddress);
            else
                return null;
        }
コード例 #27
0
ファイル: Image.cs プロジェクト: trmcnealy/Plotly.WPF
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Visible != null)
                {
                    hashCode = hashCode * 59 + Visible.GetHashCode();
                }

                if (Source != null)
                {
                    hashCode = hashCode * 59 + Source.GetHashCode();
                }

                if (Layer != null)
                {
                    hashCode = hashCode * 59 + Layer.GetHashCode();
                }

                if (SizeX != null)
                {
                    hashCode = hashCode * 59 + SizeX.GetHashCode();
                }

                if (SizeY != null)
                {
                    hashCode = hashCode * 59 + SizeY.GetHashCode();
                }

                if (Sizing != null)
                {
                    hashCode = hashCode * 59 + Sizing.GetHashCode();
                }

                if (Opacity != null)
                {
                    hashCode = hashCode * 59 + Opacity.GetHashCode();
                }

                if (X != null)
                {
                    hashCode = hashCode * 59 + X.GetHashCode();
                }

                if (Y != null)
                {
                    hashCode = hashCode * 59 + Y.GetHashCode();
                }

                if (XAnchor != null)
                {
                    hashCode = hashCode * 59 + XAnchor.GetHashCode();
                }

                if (YAnchor != null)
                {
                    hashCode = hashCode * 59 + YAnchor.GetHashCode();
                }

                if (XRef != null)
                {
                    hashCode = hashCode * 59 + XRef.GetHashCode();
                }

                if (YRef != null)
                {
                    hashCode = hashCode * 59 + YRef.GetHashCode();
                }

                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }

                if (TemplateItemName != null)
                {
                    hashCode = hashCode * 59 + TemplateItemName.GetHashCode();
                }

                return(hashCode);
            }
        }
コード例 #28
0
 protected virtual XRef CreateFallThroughXRef(Address source, Address target)
 {
     XRef xref = new XRef(
         type: XRefType.FallThrough,
         source: source,
         target: target
         );
     return xref;
 }
コード例 #29
0
        public OBO_Typedef(List <KeyValuePair <string, string> > data = null)
        {
            if (data != null)
            {
                foreach (var datum in data)
                {
                    switch (datum.Key.ToLower())
                    {
                    case "id":
                        Id = datum.Value;
                        break;

                    case "is_anonymous":
                        IsAnonymous = Convert.ToBoolean(datum.Value);
                        break;

                    case "name":
                        Name = datum.Value;
                        break;

                    case "namespace":
                        Namespace = datum.Value;
                        break;

                    case "alt_id":
                        AltId.Add(datum.Value);
                        break;

                    case "def":
                        Def = datum.Value;
                        break;

                    case "comment":
                        Comment = datum.Value;
                        break;

                    case "subset":
                        Subset.Add(datum.Value);
                        break;

                    case "synonym":
                        Synonym.Add(datum.Value);
                        break;

                    case "xref":
                        XRef.Add(datum.Value);
                        break;

                    case "domain":
                        Domain = datum.Value;
                        break;

                    case "range":
                        Range = datum.Value;
                        break;

                    case "is_anti_symmetric":
                        IsAntiSymmetric = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_cyclic":
                        IsCyclic = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_reflexive":
                        IsReflexive = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_symmetric":
                        IsSymmetric = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_transitive":
                        IsTransitive = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_a":
                        IsA.Add(datum.Value);
                        break;

                    case "inverse_of":
                        InverseOf = datum.Value;
                        break;

                    case "transitive_over":
                        TransitiveOver.Add(datum.Value);
                        break;

                    case "relationship":
                        Relationship.Add(datum.Value);
                        break;

                    case "is_obsolete":
                        IsObsolete = Convert.ToBoolean(datum.Value);
                        break;

                    case "replaced_by":
                        ReplacedBy.Add(datum.Value);
                        break;

                    case "consider":
                        Consider.Add(datum.Value);
                        break;

                    case "created_by":
                        CreatedBy = datum.Value;
                        break;

                    case "creation_date":
                        CreationDate = datum.Value;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Fills the Target of an IndexedJump xref heuristically by plugging
        /// in the jump target stored in DataLocation and performing various
        /// sanity checks.
        /// </summary>
        /// <param name="entry">A xref of type IndexedJump whose Target field
        /// is Invalid.</param>
        /// <param name="xrefs">Collection to add a new dynamic IndexedJump
        /// xref to, if any.</param>
        /// <returns>The updated xref, or null if the jump table ends.</returns>
        private XRef ProcessJumpTableEntry(XRef entry, ICollection<XRef> xrefs)
        {
            #if true
            return null;
            #else
            System.Diagnostics.Debug.Assert(
                entry.Type == XRefType.NearIndexedJump &&
                entry.Target == LogicalAddress.Invalid,
                "Entry must be NearIndexedJump with unknown target");

            // Verify that the location that supposedly stores the jump table
            // entry is not analyzed as anything else. If it is, it indicates
            // that the jump table ends here.
            LinearPointer b = entry.DataLocation.LinearAddress;
            if (image[b].Type != ByteType.Unknown ||
                image[b + 1].Type != ByteType.Unknown)
                return null;

            // If the data location looks like in another segment, stop.
            if (image.LargestSegmentThatStartsBefore(b)
                > entry.Source.Segment)
            {
                return null;
            }

            // TBD: it's always a problem if CS:IP wraps. We need a more
            // general way to detect and fix it. For this particular case,
            // we need to check that the jump target is within the space
            // of this segment.
            if (entry.DataLocation.Offset >= 0xFFFE)
            {
                AddError(entry.DataLocation, ErrorCategory.Error,
                    "Jump table is too big (jumped from {0}).",
                    entry.Source);
                return null;
            }

            // Find the target address of the jump table entry.
            ushort jumpOffset = image.GetUInt16(b);
            Pointer jumpTarget = new Pointer(entry.Source.Segment, jumpOffset);

            // Check that the target address looks valid. If it doesn't, it
            // probably indicates that the jump table ends here.
            if (!image.IsAddressValid(jumpTarget.LinearAddress))
                return null;

            // If the jump target is outside the range of the current segment
            // but inside the range of a later segment, it likely indicates
            // that the jump table ends here.
            // TBD: this heuristic is kind of a hack... we should do better.
            #if true
            if (image.LargestSegmentThatStartsBefore(jumpTarget.LinearAddress)
                > entry.Source.Segment)
            {
                return null;
            }
            #endif

            // BUG: We really do need to check that the destination
            // is valid. If not, we should stop immediately.
            if (!(image[jumpTarget].Type == ByteType.Unknown ||
                  image[jumpTarget].Type == ByteType.Code &&
                  image[jumpTarget].IsLeadByte))
                return null;

            // ...

            // Mark DataLocation as data and add it to the owning procedure's
            // byte range.
            Piece piece = image.CreatePiece(
                entry.DataLocation, entry.DataLocation + 2, ByteType.Data);
            Procedure proc = image[entry.Source].Procedure;
            proc.AddDataBlock(piece.StartAddress, piece.EndAddress);

            // Add a dynamic xref from the JMP instruction to the next jump
            // table entry.
            xrefs.Add(new XRef(
                type: XRefType.NearIndexedJump,
                source: entry.Source,
                target: Pointer.Invalid,
                dataLocation: entry.DataLocation + 2
            ));

            // Return the updated xref with Target field filled.
            return new XRef(
                type: XRefType.NearIndexedJump,
                source: entry.Source,
                target: jumpTarget,
                dataLocation: entry.DataLocation
            );
            #endif
        }