Exemplo n.º 1
0
def deserialize(trace):
    res = []
    for line in trace:
        line_t = tuple(line)

        if opcode(line_t) == "while":
            _, cond, path, lid, setvars = line_t
            cond = tuplify(cond)
            setvars = tuplify(setvars)
            assert type(lid) == str

            path = deserialize(path)
            res.append(("while", cond, path, lid, setvars))

        elif opcode(line_t) == "if":
            _, cond, if_true, if_false = line_t
            cond = tuplify(cond)
            if_true = deserialize(if_true)
            if_false = deserialize(if_false)
            res.append(("if", cond, if_true, if_false))

        else:
            res.append(tuplify(line))

    return res
Exemplo n.º 2
0
def deserialize(trace):
    res = []
    for line in trace:
        line_t = tuple(line)

        if line_t ~ ('while', :cond, :path, :lid, :setvars):
            cond = tuplify(cond)
            setvars = tuplify(setvars)
            assert type(lid) == str

            path = deserialize(path)
            res.append(('while', cond, path, lid, setvars))

        elif line_t ~ ('if', :cond, :if_true, :if_false):
Exemplo n.º 3
0
def deserialize(trace):
    res = []
    for line in trace:
        line_t = tuple(line)

        if line_t ~ ('while', :cond, :path, :lid, :setvars):
            cond = tuplify(cond)
            setvars = tuplify(setvars)
            assert type(lid) == str

            path = deserialize(path)
            res.append(('while', cond, path, lid, setvars))

        elif line_t ~ ('if', :cond, :if_true, :if_false):
            cond = tuplify(cond)
            if_true = deserialize(if_true)
            if_false = deserialize(if_false)
            res.append(('if', cond, if_true, if_false))

        else:
            res.append(tuplify(line))

    return res


class Contract():

    def __init__(self, addr, network, functions, problems, ver):
        self.addr = addr
        self.network = network