Пример #1
0
def project(projector, node_):
    scope = get_scope(node_)
    gblock = get_block_child(node_)
    block = projector.visit(gblock)
    throw = None  # localthrow  # FIXME: need destination roles
    catches = []  # [localcatch]

    #RoleCollector() # Couldn't import conveniently (cyclic)
    involved = projector.rc.collect_roles(gblock)
    for i in get_interrupt_children(node_):
        subj = globalinterrupt_get_role(i)  # String
        involved.add(subj)

    throw_messages = []
    for i in get_interrupt_children(node_):
        subj = globalinterrupt_get_role(i)  # String
        roles = list(involved - set([subj]))
        messages = []
        for sig in globalinterrupt_get_message_children(i):
            # Factor out with interrupt, message transfer, argument, etc.
            if util.get_node_type(sig) == \
                   constants.MESSAGE_SIGNATURE_NODE_TYPE:
                messages.append(messagesignature_pretty_print(sig))
            else:
                messages.append(parameter_pretty_print(sig))
        if projector.role == subj and len(roles) > 0:
            #throws.append(projector.nf.localthrow(dests, messages))
            #new_roles = util.replace_in_list(roles, projector.rolemap)
            new_roles = roles
            """throw = projector.nf.localthrow(#projector.rolemap[projector.role],
                                            projector.role,
                                            new_roles,
                                            messages)"""
            throw_messages.extend(messages)
        else:
            catches.append(
                projector.nf.localcatch(
                    #projector.rolemap[projector.role],
                    projector.role,
                    #projector.rolemap[subj],
                    subj,
                    messages))
    if throw_messages:
        throw = projector.nf.localthrow(projector.role, new_roles,
                                        throw_messages)
    if (not block.is_empty()) or throw:
        # Section 5.3.5 -- if R is involved in the interruptible (if it is
        # involved in the block or is a thrower)
        return projector.nf.localinterruptible(
            #projector.rolemap[projector.role], scope, block, throw, catches)
            projector.role,
            scope,
            block,
            throw,
            catches)
    else:
        return None
Пример #2
0
def pretty_print(node_):
    text = ''
    message = get_message_child(node_)
    if util.get_node_type(message) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        text = text + messagesignature_pretty_print(message)
    else:
        text = text + parameter_pretty_print(message)
    text = text + ' ' + constants.FROM_KW + ' '
    text = text + get_source(node_)
    text = text + ';'
    return text
def project(projector, node_):
    scope = get_scope(node_)
    gblock = get_block_child(node_)
    block = projector.visit(gblock)
    throw = None  # localthrow  # FIXME: need destination roles
    catches = []  # [localcatch]

    #RoleCollector() # Couldn't import conveniently (cyclic)
    involved = projector.rc.collect_roles(gblock)
    for i in get_interrupt_children(node_):
        subj = globalinterrupt_get_role(i)  # String
        involved.add(subj)
    
    throw_messages = []
    for i in get_interrupt_children(node_):
        subj = globalinterrupt_get_role(i)  # String
        roles = list(involved - set([subj]))
        messages = []
        for sig in globalinterrupt_get_message_children(i): 
            # Factor out with interrupt, message transfer, argument, etc.
            if util.get_node_type(sig) == \
                   constants.MESSAGE_SIGNATURE_NODE_TYPE:
                messages.append(messagesignature_pretty_print(sig))
            else:
                messages.append(parameter_pretty_print(sig))
        if projector.role == subj and len(roles) > 0:
            #throws.append(projector.nf.localthrow(dests, messages)) 
            #new_roles = util.replace_in_list(roles, projector.rolemap)
            new_roles = roles
            """throw = projector.nf.localthrow(#projector.rolemap[projector.role],
                                            projector.role,
                                            new_roles,
                                            messages)"""
            throw_messages.extend(messages)
        else:
            catches.append(projector.nf.localcatch(
                               #projector.rolemap[projector.role],
                               projector.role,
                               #projector.rolemap[subj],
                               subj,
                               messages))
    if throw_messages:
        throw = projector.nf.localthrow(projector.role,
                                        new_roles,
                                        throw_messages)
    if (not block.is_empty()) or throw:
        # Section 5.3.5 -- if R is involved in the interruptible (if it is
        # involved in the block or is a thrower)
        return projector.nf.localinterruptible(
                   #projector.rolemap[projector.role], scope, block, throw, catches)
                   projector.role, scope, block, throw, catches)
    else:
        return None
Пример #4
0
def pretty_print(node_):
    text = ""
    message = get_message_child(node_)
    if util.get_node_type(message) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        text = text + messagesignature_pretty_print(message)
    else:
        text = text + parameter_pretty_print(message)
    text = text + ' ' + constants.TO_KW + ' '
    dests = get_destinations(node_)
    text = text + dests[0]
    for dest in dests[1:]:
        text = text + ', ' + dest
    text = text + ';'
    return text
def pretty_print(node_):
    text = ""
    message = get_message_child(node_)
    if util.get_node_type(message) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        text = text + messagesignature_pretty_print(message)
    else:
        text = text + parameter_pretty_print(message)
    text = text + ' ' + constants.FROM_KW + ' '
    text = text + get_source(node_)
    text = text + ' ' + constants.TO_KW + ' '
    dests = get_destinations(node_)
    text = text + dests[0]
    for dest in dests[1:]:
        text = text + ', ' + dest
    text = text + ';'
    return text
Пример #6
0
def _pretty_print_aux(msg):  # Factor out more globally (also in localthrow)
    if util.get_node_type(msg) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        return messagesignature_pretty_print(msg)
    else:
        return parameter_pretty_print(msg)