Beispiel #1
0
        private void setEntry(VirtualReference reference, MemoryEntry entry)
        {
            if (entry == null)
            {
                throw new NotSupportedException("Entry cannot be null");
            }

            reference.SetEntry(this, getDataContainer(), entry);
        }
Beispiel #2
0
        private IEnumerable <Value> resolveValuesFrom(VirtualReference reference)
        {
            var entry = getEntry(reference);

            if (entry == null)
            {
                return(new Value[0]);
            }

            return(entry.PossibleValues);
        }
Beispiel #3
0
        /// <summary>
        /// Get memory entry stored at given reference
        /// </summary>
        /// <param name="reference"></param>
        /// <returns></returns>
        internal MemoryEntry GetEntry(VirtualReference reference)
        {
            MemoryEntry entry;

            REPORT(Statistic.SimpleHashSearches);
            if (_data.TryGetValue(reference, out entry))
            {
                return(entry);
            }

            //reading of uninitialized reference (may happen when aliasing cross contexts)
            REPORT(Statistic.MemoryEntryCreation);
            return(new MemoryEntry(_owner.UndefinedValue));
        }
Beispiel #4
0
        internal void ExtendBy(VariableContainer variableContainer, bool directExtend)
        {
            foreach (var varPair in variableContainer._variables)
            {
                VariableInfo oldVar;
                REPORT(Statistic.SimpleHashSearches);
                if (!_variables.TryGetValue(varPair.Key, out oldVar))
                {
                    //copy variable info, so we can process changes on it
                    REPORT(Statistic.SimpleHashAssigns);
                    if (CanFetchFromGlobals && varPair.Value.IsGlobal)
                    {
                        //fetch from globals
                        _variables[varPair.Key] = _globals._variables[varPair.Key];
                    }
                    else
                    {
                        var clone = varPair.Value.Clone();
                        if (!directExtend)
                        {
                            //undefined branch
                            //TODO what about callback references ?
                            var reference = new VirtualReference(clone, _owner.CurrentContextStamp);

                            if (!clone.References.Contains(reference))
                            {
                                clone.References.Add(reference);
                            }
                        }

                        _variables[varPair.Key] = clone;
                    }
                }
                else
                {
                    //merge variable references
                    foreach (var reference in varPair.Value.References)
                    {
                        if (!oldVar.References.Contains(reference))
                        {
                            oldVar.References.Add(reference);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private void assign(VariableInfo info, MemoryEntry entry)
        {
            var references = info.References;

            switch (references.Count)
            {
            case 0:
                //reserve new virtual reference
                var allocatedReference = new VirtualReference(info.Name, info.Kind, CurrentContextStamp);
                info.References.Add(allocatedReference);

                setEntry(allocatedReference, entry);
                break;

            case 1:
                setEntry(references[0], entry);
                break;

            default:
                weakUpdate(references, entry);
                break;
            }
        }
Beispiel #6
0
 private MemoryEntry getEntry(VirtualReference reference)
 {
     return(reference.GetEntry(this, getDataContainer()));
 }
Beispiel #7
0
 /// <summary>
 /// Set memory entry at given reference
 /// </summary>
 /// <param name="reference"></param>
 /// <param name="entry"></param>
 internal void SetEntry(VirtualReference reference, MemoryEntry entry)
 {
     REPORT(Statistic.SimpleHashAssigns);
     _data[reference] = entry;
 }