def _get_imported_modules(context, module_): importmodules = module_get_importmodule_children(module_) for im in importmodules: fn = importmodule_get_full_module_name(im) # Distinct names already checked dn = importmodule_get_declaration_name(im) m = context.get_module(fn) # Section 4.1.1 -- imported module_ referred to by declaration name if dn not in context.get_visible_modules().keys(): context = context.add_visible_module(dn, m) context = _get_module_members(context, dn, m) return context
def _get_imported_modules(context, module_): importmodules = module_get_importmodule_children(module_) for im in importmodules: fn = importmodule_get_full_module_name(im) # Distinct names already checked dn = importmodule_get_declaration_name(im) m = context.get_module(fn) # Section 4.1.1 -- imported module_ referred to by declaration name # FIXME: transitively import modules -- not working for project all (and do well-formedness?) if dn not in context.get_visible_modules().keys(): context = context.add_visible_module(dn, m) context = _get_module_members(context, dn, m) return context
def _get_imported_modules(context, module_): importmodules = module_get_importmodule_children(module_) for im in importmodules: fn = importmodule_get_full_module_name(im) # Distinct names already checked dn = importmodule_get_declaration_name(im) m = context.get_module(fn) # Section 4.1.1 -- imported module_ referred to by declaration name # FIXME: transitively import modules -- not working for project all (and do well-formedness?) if dn not in context.get_visible_modules().keys(): context = context.add_visible_module(dn, m) context = _get_module_members(context, dn, m) return context
def check_wellformedness_visit(checker, node_): ## # Section 4.2 -- Simple name and filename of module condition checked in moduledecl_ (also currently checked earlier by moduleLoader) ## # Section 4.2 -- Distinct module names condition fmn = moduledecl_get_full_name(get_moduledecl_child(node_)) smn_from_fmn = util.get_simple_module_name_from_full_module_name(fmn) names = [smn_from_fmn] for im in get_importmodule_children(node_): name = importmodule_get_declaration_name(im) if name in names: util.report_error("Bad module import declaration name: " + name) names.append(name) ## # Section 4.2 -- Distinct member names condition names = [] for ptd in get_payloadtypedecl_children(node_): name = payloadtypedecl_get_declaration_name(ptd) if name in names: util.report_error("Bad payload type declaration name: " + name) names.append(name) for gpd in get_globalprotocoldecl_children(node_): name = globalprotocoldecl_get_name(gpd) if name in names: util.report_error("Bad global protocol declaration name: " + name) names.append(name) for lpd in get_localprotocoldecl_children(node_): name = localprotocoldecl_get_name(lpd) if name in names: util.report_error("Bad local protocol declaration name: " + name) names.append(name) for im in get_importmember_children(node_): # TODO: import member declaration names util.report_error("TODO member import: " + im) ## # Section 4.2 -- Well-formed import declarations and members # # Same visiting structure as traverse; in the general case, however, # well-formedness visiting needs to visit each child with a separate # context, so cannot directly reuse the traverse routine here visited = [] moduledecl_ = get_moduledecl_child(node_) visited.append(checker.visit(moduledecl_)) for im in get_importmodule_children(node_): visited.append(checker.visit(im)) for im in get_importmember_children(node_): util.report_error("Member Import not supported yet.") # FIXME: also members for ptd in get_payloadtypedecl_children(node_): visited.append(checker.visit(ptd)) for gpd in get_globalprotocoldecl_children(node_): visited.append(checker.visit(gpd)) for lpd in get_localprotocoldecl_children(node_): # visited.append(checker.visit(lpd)) # TODO util.report_warning("[WellformednessChecker] Skipping localprotocoldecl: " + localprotocoldecl_get_name(lpd)) # print "Skipped:\n", localprotocoldecl_pretty_print(lpd) # rebuild using new children return util.antlr_dupnode_and_replace_children(node_, visited)
def check_wellformedness_visit(checker, node_): ## # Section 4.2 -- Simple name and filename of module condition checked in moduledecl_ (also currently checked earlier by moduleLoader) ## # Section 4.2 -- Distinct module names condition fmn = moduledecl_get_full_name(get_moduledecl_child(node_)) smn_from_fmn = util.get_simple_module_name_from_full_module_name(fmn) names = [smn_from_fmn] for im in get_importmodule_children(node_): name = importmodule_get_declaration_name(im) if name in names: util.report_error("Bad module import declaration name: " + name) names.append(name) ## # Section 4.2 -- Distinct member names condition names = [] for ptd in get_payloadtypedecl_children(node_): name = payloadtypedecl_get_declaration_name(ptd) if name in names: util.report_error("Bad payload type declaration name: " + name) names.append(name) for gpd in get_globalprotocoldecl_children(node_): name = globalprotocoldecl_get_name(gpd) if name in names: util.report_error("Bad global protocol declaration name: " + name) names.append(name) for lpd in get_localprotocoldecl_children(node_): name = localprotocoldecl_get_name(lpd) if name in names: util.report_error("Bad local protocol declaration name: " + name) names.append(name) for im in get_importmember_children(node_): # TODO: import member declaration names util.report_error("TODO member import: " + im) ## # Section 4.2 -- Well-formed import declarations and members # # Same visiting structure as traverse; in the general case, however, # well-formedness visiting needs to visit each child with a separate # context, so cannot directly reuse the traverse routine here visited = [] moduledecl_ = get_moduledecl_child(node_) visited.append(checker.visit(moduledecl_)) for im in get_importmodule_children(node_): visited.append(checker.visit(im)) for im in get_importmember_children(node_): util.report_error("Member Import not supported yet.") # FIXME: also members for ptd in get_payloadtypedecl_children(node_): visited.append(checker.visit(ptd)) for gpd in get_globalprotocoldecl_children(node_): visited.append(checker.visit(gpd)) for lpd in get_localprotocoldecl_children(node_): #visited.append(checker.visit(lpd)) # TODO util.report_warning("[WellformednessChecker] Skipping localprotocoldecl: " \ + localprotocoldecl_get_name(lpd)) #print "Skipped:\n", localprotocoldecl_pretty_print(lpd) # rebuild using new children return util.antlr_dupnode_and_replace_children(node_, visited)