import { Variable , DecodedVariable } from "../variable" ; import { ValueDetail } from "./value" ; import { ArrayDetail } from "./array" ; import { BN } from "bn.js" ; import { LibSdbInterface } from "../../../interface" ; import { LibSdbTypes } from "../../types" ; export class MappingDetail { variable : Variable ; position : BN ; offset : number | null ; id : number ; key : ValueDetail | ArrayDetail ; value : LibSdbTypes . VariableDetailType | null ; memoryLength : number ; constructor ( variable ) { this . variable = variable ; this . position = new BN ( 0 ) ; this . id = Variable . nextId ++ ; } getStorageUsed ( ) { return 32 ; } childIds ( ) { let ids = [ ] ; if ( ! ( this . key instanceof ValueDetail ) ) { ids . push ( this . key . id ) ; ids = ids . concat ( this . key . childIds ( ) ) ; } if ( ! ( this . value instanceof ValueDetail ) && this . value !== null ) { ids . push ( this . value . id ) ; ids = ids . concat ( this . value . childIds ( ) ) ; } return ids ; } clone ( variable = this . variable ) { let clone = new MappingDetail ( variable ) ; clone . position = this . position ; clone . offset = this . offset ; clone . key = this . key . clone ( variable ) ; clone . value = this . value === null ? null : this . value . clone ( variable ) ; clone . memoryLength = this . memoryLength ; return clone ; } async decodeChildren ( stack , memory , _interface , address ) { return [ ] ; } async decode ( stack , memory , _interface , address ) { let decodedVariable = < DecodedVariable > { name : this . variable . name , type : "mapping" , variablesReference : 0 , value : this . variable . originalType , result : "" } ; return decodedVariable ; } }