Esempio n. 1
0
    def _visit_globalinterrupt(
        self, node
    ):  # FIXME: not actually permitted by the syntax yet, but for later
        rolemap = self.getroleMap()
        argmap = self.getArgMap()

        dup = node.dupNode()

        #util.report_error('[NameSubstitutor] TODO: ' + node)  # FIXME

        rolenode = globalinterrupt.get_role_child(node)
        msgnodes = globalinterrupt.get_message_children(node)

        dest = role.get_role_name(
            rolenode)  # FIXME: factor out with globalmessagetransfer
        tmp = rolenode.dupNode()
        if dest in rolemap.keys():
            val = rolemap[dest]
            tmp.token = copy.deepcopy(rolenode.token)
            util.set_node_type(tmp, val)
        dup.addChild(tmp)

        for mn in msgnodes:
            tmp = mn.dupNode()  # FIXME: factor out with globalmessagetransfer
            if util.get_node_type(mn) != constants.MESSAGE_SIGNATURE_NODE_TYPE:
                msg = parameter.get_parameter_name(
                    mn)  # parameter or message signature
                if msg in argmap.keys():  # a param to substitute
                    val = argmap[
                        msg]  # message signature or another parameter?
                    tmp.token = copy.deepcopy(
                        mn.token
                    )  # HACK: does it conflict with any parser meta data? e.g. line number?
                    #tmp.token.setText(_argmap[msg].getText())
                    util.set_node_type(tmp, util.get_node_type(val))
                    for mn in val.getChildren():
                        tmp.addChild(copy.deepcopy(mn))
            else:
                for mn in mn.getChildren():
                    tmp.addChild(copy.deepcopy(mn))
            #tmp.addChild(tmp)  # If a parameter but not a substitution object, then the dupNode for tmp is enough
            dup.addChild(tmp)

        return dup
    def _visit_globalinterrupt(self, node):  # FIXME: not actually permitted by the syntax yet, but for later
        rolemap = self.getroleMap()
        argmap = self.getArgMap()

        dup = node.dupNode()

        # util.report_error('[NameSubstitutor] TODO: ' + node)  # FIXME

        rolenode = globalinterrupt.get_role_child(node)
        msgnodes = globalinterrupt.get_message_children(node)

        dest = role.get_role_name(rolenode)  # FIXME: factor out with globalmessagetransfer
        tmp = rolenode.dupNode()
        if dest in rolemap.keys():
            val = rolemap[dest]
            tmp.token = copy.deepcopy(rolenode.token)
            util.set_node_type(tmp, val)
        dup.addChild(tmp)

        for mn in msgnodes:
            tmp = mn.dupNode()  # FIXME: factor out with globalmessagetransfer
            if util.get_node_type(mn) != constants.MESSAGE_SIGNATURE_NODE_TYPE:
                msg = parameter.get_parameter_name(mn)  # parameter or message signature
                if msg in argmap.keys():  # a param to substitute
                    val = argmap[msg]  # message signature or another parameter?
                    tmp.token = copy.deepcopy(
                        mn.token
                    )  # HACK: does it conflict with any parser meta data? e.g. line number?
                    # tmp.token.setText(_argmap[msg].getText())
                    util.set_node_type(tmp, util.get_node_type(val))
                    for mn in val.getChildren():
                        tmp.addChild(copy.deepcopy(mn))
            else:
                for mn in mn.getChildren():
                    tmp.addChild(copy.deepcopy(mn))
            # tmp.addChild(tmp)  # If a parameter but not a substitution object, then the dupNode for tmp is enough
            dup.addChild(tmp)

        return dup
    def _visit_globalmessagetransfer(self, node):
        rolemap = self.getroleMap()
        argmap = self.getArgMap()

        dup = node.dupNode()
        #dup.children = [''] * 3

        msgnode = globalmessagetransfer.get_message_child(node)
        srcnode = globalmessagetransfer.get_source_child(node)
        #destnode = globalmessagetransfer.getglobalmessagetransferDestinationChild(node)
        destnodes = globalmessagetransfer.get_destination_children(node)

        tmp = msgnode.dupNode()
        if util.get_node_type(msgnode) != constants.MESSAGE_SIGNATURE_NODE_TYPE:
            msg = parameter.get_parameter_name(msgnode)  # parameter or message signature

            if msg in argmap.keys():  # a param to substitute
                val = argmap[msg]  # message signature or another parameter?
                tmp.token = copy.deepcopy(msgnode.token)  # HACK: does it conflict with any parser meta data? e.g. line number?
                #tmp.token.setText(_argmap[msg].getText())
                util.set_node_type(tmp, util.get_node_type(val))
                for child in val.getChildren():
                    tmp.addChild(copy.deepcopy(child))
        else:
            tmp.addChild(copy.deepcopy(messagesignature.get_operator_child(msgnode)))
            payload = messagesignature.get_payload_child(msgnode)
            tmp2 = payload.dupNode()
            for pe in payload.getChildren():
                tmp3 = pe.dupNode()
                tmp3.addChild(copy.deepcopy(payloadelement.get_annotation_child(pe)))
                child = payloadelement.get_type_child(pe)
                tmp4 = child.dupNode()
                if child.getText() in argmap.keys():
                    val = argmap[child.getText()]
                    tmp4.token = copy.deepcopy(child.token)
                    util.set_node_type(tmp4, util.get_node_type(val))  # parameter name and payload type both correspond to the node type for this node (the text of the node)
                tmp3.addChild(tmp4)
                tmp2.addChild(tmp3)
            tmp.addChild(tmp2)
        dup.addChild(tmp)  # If a parameter but not a substitution object, then the dupNode for tmp is enough

        src = role.get_role_name(srcnode)
        tmp = srcnode.dupNode()  # FIXME: sort out dupNode vs deepclone
        if src in rolemap.keys():  # FIXME: factor out this routine
            val = rolemap[src]
            #token = tmp.getToken()
            #token.setText(_rolemap[src])
            #tmp.setToken(token)

            #tmp.token.setText(_rolemap[src])
            tmp.token = copy.deepcopy(srcnode.token)
            #tmp.token.setText(_rolemap[src])
            util.set_node_type(tmp, val)
        #dup.setChild(1, tmp)
        dup.addChild(tmp)

        for destnode in destnodes:
            dest = role.get_role_name(destnode)
            tmp = destnode.dupNode()
            if dest in rolemap.keys():
                val = rolemap[dest]
                tmp.token = copy.deepcopy(destnode.token)
                #tmp.token.setText(_rolemap[dest])
                util.set_node_type(tmp, val)
            #dup.setChild(2, tmp)
            dup.addChild(tmp)

        return dup
Esempio n. 4
0
    def _visit_globalmessagetransfer(self, node):
        rolemap = self.getroleMap()
        argmap = self.getArgMap()

        dup = node.dupNode()
        #dup.children = [''] * 3

        msgnode = globalmessagetransfer.get_message_child(node)
        srcnode = globalmessagetransfer.get_source_child(node)
        #destnode = globalmessagetransfer.getglobalmessagetransferDestinationChild(node)
        destnodes = globalmessagetransfer.get_destination_children(node)

        tmp = msgnode.dupNode()
        if util.get_node_type(
                msgnode) != constants.MESSAGE_SIGNATURE_NODE_TYPE:
            msg = parameter.get_parameter_name(
                msgnode)  # parameter or message signature

            if msg in argmap.keys():  # a param to substitute
                val = argmap[msg]  # message signature or another parameter?
                tmp.token = copy.deepcopy(
                    msgnode.token
                )  # HACK: does it conflict with any parser meta data? e.g. line number?
                #tmp.token.setText(_argmap[msg].getText())
                util.set_node_type(tmp, util.get_node_type(val))
                for child in val.getChildren():
                    tmp.addChild(copy.deepcopy(child))
        else:
            tmp.addChild(
                copy.deepcopy(messagesignature.get_operator_child(msgnode)))
            payload = messagesignature.get_payload_child(msgnode)
            tmp2 = payload.dupNode()
            for pe in payload.getChildren():
                tmp3 = pe.dupNode()
                tmp3.addChild(
                    copy.deepcopy(payloadelement.get_annotation_child(pe)))
                child = payloadelement.get_type_child(pe)
                tmp4 = child.dupNode()
                if child.getText() in argmap.keys():
                    val = argmap[child.getText()]
                    tmp4.token = copy.deepcopy(child.token)
                    util.set_node_type(
                        tmp4, util.get_node_type(val)
                    )  # parameter name and payload type both correspond to the node type for this node (the text of the node)
                tmp3.addChild(tmp4)
                tmp2.addChild(tmp3)
            tmp.addChild(tmp2)
        dup.addChild(
            tmp
        )  # If a parameter but not a substitution object, then the dupNode for tmp is enough

        src = role.get_role_name(srcnode)
        tmp = srcnode.dupNode()  # FIXME: sort out dupNode vs deepclone
        if src in rolemap.keys():  # FIXME: factor out this routine
            val = rolemap[src]
            #token = tmp.getToken()
            #token.setText(_rolemap[src])
            #tmp.setToken(token)

            #tmp.token.setText(_rolemap[src])
            tmp.token = copy.deepcopy(srcnode.token)
            #tmp.token.setText(_rolemap[src])
            util.set_node_type(tmp, val)
        #dup.setChild(1, tmp)
        dup.addChild(tmp)

        for destnode in destnodes:
            dest = role.get_role_name(destnode)
            tmp = destnode.dupNode()
            if dest in rolemap.keys():
                val = rolemap[dest]
                tmp.token = copy.deepcopy(destnode.token)
                #tmp.token.setText(_rolemap[dest])
                util.set_node_type(tmp, val)
            #dup.setChild(2, tmp)
            dup.addChild(tmp)

        return dup