示例#1
0
def get_arg(node_):
    arg = get_arg_child(node_)
    if util.get_node_type(arg) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        # FIXME: broken if type/parameter name happens to be 'MESSAGESIGNATURE'
        return messagesignature_pretty_print(arg)  # Is this right?
    else:
        return arg.getText()  # payload type or parameter name
def _pretty_print_aux(sig):
    if util.get_node_type(sig) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        return messagesignature_pretty_print(sig) 
        #text = text + util.pretty_print(sig)
    else:
        # TODO: parameter
        raise RuntimeError("TODO: " + parameter_get_parameter_name(sig))
示例#3
0
def _pretty_print_aux(sig):
    if util.get_node_type(sig) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        return messagesignature_pretty_print(sig)
        #text = text + util.pretty_print(sig)
    else:
        # TODO: parameter
        raise RuntimeError("TODO: " + parameter_get_parameter_name(sig))
示例#4
0
def get_arg(node_):
    arg = get_arg_child(node_)
    if util.get_node_type(arg) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
        # FIXME: broken if type/parameter name happens to be 'MESSAGESIGNATURE'
        return messagesignature_pretty_print(arg)  # Is this right?
    else:
        return arg.getText()  # payload type or parameter name
def project(projector, node_):
    src = get_source(node_)
    dests = get_destinations(node_)

    if src == projector.role or projector.role in dests:
        child = get_message_child(node_)
        message = None
        if util.get_node_type(child) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
            message = messagesignature_pretty_print(
                child)  # FIXME: string hack
        else:
            message = parameter_get_name(child)  # FIXME: string hack

        if src == projector.role:
            if projector.role in dests:
                util.report_error("Self communication not supported.")
            #new_dests = util.replace_in_list(dests, projector.rolemap)
            new_dests = dests
            return projector.nf.localsend(projector.role, new_dests, message)
        if projector.role in dests:
            if src == projector.role:
                util.report_error("Self communication not supported.")
            #new_src = util.replace_in_list([src], projector.rolemap)[0]
            new_src = src
            return projector.nf.localreceive(projector.role, new_src, message)
    else:
        return None  # OK to use None as "empty projection"?
def project(projector, node_):
    src = get_source(node_)
    dests = get_destinations(node_)

    if src == projector.role or projector.role in dests:
        child = get_message_child(node_)
        message = None
        if util.get_node_type(child) == constants.MESSAGE_SIGNATURE_NODE_TYPE:
            message = messagesignature_pretty_print(child)  # FIXME: string hack
        else:
            message = parameter_get_name(child)  # FIXME: string hack

        if src == projector.role:
            if projector.role in dests:
                util.report_error("Self communication not supported.")
            #new_dests = util.replace_in_list(dests, projector.rolemap)
            new_dests = dests
            return projector.nf.localsend(projector.role, new_dests, message)
        if projector.role in dests:
            if src == projector.role:
                util.report_error("Self communication not supported.")
            #new_src = util.replace_in_list([src], projector.rolemap)[0]
            new_src = src
            return projector.nf.localreceive(projector.role, new_src, message)
    else:
        return None  # OK to use None as "empty projection"?
示例#7
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
示例#8
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
示例#10
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
示例#12
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)