Ejemplo n.º 1
0
def qrem(
    a: pt.abi.Uint64,
    b: pt.abi.Uint64,
    *,
    output: pt.abi.Tuple2[pt.abi.Uint64, pt.abi.Uint64],
) -> pt.Expr:
    return pt.Seq(
        (q := pt.abi.Uint64()).set(a.get() / b.get()),
        (rem := pt.abi.Uint64()).set(a.get() % b.get()),
        output.set(q, rem),
    )
Ejemplo n.º 2
0
 def fn_2arg_1ret(
     a: pt.abi.Uint64,
     b: pt.abi.StaticArray[pt.abi.Byte, Literal[10]],
     *,
     output: pt.abi.Byte,
 ) -> pt.Expr:
     return output.set(b[a.get() % pt.Int(10)])
Ejemplo n.º 3
0
def many_args(
    _a: pt.abi.Uint64,
    _b: pt.abi.Uint64,
    _c: pt.abi.Uint64,
    _d: pt.abi.Uint64,
    _e: pt.abi.Uint64,
    _f: pt.abi.Uint64,
    _g: pt.abi.Uint64,
    _h: pt.abi.Uint64,
    _i: pt.abi.Uint64,
    _j: pt.abi.Uint64,
    _k: pt.abi.Uint64,
    _l: pt.abi.Uint64,
    _m: pt.abi.Uint64,
    _n: pt.abi.Uint64,
    _o: pt.abi.Uint64,
    _p: pt.abi.Uint64,
    _q: pt.abi.Uint64,
    _r: pt.abi.Uint64,
    _s: pt.abi.Uint64,
    _t: pt.abi.Uint64,
    *,
    output: pt.abi.Uint64,
) -> pt.Expr:
    return output.set(_t.get())
Ejemplo n.º 4
0
 def fn_mixed_annotation_1_with_ret(a: pt.ScratchVar, b: pt.abi.Uint64, *,
                                    output: pt.abi.Bool) -> pt.Expr:
     return output.set((a.load() + b.get()) % pt.Int(2))
Ejemplo n.º 5
0
 def fn_ret_add(a: pt.abi.Uint64, b: pt.abi.Uint32, *,
                output: pt.abi.Uint64) -> pt.Expr:
     return output.set(a.get() + b.get() + pt.Int(0xA190))
Ejemplo n.º 6
0
 def fn_log_add(a: pt.abi.Uint64, b: pt.abi.Uint32) -> pt.Expr:
     return pt.Seq(pt.Log(pt.Itob(a.get() + b.get())), pt.Return())
Ejemplo n.º 7
0
def mod(a: pt.abi.Uint64, b: pt.abi.Uint64, *, output: pt.abi.Uint64) -> pt.Expr:
    return output.set(a.get() % b.get())
Ejemplo n.º 8
0
def div(a: pt.abi.Uint64, b: pt.abi.Uint64, *, output: pt.abi.Uint64) -> pt.Expr:
    return output.set(a.get() / b.get())
Ejemplo n.º 9
0
def sub(a: pt.abi.Uint64, b: pt.abi.Uint64, *, output: pt.abi.Uint64) -> pt.Expr:
    """replace me"""
    return output.set(a.get() - b.get())
Ejemplo n.º 10
0
def not_registrable(lhs: pt.abi.Uint64, rhs: pt.Expr, *, output: pt.abi.Uint64):
    return output.set(lhs.get() * rhs)
Ejemplo n.º 11
0
def add(a: pt.abi.Uint64, b: pt.abi.Uint64, *, output: pt.abi.Uint64) -> pt.Expr:
    """add takes 2 integers a,b and adds them, returning the sum"""
    return output.set(a.get() + b.get())