Пример #1
0
 def get_ast(self):
     fields = [get_field_ast(f) for f in self.fields]
     methods = [m.get_ast() for m in self.methods if m.ast is not None]
     isInterface = 'interface' in self.access
     return {
         'rawname': self.thisclass[1:-1],
         'name': parse_descriptor(self.thisclass),
         'super': parse_descriptor(self.superclass),
         'flags': self.access,
         'isInterface': isInterface,
         'interfaces': list(map(parse_descriptor, self.interfaces)),
         'fields': fields,
         'methods': methods,
     }
Пример #2
0
 def get_ast(self):
     fields = [get_field_ast(f) for f in self.fields]
     methods = [m.get_ast() for m in self.methods if m.ast is not None]
     isInterface = "interface" in self.access
     return {
         "rawname": self.thisclass[1:-1],
         "name": parse_descriptor(self.thisclass),
         "super": parse_descriptor(self.superclass),
         "flags": self.access,
         "isInterface": isInterface,
         "interfaces": map(parse_descriptor, self.interfaces),
         "fields": fields,
         "methods": methods,
     }
Пример #3
0
 def get_ast(self):
     fields = [get_field_ast(f) for f in self.fields]
     methods = [m.get_ast() for m in self.methods if m.ast is not None]
     isInterface = 'interface' in self.access
     return {
         'rawname': self.thisclass[1:-1],
         'name': parse_descriptor(self.thisclass),
         'super': parse_descriptor(self.superclass),
         'flags': self.access,
         'isInterface': isInterface,
         'interfaces': map(parse_descriptor, self.interfaces),
         'fields': fields,
         'methods': methods,
     }
Пример #4
0
def get_field_ast(field):
    triple = field.get_class_name()[1:-1], field.get_name(), field.get_descriptor()

    expr = None
    if field.init_value:
        vt = field.init_value.get_value_type()
        val = field.init_value.value

        # TODO: Add other types once dvm.EncodedValue parses them correctly
        if vt == dvm.VALUE_STRING:
            expr = literal_string(val)
        # elif vt in (dvm.VALUE_INT, dvm.VALUE_SHORT, dvm.VALUE_CHAR):
        #     expr = literal_int(val)
        elif vt == dvm.VALUE_BYTE:
            x = ord(val)
            expr = literal_int(x - 256 if x >= 128 else x)
        # elif vt == dvm.VALUE_LONG:
        #     expr = literal_long(val)
        # elif vt == dvm.VALUE_DOUBLE:
        #     expr = literal_double(val)
        # elif vt == dvm.VALUE_FLOAT:
        #     expr = literal_float(val)
        elif vt == dvm.VALUE_NULL:
            expr = literal_null()
        elif vt == dvm.VALUE_BOOLEAN:
            expr = literal_bool(val)
        else:
            expr = dummy('???')

    return {
        'triple': triple,
        'type': parse_descriptor(field.get_descriptor()),
        'flags': util.get_access_field(field.get_access_flags()),
        'expr': expr,
    }
Пример #5
0
def get_field_ast(field):
    triple = field.get_class_name()[1:-1], field.get_name(), field.get_descriptor()

    expr = None
    if field.init_value:
        vt = field.init_value.get_value_type()
        val = field.init_value.value

        # TODO: Add other types once dvm.EncodedValue parses them correctly
        if vt == dvm.VALUE_STRING:
            expr = literal_string(val)
        # elif vt in (dvm.VALUE_INT, dvm.VALUE_SHORT, dvm.VALUE_CHAR):
        #     expr = literal_int(val)
        elif vt == dvm.VALUE_BYTE:
            x = ord(val)
            expr = literal_int(x - 256 if x >= 128 else x)
        # elif vt == dvm.VALUE_LONG:
        #     expr = literal_long(val)
        # elif vt == dvm.VALUE_DOUBLE:
        #     expr = literal_double(val)
        # elif vt == dvm.VALUE_FLOAT:
        #     expr = literal_float(val)
        elif vt == dvm.VALUE_NULL:
            expr = literal_null()
        elif vt == dvm.VALUE_BOOLEAN:
            expr = literal_bool(val)
        else:
            expr = dummy('???')

    return {
        'triple': triple,
        'type': parse_descriptor(field.get_descriptor()),
        'flags': util.get_access_field(field.get_access_flags()),
        'expr': expr,
    }
Пример #6
0
 def get_ast(self):
     fields = [get_field_ast(f) for f in self.fields]
     methods = []
     for m in self.methods:
         if isinstance(m, DvMethod) and m.ast:
             methods.append(m.get_ast())
     isInterface = 'interface' in self.access
     return {
         'rawname': self.thisclass[1:-1],
         'name': parse_descriptor(self.thisclass),
         'super': parse_descriptor(self.superclass),
         'flags': self.access,
         'isInterface': isInterface,
         'interfaces': list(map(parse_descriptor, self.interfaces)),
         'fields': fields,
         'methods': methods,
     }
Пример #7
0
 def get_ast(self):
     fields = [get_field_ast(f) for f in self.fields]
     methods = []
     for m in self.methods:
       if isinstance(m, DvMethod) and m.ast:
         methods.append(m.get_ast())
     isInterface = 'interface' in self.access
     return {
         'rawname': self.thisclass[1:-1],
         'name': parse_descriptor(self.thisclass),
         'super': parse_descriptor(self.superclass),
         'flags': self.access,
         'isInterface': isInterface,
         'interfaces': map(parse_descriptor, self.interfaces),
         'fields': fields,
         'methods': methods,
     }
Пример #8
0
def get_field_ast(field):
    triple = field.get_class_name()[1:-1], field.get_name(), field.get_descriptor()

    expr = None
    if field.init_value:
        val = field.init_value.value
        expr = dummy(str(val))

        if val is not None:
            if field.get_descriptor() == 'Ljava/lang/String;':
                expr = literal_string(val)
            elif field.proto == 'B':
                expr = literal_hex_int(struct.unpack('<b', val)[0])

    return {
        'triple': triple,
        'type': parse_descriptor(field.get_descriptor()),
        'flags': util.get_access_field(field.get_access_flags()),
        'expr': expr,
    }
Пример #9
0
def get_field_ast(field):
    triple = field.get_class_name()[1:-1], field.get_name(), field.get_descriptor()

    expr = None
    if field.init_value:
        val = field.init_value.value
        expr = dummy(str(val))

        if val is not None:
            if field.get_descriptor() == 'Ljava/lang/String;':
                expr = literal_string(val)
            elif field.proto == 'B':
                expr = literal_hex_int(struct.unpack('<b', val)[0])

    return {
        'triple': triple,
        'type': parse_descriptor(field.get_descriptor()),
        'flags': util.get_access_field(field.get_access_flags()),
        'expr': expr,
    }
Пример #10
0
def get_field_ast(field):
    triple = field.get_class_name()[1:-1], field.get_name(), field.get_descriptor()

    expr = None
    if field.init_value:
        val = field.init_value.value
        expr = dummy(str(val))

        if val is not None:
            if field.get_descriptor() == "Ljava/lang/String;":
                expr = literal_string(val)
            elif field.proto == "B":
                expr = literal_hex_int(struct.unpack("<b", val)[0])

    return {
        "triple": triple,
        "type": parse_descriptor(field.get_descriptor()),
        "flags": util.get_access_field(field.get_access_flags()),
        "expr": expr,
    }