public void Alst_NonOverlap()
 {
     var alst = new AliasState();
     alst.Add(ah);
     alst.Add(al);
     var aliases = alst.GetAliases(ah);
     Assert.AreEqual("ah", string.Join(" ", aliases.Select(a => ((RegisterStorage)a).Name).OrderBy(r => r)));
 }
 public void Alst_Subset()
 {
     var alst = new AliasState();
     alst.Add(eax);
     alst.Add(al);
     var aliases = alst.GetAliases(eax);
     Assert.AreEqual("al eax", string.Join(" ", aliases.Select(a => ((RegisterStorage)a).Name).OrderBy(r => r)));
 }
Exemple #3
0
        public void Alst_NonOverlap()
        {
            var alst = new AliasState();

            alst.Add(ah);
            alst.Add(al);
            var aliases = alst.GetAliases(ah);

            Assert.AreEqual("ah", string.Join(" ", aliases.Select(a => ((RegisterStorage)a).Name).OrderBy(r => r)));
        }
Exemple #4
0
        public void Alst_Subset()
        {
            var alst = new AliasState();

            alst.Add(eax);
            alst.Add(al);
            var aliases = alst.GetAliases(eax);

            Assert.AreEqual("al eax", string.Join(" ", aliases.Select(a => ((RegisterStorage)a).Name).OrderBy(r => r)));
        }
        public object DeserializeValue(EventReader reader, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
        {
            AnchorAlias alias = reader.Allow <AnchorAlias>();

            if (alias != null)
            {
                ValuePromise promise;
                AliasState   state2 = state.Get <AliasState>();
                if (!state2.TryGetValue(alias.Value, out promise))
                {
                    promise = new ValuePromise(alias);
                    state2.Add(alias.Value, promise);
                }
                return(!promise.HasValue ? promise : promise.Value);
            }
            string    key    = null;
            NodeEvent event2 = reader.Peek <NodeEvent>();

            if ((event2 != null) && !string.IsNullOrEmpty(event2.Anchor))
            {
                key = event2.Anchor;
            }
            object obj2 = this.innerDeserializer.DeserializeValue(reader, expectedType, state, nestedObjectDeserializer);

            if (key != null)
            {
                ValuePromise promise2;
                AliasState   state3 = state.Get <AliasState>();
                if (!state3.TryGetValue(key, out promise2))
                {
                    state3.Add(key, new ValuePromise(obj2));
                }
                else
                {
                    if (promise2.HasValue)
                    {
                        throw new DuplicateAnchorException(event2.Start, event2.End, $"Anchor '{key}' already defined");
                    }
                    promise2.Value = obj2;
                }
            }
            return(obj2);
        }
        public object DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
        {
            AnchorAlias anchorAlias = parser.Allow <AnchorAlias>();

            if (anchorAlias != null)
            {
                AliasState aliasState = state.Get <AliasState>();
                if (!aliasState.TryGetValue(anchorAlias.Value, out ValuePromise value))
                {
                    value = new ValuePromise(anchorAlias);
                    aliasState.Add(anchorAlias.Value, value);
                }
                return((!value.HasValue) ? value : value.Value);
            }
            string    text      = null;
            NodeEvent nodeEvent = parser.Peek <NodeEvent>();

            if (nodeEvent != null && !string.IsNullOrEmpty(nodeEvent.Anchor))
            {
                text = nodeEvent.Anchor;
            }
            object obj = innerDeserializer.DeserializeValue(parser, expectedType, state, nestedObjectDeserializer);

            if (text != null)
            {
                AliasState aliasState2 = state.Get <AliasState>();
                if (!aliasState2.TryGetValue(text, out ValuePromise value2))
                {
                    aliasState2.Add(text, new ValuePromise(obj));
                }
                else if (!value2.HasValue)
                {
                    value2.Value = obj;
                }
                else
                {
                    aliasState2[text] = new ValuePromise(obj);
                }
            }
            return(obj);
        }