def method_id(viper_ast: ViperAST, method, len: int, pos=None, info=None): mid = mangled.BLOCKCHAIN_METHOD_ID domain = mangled.BLOCKCHAIN_DOMAIN rl = viper_ast.IntLit(len, pos) return viper_ast.DomainFuncApp(mid, [method, rl], viper_ast.SeqType(viper_ast.Int), pos, info, domain)
def convert_unsigned_int_to_bytes32(viper_ast: ViperAST, i, pos=None, info=None): domain = mangled.CONVERT_DOMAIN function = mangled.CONVERT_UNSIGNED_INT_TO_BYTES32 return viper_ast.DomainFuncApp(function, [i], viper_ast.SeqType(viper_ast.Int), pos, info, domain)
def pad32(viper_ast: ViperAST, bytes, pos=None, info=None): """ Left-pads a byte array shorter than 32 bytes with 0s so that its resulting length is 32. Left-crops a byte array longer than 32 bytes so that its resulting length is 32. """ domain = mangled.CONVERT_DOMAIN function = mangled.CONVERT_PAD32 return viper_ast.DomainFuncApp(function, [bytes], viper_ast.SeqType(viper_ast.Int), pos, info, domain)
def range(viper_ast: ViperAST, start, end, pos=None, info=None): range_func = mangled.RANGE_RANGE range_type = viper_ast.SeqType(viper_ast.Int) domain = mangled.RANGE_DOMAIN return viper_ast.DomainFuncApp(range_func, [start, end], range_type, pos, info, domain)
def array_type(viper_ast: ViperAST, element_type): return viper_ast.SeqType(element_type)
def ecmul(viper_ast: ViperAST, args, pos=None, info=None): int_array_type = viper_ast.SeqType(viper_ast.Int) em = mangled.BLOCKCHAIN_ECMUL domain = mangled.BLOCKCHAIN_DOMAIN return viper_ast.DomainFuncApp(em, args, int_array_type, pos, info, domain)
def sha256(viper_ast: ViperAST, arg, pos=None, info=None): int_array_type = viper_ast.SeqType(viper_ast.Int) sha = mangled.BLOCKCHAIN_SHA256 domain = mangled.BLOCKCHAIN_DOMAIN return viper_ast.DomainFuncApp(sha, [arg], int_array_type, pos, info, domain)
def keccak256(viper_ast: ViperAST, arg, pos=None, info=None): int_array_type = viper_ast.SeqType(viper_ast.Int) keccak = mangled.BLOCKCHAIN_KECCAK256 domain = mangled.BLOCKCHAIN_DOMAIN return viper_ast.DomainFuncApp(keccak, [arg], int_array_type, pos, info, domain)
def blockhash(viper_ast: ViperAST, no, ctx: Context, pos=None, info=None): bhash = mangled.BLOCKCHAIN_BLOCKHASH domain = mangled.BLOCKCHAIN_DOMAIN return viper_ast.DomainFuncApp(bhash, [no], viper_ast.SeqType(viper_ast.Int), pos, info, domain)