コード例 #1
0
        public void AssignFrom(StackPlace place, ReferenceCapability referenceCapability)
        {
            if (place.Graph != Graph)
            {
                throw new ArgumentException("Must be part of the same graph", nameof(place));
            }

            switch (referenceCapability)
            {
            default:
                throw ExhaustiveMatch.Failed(referenceCapability);

            case ReferenceCapability.Owned:
            case ReferenceCapability.OwnedMutable:
            case ReferenceCapability.Isolated:
            case ReferenceCapability.IsolatedMutable:
            case ReferenceCapability.Held:
            case ReferenceCapability.HeldMutable:
                MoveFrom(place);
                break;

            case ReferenceCapability.Shared:
                ShareFrom(place);
                break;

            case ReferenceCapability.Borrowed:
                BorrowFrom(place);
                break;

            case ReferenceCapability.Identity:
                IdentityFrom(place);
                break;
            }
        }
コード例 #2
0
        public void IdentityFrom(StackPlace place)
        {
            if (place.Graph != Graph)
            {
                throw new ArgumentException("Must be part of the same graph", nameof(place));
            }

            references.AddRange(place.References.Select(r => r.Identify()).DistinctBy(r => r.Referent));
            Graph.Dirty();
        }
コード例 #3
0
        public void MoveFrom(StackPlace place)
        {
            if (place.Graph != Graph)
            {
                throw new ArgumentException("Must be part of the same graph", nameof(place));
            }

            references.AddRange(place.StealReferences());
            Graph.Dirty();
        }
コード例 #4
0
        public void BorrowFrom(StackPlace place)
        {
            if (place.Graph != Graph)
            {
                throw new ArgumentException("Must be part of the same graph", nameof(place));
            }

            foreach (var reference in place.References)
            {
                references.Add(reference.Borrow());
            }
            Graph.Dirty();
        }
        private static void AppendStackItem(
            StringBuilder dot,
            StackPlace place,
            string nodeType,
            Dictionary <MemoryPlace, string> nodes,
            ref int nextNode)
        {
            var port = nodeType + nextNode;

            nodes.Add(place, "stack:" + port + ":e");
            var label = Escape(place.ToString() !);
            var color = "";

            if (!place.IsAllocated)
            {
                color = " COLOR=\"red\"";
                label = $"<S>{label}</S>";
            }
            dot.AppendLine($"            <TR><TD PORT=\"{port}\" ALIGN=\"LEFT\"{color}>{label}</TD></TR>");
            nextNode += 1;
        }