示例#1
0
def test_refine_to_chain():
    import code_examples
    tac_name = 'tac_block'
    from tac_analysis import make_tacblock_cfg
    cfg = make_tacblock_cfg(code_examples.CreateSphere)
    refined = refine_to_chain(cfg, tac_name, 'tac')
    for x in sorted(refined.nodes_iter()):
        print(x, refined.node[x]['tac'].format())
示例#2
0
def analyze_type_safety(code_to_analyze):
    cfg = tac_analysis.make_tacblock_cfg(code_to_analyze)
    tac_analysis.print_tac_cfg(cfg)

    cfg = program_cfg.ProgramCFG(cfg, name=tac_analysis.BLOCKNAME)
    cfg.depict()
    print(cfg.program_vars())
    
    type_abstract_analyzer = types_predicate_abstraction.AbstractTypesAnalysis(cfg)
    abstract_type_for_reachable_location = chaotic_type_analysis(type_abstract_analyzer, cfg)
    type_safety_constraints = generate_type_safety_constraints(type_abstract_analyzer, cfg)
    types_exclusion_theory = type_abstract_analyzer.get_types_exclusion_theory()
    print(type_safety_constraints)
    
    result = check_type_safety(abstract_type_for_reachable_location, 
                         type_safety_constraints,
                         types_exclusion_theory)
    return result