Exemplo n.º 1
0
def _(operand):
    offset, base = single(operand.items())
    if not isinstance(offset, (Register, Integral)):
        raise TypeError("Expected integer offset. Got {}".format(offset))
    if not isinstance(base, (Register, AutoIncrementedRegister)):
        raise TypeError("{} is not a base".format(base))
    return Indexed(base=base, offset=offset)
Exemplo n.º 2
0
def test_indexed_inequality(base_a, offset_a, base_b, offset_b):
    assume((base_a, offset_a) != (base_b, offset_b))
    assert Indexed(base_a, offset_a) != Indexed(base_b, offset_b)
Exemplo n.º 3
0
def test_indexed_hash_equality(base, offset):
    assert hash(Indexed(base, offset)) == hash(Indexed(base, offset))
Exemplo n.º 4
0
def test_indexed_equality(base, offset):
    assert Indexed(base, offset) == Indexed(base, offset)
Exemplo n.º 5
0
def test_indexed_inequality_different_types(base, offset):
    assert Indexed(base, offset) != object()
Exemplo n.º 6
0
def test_indexed_repr(base, offset):
    r = repr(Indexed(base, offset))
    assert r.startswith('Indexed')
    assert base.name in r
    assert check_balanced(r)
Exemplo n.º 7
0
def test_indexed_autoincrement_with_out_of_range_offset_raises_value_error(
        index_register, offset):
    assume(offset != 0)
    with raises(ValueError):
        Indexed(index_register, offset)
Exemplo n.º 8
0
def test_indexed_autoincrement_with_non_zero_offset_raises_value_error(
        index_register, delta, offset):
    assume(offset != 0)
    print(offset)
    with raises(ValueError):
        Indexed(AutoIncrementedRegister(index_register, delta), offset)
Exemplo n.º 9
0
def test_indexed_values(base, offset):
    idx = Indexed(base, offset)
    assert idx.base == base
    assert idx.offset == offset
Exemplo n.º 10
0
def test_indexed_zero_offset():
    asm = AsmDsl()
    asm(ADDA, {0: X})
    assert statements(asm) == (AddA(Indexed(X, 0)), )