Ejemplo n.º 1
0
    if li[0]:
        return Astnode(li[1], li[3:], li[2])
    else:
        return Token(li[1], li[2])


def take(x):
    return pyext.parse_lll(x) if isinstance(x, (str, unicode, bytes)) else x.out()


def takelist(x):
    return map(take, parse(x).args if isinstance(x, (str, unicode, bytes)) else x)

compile = lambda x: pyext.compile(strtobytes(x))
compile_chunk = lambda x: pyext.compile_chunk(strtobytes(x))
compile_to_lll = lambda x: node(pyext.compile_to_lll(strtobytes(x)))
compile_chunk_to_lll = lambda x: node(pyext.compile_chunk_to_lll(strtobytes(x)))
compile_lll = lambda x: pyext.compile_lll(take(strtobytes(x)))
parse = lambda x: node(pyext.parse(strtobytes(x)))
rewrite = lambda x: node(pyext.rewrite(take(strtobytes(x))))
rewrite_chunk = lambda x: node(pyext.rewrite_chunk(take(strtobytes(x))))
pretty_compile = lambda x: map(node, pyext.pretty_compile(strtobytes(x)))
pretty_compile_chunk = lambda x: map(node, pyext.pretty_compile_chunk(strtobytes(x)))
pretty_compile_lll = lambda x: map(node, pyext.pretty_compile_lll(take(strtobytes(x))))
serialize = lambda x: pyext.serialize(takelist(strtobytes(x)))
deserialize = lambda x: map(node, pyext.deserialize(strtobytes(x)))

is_numeric = lambda x: isinstance(x, (int, long))
is_string = lambda x: isinstance(x, (str, unicode))
tobytearr = lambda n, L: [] if L == 0 else tobytearr(n / 256, L - 1)+[n % 256]
Ejemplo n.º 2
0
    if li[0]:
        return Astnode(li[1], li[3:], li[2])
    else:
        return Token(li[1], li[2])


def take(x):
    return pyext.parse_lll(x) if isinstance(x, (str, unicode)) else x.out()


def takelist(x):
    return map(take, parse(x).args if isinstance(x, (str, unicode)) else x)


compile = lambda x: pyext.compile(x)
compile_to_lll = lambda x: node(pyext.compile_to_lll(x))
compile_lll = lambda x: pyext.compile_lll(take(x))
parse = lambda x: node(pyext.parse(x))
rewrite = lambda x: node(pyext.rewrite(take(x)))
pretty_compile = lambda x: map(node, pyext.pretty_compile(x))
pretty_compile_lll = lambda x: map(node, pyext.pretty_compile_lll(take(x)))
serialize = lambda x: pyext.serialize(takelist(x))
deserialize = lambda x: map(node, pyext.deserialize(x))

is_numeric = lambda x: isinstance(x, (int, long))
is_string = lambda x: isinstance(x, (str, unicode))
tobytearr = lambda n, L: [] if L == 0 else tobytearr(n / 256, L - 1)+[n % 256]


# A set of methods for detecting raw values (numbers and strings) and
# converting them to integers
Ejemplo n.º 3
0
    return map(take, parse(x).args if is_string(x) else x)


def pre_transform(code, params):
    code2 = ''
    for k, v in params.items():
        if isinstance(v, str_types):
            v = '"' + str(v) + '"'
        code2 += 'macro $%s:\n    %s\n' % (k, v)
    if os.path.exists(code):
        return code2 + "inset('" + code + "')"
    return code2 + code

compile = lambda code, **kwargs: pyext.compile(strtobytes(pre_transform(code, kwargs)))
compile_chunk = lambda code, **kwargs: pyext.compile_chunk(strtobytes(pre_transform(code, kwargs)))
compile_to_lll = lambda code, **kwargs: node(pyext.compile_to_lll(strtobytes(pre_transform(code, kwargs))))
compile_chunk_to_lll = lambda code, **kwargs: node(pyext.compile_chunk_to_lll(strtobytes(pre_transform(code, kwargs))))
compile_lll = lambda x: pyext.compile_lll(take(strtobytes(x)))
parse = lambda code, **kwargs: node(pyext.parse(strtobytes(pre_transform(code, kwargs))))
rewrite = lambda x: node(pyext.rewrite(take(strtobytes(x))))
rewrite_chunk = lambda x: node(pyext.rewrite_chunk(take(strtobytes(x))))
pretty_compile = lambda code, **kwargs: map(node, pyext.pretty_compile(strtobytes(pre_transform(code, kwargs))))
pretty_compile_chunk = lambda code, **kwargs: map(node, pyext.pretty_compile_chunk(strtobytes(pre_transform(code, kwargs))))
pretty_compile_lll = lambda code, **kwargs: map(node, pyext.pretty_compile_lll(take(strtobytes(pre_transform(code, kwargs)))))
serialize = lambda x: pyext.serialize(takelist(strtobytes(x)))
deserialize = lambda x: map(node, pyext.deserialize(x))
mk_signature = lambda code, **kwargs: pyext.mk_signature(strtobytes(pre_transform(code, kwargs)))
mk_full_signature = lambda code, **kwargs: json.loads(bytestostr(pyext.mk_full_signature(strtobytes(pre_transform(code, kwargs)))))
mk_contract_info_decl = lambda code, **kwargs: json.loads(bytestostr(pyext.mk_contract_info_decl(strtobytes(pre_transform(code, kwargs)))))
get_prefix = lambda x: pyext.get_prefix(strtobytes(x)) % 2**32