package com.ninty.runtime.heap;

import com.ninty.runtime.LocalVars;

/**
 * Created by ninty on 2017/7/23.
 */
public class NiObject {
    private NiClass clz;
    private LocalVars fields;

    public NiObject(NiClass clz, int count) {
        this.clz = clz;
        fields = new LocalVars(count);
    }

    public NiObject(NiObject obj) {
        this.clz = obj.clz;
        this.fields = obj.fields;
    }

    public NiClass getClz() {
        return clz;
    }

    public LocalVars getFields() {
        return fields;
    }

    public boolean isInstanceOf(NiClass clz) {
        return clz.isAssignableFrom(this.clz);
    }

    @Override
    public String toString() {
        return "NiObject{" +
                clz.className +
                '}';
    }
}

@@ -183,16 +183,66 @@
  fields;
+%0A    private Object arrayDatas; // when it's array
 %0A%0A    pu
@@ -473,108 +473,1600 @@
 c Ni
-Class getClz() %7B%0A        return clz;%0A    %7D%0A%0A    public LocalVars getFields() %7B%0A        return fields
+Object(NiClass clz, Object arrayDatas) %7B%0A        this.clz = clz;%0A        this.arrayDatas = arrayDatas;%0A    %7D%0A%0A    public NiClass getClz() %7B%0A        return clz;%0A    %7D%0A%0A    public LocalVars getFields() %7B%0A        return fields;%0A    %7D%0A%0A    public byte%5B%5D abyte() %7B%0A        return (byte%5B%5D) arrayDatas;%0A    %7D%0A%0A    public short%5B%5D ashort() %7B%0A        return (short%5B%5D) arrayDatas;%0A    %7D%0A%0A    public char%5B%5D achar() %7B%0A        return (char%5B%5D) arrayDatas;%0A    %7D%0A%0A    public int%5B%5D aint() %7B%0A        return (int%5B%5D) arrayDatas;%0A    %7D%0A%0A    public long%5B%5D along() %7B%0A        return (long%5B%5D) arrayDatas;%0A    %7D%0A%0A    public float%5B%5D afloat() %7B%0A        return (float%5B%5D) arrayDatas;%0A    %7D%0A%0A    public double%5B%5D adouble() %7B%0A        return (double%5B%5D) arrayDatas;%0A    %7D%0A%0A    public NiObject%5B%5D aobject() %7B%0A        return (NiObject%5B%5D) arrayDatas;%0A    %7D%0A%0A    public int arrayLength() %7B%0A        Class clz = arrayDatas.getClass();%0A        if (clz == byte%5B%5D.class) %7B%0A            return abyte().length;%0A        %7D else if (clz == short%5B%5D.class) %7B%0A            return ashort().length;%0A        %7D else if (clz == char%5B%5D.class) %7B%0A            return achar().length;%0A        %7D else if (clz == int%5B%5D.class) %7B%0A            return aint().length;%0A        %7D else if (clz == long%5B%5D.class) %7B%0A            return along().length;%0A        %7D else if (clz == float%5B%5D.class) %7B%0A            return afloat().length;%0A        %7D else if (clz == double%5B%5D.class) %7B%0A            return adouble().length;%0A        %7D else if (clz == NiObject%5B%5D.class) %7B%0A            return aobject().length;%0A        %7D%0A        throw new IllegalAccessError(%22Only array can access length%22)
 ;%0A  

support array Object