public void Store(string name, SubscriptExpr subscript, BitVector val) { if (!arrays.ContainsKey(name)) { arrays[name] = new Dictionary <SubscriptExpr, BitVector>(); } SubscriptExpr matchingSubscript = SubscriptExpr.Matches(subscript, arrays[name].Keys.ToList()); if (matchingSubscript != null) { arrays[name].Remove(matchingSubscript); } arrays[name][subscript] = val; }
public bool Contains(string name, SubscriptExpr subscript) { if (arrays.ContainsKey(name)) { Dictionary <SubscriptExpr, BitVector> arrayLocations = arrays[name]; foreach (KeyValuePair <SubscriptExpr, BitVector> item in arrayLocations) { if (SubscriptExpr.Matches(item.Key, subscript)) { return(true); } } } return(false); }
public BitVector GetValue(string name, SubscriptExpr subscript) { Print.ConditionalExitMessage(arrays.ContainsKey(name), string.Format("Unable to find array '{0}' in memory", name)); Dictionary <SubscriptExpr, BitVector> arrayLocations = arrays[name]; foreach (KeyValuePair <SubscriptExpr, BitVector> item in arrayLocations) { if (SubscriptExpr.Matches(item.Key, subscript)) { return(arrays[name][item.Key]); } } Print.WarningMessage(string.Format("Location '{0}' in array '{1}' has not been initialised", subscript.ToString(), name)); // Assign a random value BitVector val = new BitVector(Random.Next(int.MinValue, int.MaxValue)); arrays[name][subscript] = val; return(val); }