(ptr: number)
| 915 | } |
| 916 | |
| 917 | public toJSON(ptr: number): any { |
| 918 | this.resolvePtr(ptr); |
| 919 | const len = this.scratchLen; |
| 920 | const start = this.scratchStart; |
| 921 | const type = this.u32[this.scratchPtr >> 2]!; |
| 922 | |
| 923 | if (type === TYPE_ARRAY) { |
| 924 | const arr = new Array(len); |
| 925 | for (let i = 0; i < len; i++) { |
| 926 | const offset = start + i * 8; |
| 927 | const itemType = this.u32[offset >> 2]!; |
| 928 | const itemPayload = this.u32[(offset + 4) >> 2]!; |
| 929 | |
| 930 | if (itemType === TYPE_OBJECT || itemType === TYPE_ARRAY) { |
| 931 | arr[i] = this.toJSON(itemPayload); |
| 932 | } else { |
| 933 | arr[i] = this.readSlot(offset); |
| 934 | } |
| 935 | } |
| 936 | return arr; |
| 937 | } else { |
| 938 | const obj: any = {}; |
| 939 | for (let i = 0; i < len; i++) { |
| 940 | const entryOffset = start + i * 12; |
| 941 | const keyPtr = this.u32[entryOffset >> 2]!; |
| 942 | const key = this.readString(keyPtr); |
| 943 | |
| 944 | const itemType = this.u32[(entryOffset + 4) >> 2]!; |
| 945 | const itemPayload = this.u32[(entryOffset + 8) >> 2]!; |
| 946 | |
| 947 | if (itemType === TYPE_OBJECT || itemType === TYPE_ARRAY) { |
| 948 | obj[key] = this.toJSON(itemPayload); |
| 949 | } else { |
| 950 | obj[key] = this.readSlot(entryOffset + 4); |
| 951 | } |
| 952 | } |
| 953 | return obj; |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | private objectDelete(target: Pointer, key: string): boolean { |
| 958 | this.resolvePtr(target.__ptr); |
no test coverage detected