(struc, fieldname)
given a wasm struct instance and a field name, return the offset into the struct where you'd find the field.
given a wasm struct instance and a field name, return the offset into the struct where you'd find the field.
given a wasm struct instance and a field name return the offset into the struct where you d find the field .
def offset_of(struc, fieldname):
    '''
    given a wasm struct instance and a field name, return the offset into the struct where you'd find the field.
    '''
    p = 0
    dec_meta = struc.get_decoder_meta()
    for field in struc.get_meta().fields:
        if field.name != fieldname:
            p += dec_meta['lengths'][field.name]
        else:
            return p
    raise KeyError('field not found: ' + fieldname)
def offset_of ( struc , fieldname ) : p = 0 dec_meta = struc . get_decoder_meta ( ) for field in struc . get_meta ( ) . fields : if field . name != fieldname : p += dec_meta [ 'lengths' ] [ field . name ] else : return p raise KeyError ( 'field not found: ' + fieldname )