public VMValue_arrayinst MakeArrayInst(int size, CILVariable elementType) { int guid = nextguid++; VMValue_arrayinst ret = new VMValue_arrayinst(guid, size, elementType, this); allValues.Add(guid, ret); return ret; }
public VMValue_arrayinst(int guid, int size, CILVariable elementType, VMValueManager valueManager) : base(guid) { this.elementType = elementType; data = new int[size]; for(int i = 0; i < size; i++) data[i] = valueManager.MakeValue(elementType).GUID; }
/// <summary> /// Get the guid of a static variable, which is a static field of a class. /// It is global and accessible by a pair of a class name and a variable name. /// </summary> /// <param name="classType">The class containing the static field</param> /// <param name="variable">The static variable</param> /// <returns>The guid of the static variable</returns> public int GetStaticVariable(CILClass classType, CILVariable variable) { string name = classType.Name + ":" + variable.Name; for(int i = 0; i < names.Count; i++) if(names[i] == name) return values[i]; AddStaticVariable(classType, variable); // the second time we must have got the variable on the list already return GetStaticVariable(classType, variable); }
public void AddStaticVariable(CILClass classType, CILVariable variable) { string name = classType.Name + ":" + variable.Name; VMValue v = systemState.Values.MakeValue(variable); v.IsConcrete = true; v.IsThreadLocal = false; for(int i = 0; i < names.Count; i++) if(name == names[i]) return; else if(name.CompareTo(names[i]) < 0) { names.Insert(i, name); values.Insert(i, v.GUID); return; } names.Add(name); values.Add(v.GUID); }
public int GetStaticVariable(CILClass classType, CILVariable variable) { return heap.GetStaticVariable(classType, variable); }
/// <summary> /// Private constructor to be used by Duplicate() only /// </summary> private VMValue_arrayinst(CILVariable elementType) { this.elementType = elementType; }
public VMValue_objectinst MakeObjectInstance(CILVariable variable) { int guid = nextguid; nextguid++; VMValue_objectinst ret = new VMValue_objectinst(guid, this, ((CILVar_object)variable).ClassType); allValues.Add(guid, ret); return ret; }
public VMValue MakeValue(CILVariable variable) { VMValue ret; if(variable is CILVar_int32) { ret = new VMValue_int32(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(variable is CILVar_int64) { ret = new VMValue_int64(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(variable is CILVar_double) { ret = new VMValue_double(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(variable is CILVar_object) { ret = new VMValue_object(nextguid, ((CILVar_object)variable).ClassType, -1); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(variable is CILVar_array) { ret = new VMValue_array(nextguid, -1); allValues.Add(nextguid, ret); nextguid++; return ret; } else throw new Exception("Unknown value type to make a value"); }