def _check_reachability(context_): for proto, lpd in context_.get_projections().items(): local_module_name = util.get_full_module_name_from_full_member_name( proto) clone = context_.set_current_module(local_module_name) rc = ReachabilityChecker(clone) tmp = rc.check_reachability(lpd)
def project(projector, node_): localtarget = projector.local_target subprotos = projector.subprotocols target_localmodulename = localtarget[:localtarget.rfind('.')] # Can also derive from (global) node_ decl = projector.nf.moduledecl(target_localmodulename) imports = [] payloads = [] lpd = projector.context.get_projection(localtarget) subprotos = projector.collect_subprotocols(projector.context, lpd.get_body().get_block()) module_refs = [] for sp in subprotos: module_refs.append( util.get_global_module_name_from_projected_member_name(sp)) for id in get_importdecl_children(node_): if util.get_node_type(id) == constants.IMPORT_MODULE_NODE_TYPE: if importmodule_get_full_name(id) in module_refs: tmp = projector.visit(id) if tmp != None: imports.append(tmp) else: raise RuntimeError("TODO: " + id) # Additional imports to insert due to co-module protocols being projected # into separate output modules target_globalmodulename = \ util.get_global_module_name_from_projected_member_name(localtarget) # sp is the local subprotocol name for sp in subprotos: if sp != localtarget: gmn = util.get_global_module_name_from_projected_member_name(sp) if gmn == target_globalmodulename: # Subprotocol is a global co-module protocol of the target lmn = util.get_full_module_name_from_full_member_name(sp) im = projector.nf.importmodule(lmn, None) imports.append(im) for ptd in get_payloadtypedecl_children(node_): payloads.append(projector.visit(ptd)) # Creating the local module "shell" return projector.nf.module(decl, imports, payloads, [], [])
def project(projector, node_): localtarget = projector.local_target subprotos = projector.subprotocols target_localmodulename = localtarget[: localtarget.rfind(".")] # Can also derive from (global) node_ decl = projector.nf.moduledecl(target_localmodulename) imports = [] payloads = [] lpd = projector.context.get_projection(localtarget) subprotos = projector.collect_subprotocols(projector.context, lpd.get_body().get_block()) module_refs = [] for sp in subprotos: module_refs.append(util.get_global_module_name_from_projected_member_name(sp)) for id in get_importdecl_children(node_): if util.get_node_type(id) == constants.IMPORT_MODULE_NODE_TYPE: if importmodule_get_full_name(id) in module_refs: tmp = projector.visit(id) if tmp != None: imports.append(tmp) else: raise RuntimeError("TODO: " + id) # Additional imports to insert due to co-module protocols being projected # into separate output modules target_globalmodulename = util.get_global_module_name_from_projected_member_name(localtarget) # sp is the local subprotocol name for sp in subprotos: if sp != localtarget: gmn = util.get_global_module_name_from_projected_member_name(sp) if gmn == target_globalmodulename: # Subprotocol is a global co-module protocol of the target lmn = util.get_full_module_name_from_full_member_name(sp) im = projector.nf.importmodule(lmn, None) imports.append(im) for ptd in get_payloadtypedecl_children(node_): payloads.append(projector.visit(ptd)) # Creating the local module "shell" return projector.nf.module(decl, imports, payloads, [], [])
def project(projector, node_): projections = projector.context.get_projections() fmn = get_full_module_name(node_) # Check if this import is referring to one of the subprotocol modules. # "target" is the local target name # # FIXME: make precise about which subprotocols are actually needed (use # SubprotocolCollector again for the current target) for target in projector.subprotocols: gmn = util.get_global_module_name_from_projected_member_name(target) if fmn == gmn: if not has_alias(node_): localmodulename = \ util.get_full_module_name_from_full_member_name(target) return projector.nf.importmodule(localmodulename, None) else: util.report_error("[Projector] importmodule TODO: " + \ get_declaration_name(node_)) #else: # util.report_error("[Projector] importmodule TODO: " + target)""" return None
def get_projected_member_name(full_global_member_name, role_): module_ = util.get_full_module_name_from_full_member_name( full_global_member_name) proto = util.get_simple_member_name_from_full_member_name( full_global_member_name) return module_ + '_' + proto + '_' + role_ + '.' + proto + '_' + role_