示例#1
0
        public void getTraits(BinaryReader br, bool addproperties, out List <cProp> properties)
        {
            properties = new List <cProp>();
            ulong type = 0;
            ulong cnt2 = getU30(br.BaseStream);

            for (ulong m = 0; m < cnt2; m++)
            {
                ulong     name = getU32(br.BaseStream);
                byte      tag  = br.ReadByte();
                TraitKind kind = (TraitKind)(tag & 0xF);
                switch (kind)
                {
                case TraitKind.Slot:
                    skipU32(br.BaseStream);
                    type = getU32(br.BaseStream);
                    ulong v1 = getU32(br.BaseStream);
                    byte  v2 = 0;
                    if (v1 > 0)
                    {
                        v2 = br.ReadByte();
                    }
                    if (addproperties)
                    {
                        cProp p = new cProp();
                        p.name = getLabel(name);
                        p.type = getLabel(type);
                        p.v1   = v1;
                        p.v2   = v2;
                        ulong nsidx = getNameSpaceByMultinameIdx(name);
                        p.nskind = 0;
                        if (nsidx > 0)
                        {
                            p.nskind = getNameSpaceKind(nsidx);
                        }
                        Debug.Print("var {0} {1} {2} {3} {4}", p.name, p.type, v1, v2, p.nskind);
                        properties.Add(p);
                    }
                    break;

                case TraitKind.Const:
                    type = getU32(br.BaseStream);
                    skipU32(br.BaseStream);
                    v1 = getU32(br.BaseStream);
                    v2 = 0;
                    if (v1 > 0)
                    {
                        v2 = br.ReadByte();
                    }
                    if (addproperties)
                    {
                        cProp p = new cProp();
                        p.name = getLabel(name);
                        p.type = "const_" + getLabel(type);
                        p.v1   = v1;
                        p.v2   = v2;
                        properties.Add(p);
                        ulong nsidx = getNameSpaceByMultinameIdx(name);
                        p.nskind = 0;
                        if (nsidx > 0)
                        {
                            p.nskind = getNameSpaceKind(nsidx);
                        }
                        Debug.Print("const {0} {1} {2} {3} {4}", p.name, p.type, v1, v2, p.nskind);
                    }
                    break;

                case TraitKind.Class:
                case TraitKind.Function:
                case TraitKind.Method:
                case TraitKind.Getter:
                case TraitKind.Setter:
                    skipU32(br.BaseStream);
                    skipU32(br.BaseStream);
                    break;

                /*experimental kinds
                 * case 11:
                 * case 8:
                 * case 14:
                 * case 9:
                 * case 12:
                 * case 15:
                 * case 7:
                 * case 13:
                 * case 10:
                 *  //Debugger.Break();
                 *
                 *  skipU32(br.BaseStream);
                 *  skipU32(br.BaseStream);
                 *  skipU32(br.BaseStream);
                 *  //return;
                 *  break;*/
                default:
                    //skipU32(br.BaseStream);
                    //skipU32(br.BaseStream);
                    Debugger.Break();
                    break;
                }
                if ((tag & (0x04 << 4)) != 0)
                {
                    ulong cnt3 = getU30(br.BaseStream);
                    for (ulong m2 = 0; m2 < cnt3; m2++)
                    {
                        skipU32(br.BaseStream);
                    }
                }
                //Debug.Print("{0:x} {1:x}", br.BaseStream.Position,br.BaseStream.Length);
            }
        }
示例#2
0
        public void getTraits(BinaryReader br,bool addproperties,out List<cProp> properties)
        {
            properties = new List<cProp>();
            ulong type = 0;
            ulong cnt2 = getU30(br.BaseStream);
            for (ulong m = 0; m < cnt2; m++)
            {
                ulong name=getU32(br.BaseStream);
                byte tag=br.ReadByte();
                TraitKind kind = (TraitKind)(tag & 0xF);
                switch (kind)
                {
                    case TraitKind.Slot:
                        skipU32(br.BaseStream);
                        type = getU32(br.BaseStream);
                        ulong v1 = getU32(br.BaseStream);
                        byte v2 = 0;
                        if (v1 > 0)
                            v2=br.ReadByte();
                        if (addproperties)
                        {
                            cProp p = new cProp();
                            p.name = getLabel(name);
                            p.type = getLabel(type);
                            p.v1 = v1;
                            p.v2 = v2;
                            ulong nsidx = getNameSpaceByMultinameIdx(name);
                            p.nskind = 0;
                            if(nsidx>0)
                                p.nskind = getNameSpaceKind(nsidx);
                            Debug.Print("var {0} {1} {2} {3} {4}", p.name, p.type, v1, v2,p.nskind);
                            properties.Add(p);
                        }
                        break;
                    case TraitKind.Const:
                        type = getU32(br.BaseStream);
                        skipU32(br.BaseStream);
                        v1 = getU32(br.BaseStream);
                        v2 = 0;
                        if (v1 > 0)
                            v2 = br.ReadByte();
                        if (addproperties)
                        {
                            cProp p = new cProp();
                            p.name = getLabel(name);
                            p.type = "const_"+getLabel(type);
                            p.v1 = v1;
                            p.v2 = v2;
                            properties.Add(p);
                            ulong nsidx = getNameSpaceByMultinameIdx(name);
                            p.nskind = 0;
                            if (nsidx > 0)
                                p.nskind = getNameSpaceKind(nsidx);
                            Debug.Print("const {0} {1} {2} {3} {4}", p.name, p.type, v1, v2, p.nskind);
                        }
                        break;
                    case TraitKind.Class:
                    case TraitKind.Function:
                    case TraitKind.Method:
                    case TraitKind.Getter:
                    case TraitKind.Setter:
                        skipU32(br.BaseStream);
                        skipU32(br.BaseStream);
                        break;

                    /*experimental kinds
                    case 11:
                    case 8:
                    case 14:
                    case 9:
                    case 12:
                    case 15:
                    case 7:
                    case 13:
                    case 10:
                        //Debugger.Break();

                        skipU32(br.BaseStream);
                        skipU32(br.BaseStream);
                        skipU32(br.BaseStream);
                        //return;
                        break;*/
                    default:
                        //skipU32(br.BaseStream);
                        //skipU32(br.BaseStream);
                        Debugger.Break();
                        break;
                }
                if ((tag & (0x04 << 4))!=0)
                {
                    ulong cnt3 = getU30(br.BaseStream);
                    for (ulong m2 = 0; m2 < cnt3; m2++)
                        skipU32(br.BaseStream);
                }
                //Debug.Print("{0:x} {1:x}", br.BaseStream.Position,br.BaseStream.Length);
            }
        }