Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        /*
         * 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);
            }
        }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 public string GetStringVal(HeapReference heapRef)
 {
     return (string) stringMap[heapRef];
 }