Beispiel #1
0
def op_getfield(interp, obj, attr):
    """
    Retrieve an attribute/method from an object.
    """
    if is_dict_obj(obj):
        return interp.getfield(obj, attr)
    return getattr(obj, attr)
Beispiel #2
0
def op_getfield(interp, obj, attr):
    """
    Retrieve an attribute/method from an object.
    """
    if is_dict_obj(obj):
        return interp.getfield(obj, attr)
    return getattr(obj, attr)
Beispiel #3
0
def op_untyped_getfield(typeof_func, interp, obj, attr):
    """
    Retrieve an attribute/method from an object.
    """
    op = interp.op
    arg = op.args[0]
    obj_type = typeof_func(arg, obj)

    if attr in obj_type.fields:
        # Method access
        return Method(obj_type.fields[attr], obj)
    else:
        # Attribute access
        if attr not in obj_type.layout:
            raise AttributeError("Object of type %s has no attribute %r" %
                                 (obj_type, attr))

        if is_dict_obj(obj):
            return interp.getfield(obj, attr)

        return getattr(obj, attr)
Beispiel #4
0
def op_untyped_getfield(typeof_func, interp, obj, attr):
    """
    Retrieve an attribute/method from an object.
    """
    op = interp.op
    arg = op.args[0]
    obj_type = typeof_func(arg, obj)

    if attr in obj_type.fields:
        # Method access
        return Method(obj_type.fields[attr], obj)
    else:
        # Attribute access
        if attr not in obj_type.layout:
            raise AttributeError(
                "Object of type %s has no attribute %r" % (obj_type, attr))

        if is_dict_obj(obj):
            return interp.getfield(obj, attr)

        return getattr(obj, attr)