public HeapReference newPrimitiveArray(Type type, int length) { if (log.IsDebugEnabled) log.DebugFormat("Creatring new Primitive Array of type {0}",type); int addr = theHeap.Count; HeapReference href = new HeapReference(); Array arr = Array.CreateInstance(type,length); //for (int i = 0; i < length; i++) { arr.Add(0); } href.obj = arr; href.address = addr; href.primitiveType = type; href.isPrimitive = true; href.isArray = true; href.length = length; theHeap.Add(href); return href; }
public HeapReference newInstance(ClassFile type) { int addr = theHeap.Count; HeapReference href = new HeapReference(); href.address = addr; href.obj = new ToyVMObject(type); href.type = type; theHeap.Add(href); ((ToyVMObject)href.obj).setHeapReference(href); return href; }
/* * Create array of arrays * Will basically have the actual array entries be HeapRefs */ public HeapReference new2DArray(string arrayType, int length) { if ("C".Equals(arrayType)){ //Heap.HeapReference arrayObj = newPrimitiveArray(Type.GetType("System.Char[]"),length); int addr = theHeap.Count; HeapReference href = new HeapReference(); href.isPrimitive = true; href.primitiveType = Type.GetType("System.Char[]"); ArrayList arr = new ArrayList(length); for (int i = 0; i < length; i++) { arr.Add(NullValue.INSTANCE); } href.obj = arr; href.address = addr; //href.type = type; href.isArray = true; href.length = length; theHeap.Add(href); return href; //return arrayObj; } else { throw new Exception("Can only create 2D char arrays, not " + arrayType); } }
public HeapReference newArray(ClassFile type, int length) { int addr = theHeap.Count; HeapReference href = new HeapReference(); ArrayList arr = new ArrayList(length); for (int i = 0; i < length; i++) { arr.Add(NullValue.INSTANCE); } href.obj = arr; href.address = addr; href.type = type; href.isArray = true; href.length = length; theHeap.Add(href); return href; }
public string GetStringVal(HeapReference heapRef) { return (string) stringMap[heapRef]; }