예제 #1
0
 def send_base_message(self, trans_operation: CommonTree,
                       transition: Transition,
                       var_names: Dict[str, str]) -> List[CommonTree]:
     ret_operation = trans_operation
     children = trans_operation.getChildren()
     if str(children[1]) in var_names:
         tmp_operation = copy.deepcopy(trans_operation)
         tmp_operation.token.text = MurphiModular.tPUSH_HL_DEFER
         tmp_operation.children[1].token.text = var_names[str(children[1])]
         transition.operation = copy.copy(transition.operation)
         transition.operation[transition.operation.index(
             trans_operation)] = tmp_operation
         return [ret_operation]
     return []
예제 #2
0
    def defer_base_message(self, trans_operation: CommonTree,
                           transition: Transition,
                           var_names: Dict[str, str]) -> List[CommonTree]:
        local_defer_operations = []

        children = trans_operation.getChildren()

        defer_var_name = MurphiModular.vdeferpref + str(children[0]) + "_" + \
                         str(children[2].children[1])
        # Records the variable name of the child
        var_names[str(children[0])] = defer_var_name

        # Recover next deferred operation
        tmp_operation = copy.deepcopy(trans_operation)
        tmp_children = tmp_operation.getChildren()
        defer_var_name = MurphiModular.vdeferpref + str(tmp_children[0]) + "_" + \
                         str(tmp_children[2].children[1])
        tmp_children[0].token.text = defer_var_name
        tmp_children[2].token.text = MurphiModular.tPOP_HL_DEFER
        local_defer_operations.append(tmp_operation)

        # Construct Original Message from deferred operation
        tmp_operation = copy.deepcopy(trans_operation)
        tmp_children = tmp_operation.getChildren()
        tmp_children[2].token.text = MurphiModular.tSEND_BASE_DEFER
        tmp_children[2].children[1].token.text = defer_var_name
        for ind in range(2, len(MurphiModular.BaseMsg)):
            tmp_children[2].children.pop(2)

        local_defer_operations.append(tmp_operation)

        tmp_operation = copy.deepcopy(trans_operation)
        tmp_children = tmp_operation.getChildren()

        # Generate BaseMessage that is deferred
        tmp_children[0].token.text = defer_var_name
        tmp_children[2].token.text = MurphiModular.tSEND_BASE_DEFER
        tmp_children[2].children[0].token.text = MurphiModular.rbasemessage
        for ind in range(len(MurphiModular.BaseMsg),
                         len(tmp_children[2].getChildren())):
            tmp_children[2].children.pop(len(MurphiModular.BaseMsg))

        # Update the transition
        transition.operation = copy.copy(transition.operation)
        transition.operation[transition.operation.index(
            trans_operation)] = tmp_operation

        return local_defer_operations