def check_wellformedness(context_, target, node_):
    ris = get_roleinstantiation_children(node_)

    tree = context_.get_visible_global(target)
    rparamlist = roledecllist_get_roledecl_children(
                     globalprotocoldecl_get_roledecllist_child(tree))

    # Section 4.6.3 -- lengts of role-instantiation-list and target
    # role-decl-list are the same
    if len(ris) != len(rparamlist):
        util.report_error("Bad number of role arguments, expected: " + \
                          str(len(rparamlist)))

    croles = context_.get_roles()
    rparams = rparamlist.__iter__()
    rolemap = {}  # params -> args (as strings --
                  # maybe should do ROLE node_, as for argmap)
    for ri in ris:
        ours = roleinstantiation_get_arg(ri)
        next = rparams.next()
        theirs = roledecl_get_role_name(next)
        # Section 4.6.3 -- every role argument is bound and distinct
        if (ours not in croles) or ours in rolemap.values():
            util.report_error("Bad role argument: " + ours)
        if roleinstantiation_has_parameter_child(ri):
            tmp = roleinstantiation_get_parameter(ri)
            if theirs != tmp: 
                # Section 4.6.3 -- every instantiation parameter corresponds to
                # the declared parameter in the protocol declaration
                util.report_error("Bad role parameter: " + theirs + ", " +tmp)
        rolemap[roledecl_get_declaration_name(next)] = ours

    return rolemap
Example #2
0
def check_wellformedness(context_, target, node_):
    ris = get_roleinstantiation_children(node_)

    tree = context_.get_visible_global(target)
    rparamlist = roledecllist_get_roledecl_children(
                     globalprotocoldecl_get_roledecllist_child(tree))

    # Section 4.6.3 -- lengts of role-instantiation-list and target
    # role-decl-list are the same
    if len(ris) != len(rparamlist):
        util.report_error("Bad number of role arguments, expected: " + \
                          str(len(rparamlist)))

    croles = context_.get_roles()
    rparams = rparamlist.__iter__()
    rolemap = {}  # params -> args (as strings --
                  # maybe should do ROLE node_, as for argmap)
    for ri in ris:
        ours = roleinstantiation_get_arg(ri)
        next = rparams.next()
        theirs = roledecl_get_role_name(next)
        # Section 4.6.3 -- every role argument is bound and distinct
        if (ours not in croles) or ours in rolemap.values():
            util.report_error("Bad role argument: " + ours)
        if roleinstantiation_has_parameter_child(ri):
            tmp = roleinstantiation_get_parameter(ri)
            if theirs != tmp: 
                # Section 4.6.3 -- every instantiation parameter corresponds to
                # the declared parameter in the protocol declaration
                util.report_error("Bad role parameter: " + theirs + ", " +tmp)
        rolemap[roledecl_get_declaration_name(next)] = ours

    return rolemap
Example #3
0
def _project_all(context_):
    for _, module_ in context_.get_modules().items():
        clone = context_.set_current_module(module_get_full_name(module_))
        clone = build_visibility(clone, module_)
        for (proto, gpd) in clone.get_visible_globals().items():
            full_global_name = globalprotocoldecl_get_full_name(gpd)
            rdl = globalprotocoldecl_get_roledecllist_child(gpd)
            #rolemap = roledecllist_get_rolemap(rdl) 
            #for role_ in globalprotocoldecl_get_role_names(gpd):
            for rd in roledecllist_get_roledecl_children(rdl):
                dname = roledecl_get_declaration_name(rd)
                role_ = roledecl_get_role_name(rd)
                full_local_name = globaldo_get_projected_member_name(
                                      full_global_name, role_)
                                      #full_global_name, rolemap[role_])
                if context_.has_projection(full_local_name):
                    break
                projector = Projector()
                lpd = projector.project_globalprotocoldecl(clone, gpd, dname)#, rolemap)
                #full_name = lpd.get_full_name(clone)
                context_ = context_.add_projection(full_local_name, lpd)
                
                #print "Projected", full_global_name, "for", role_ + ":\n", \
                #      lpd.pretty_print()
    return context_
def check_wellformedness_enter(checker, node_):
    context_ = checker.get_context()
    roles = []
    for rd in get_roledecl_children(node_):
        role = roledecl_get_declaration_name(rd)
        # Section 4.6 -- Global protocol header: distinct role declaration names
        if role in roles:
            util.report_error("Bad role declaration name: " + role)
        roles.append(role)
Example #5
0
def check_wellformedness_enter(checker, node_):
    context_ = checker.get_context()
    roles = []
    for rd in get_roledecl_children(node_):
        role = roledecl_get_declaration_name(rd)
        # Section 4.6 -- Global protocol header: distinct role declaration names
        if role in roles:
            util.report_error("Bad role declaration name: " + role)
        roles.append(role)
def context_visitor_enter(cv, node_):
    context_ = cv.get_context()
    for rd in get_roledecl_children(node_):
        role_ = roledecl_get_declaration_name(rd)
        # Section 4.6.1 -- bound occurrences of role_ declaration names
        context_ = context_.add_role(role_)
        if context_.is_role_enabled(role_):
            raise Exception("Shouldn't get in here: ", role_)
        # Section 4.6.6 -- role_ receives before sends implemented as role_
        # enabled/disabled, here setting each declared role_ as initially enabled
        context_ = context_.enable_role(role_, globalchoice_DUMMY_ENABLING_OP)
    cv.set_context(context_)  # No push/enter
Example #7
0
def context_visitor_enter(cv, node_):
    context_ = cv.get_context()
    for rd in get_roledecl_children(node_):
        role_ = roledecl_get_declaration_name(rd)
        # Section 4.6.1 -- bound occurrences of role_ declaration names
        context_ = context_.add_role(role_)
        if context_.is_role_enabled(role_):
            raise Exception("Shouldn't get in here: ", role_)
        # Section 4.6.6 -- role_ receives before sends implemented as role_
        # enabled/disabled, here setting each declared role_ as initially enabled
        context_ = context_.enable_role(role_, globalchoice_DUMMY_ENABLING_OP)
    cv.set_context(context_)  # No push/enter
Example #8
0
def get_role_map(context_, target, node_):
    rolemap = {}  # params -> args (string -> string)
    tree = context_.get_visible_global(target)
    rparamlist = roledecllist_get_roledecl_children(
        globalprotocoldecl_get_roledecllist_child(tree))
    rparams = rparamlist.__iter__()
    ris = get_roleinstantiation_children(node_)
    for ri in ris:
        ours = roleinstantiation_get_arg(ri)  # returns string
        next = rparams.next()
        rolemap[roledecl_get_declaration_name(next)] = ours
    return rolemap
def get_role_map(context_, target, node_):
    rolemap = {}  # params -> args (string -> string)
    tree = context_.get_visible_global(target)
    rparamlist = roledecllist_get_roledecl_children(
                     globalprotocoldecl_get_roledecllist_child(tree))
    rparams = rparamlist.__iter__()
    ris = get_roleinstantiation_children(node_)
    for ri in ris:
        ours = roleinstantiation_get_arg(ri)  # returns string
        next = rparams.next()
        rolemap[roledecl_get_declaration_name(next)] = ours
    return rolemap
Example #10
0
def get_declaration_names(node_):
    roles = []
    for rd in get_roledecl_children(node_):
        roles.append(roledecl_get_declaration_name(rd))
    return roles
Example #11
0
def get_declaration_names(node_):
    roles = []
    for rd in get_roledecl_children(node_):
        roles.append(roledecl_get_declaration_name(rd))
    return roles