def test_parse_and_convert1(self):
        ast = ctoc.minic_parse_file('./c_files/minic.c')
        self.failUnless(isinstance(ast, mast.FileAST))
        self.assertEqual(len(ast.ext), 2)
        self.failUnless(isinstance(ast.ext[0], mast.FuncDef))

        funcdef_mss = ast.ext[0]
        self.assertEqual(funcdef_mss.decl.name, 'mss')
        mss_body = funcdef_mss.body
        self.assertTrue(isinstance(mss_body, mast.Block))
        self.assertEqual(len(mss_body.block_items), 5)
        self.failUnless(isinstance(mss_body.block_items[0], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[1], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[2], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[3], mast.For))
        forstmt = mss_body.block_items[3]
        self.assertTrue(isinstance(forstmt.next, mast.Assignment))
        self.failUnless(isinstance(mss_body.block_items[4], mast.Return))

        funcdef_main = ast.ext[1]
        self.assertEqual(funcdef_main.decl.name, 'main')
        main_body = funcdef_main.body
        self.assertEqual(len(main_body.block_items), 4)
        self.failUnless(isinstance(main_body.block_items[0], mast.Decl))
        self.failUnless(isinstance(main_body.block_items[1], mast.Decl))
        self.failUnless(isinstance(main_body.block_items[2], mast.Assignment))
        self.failUnless(isinstance(main_body.block_items[3], mast.Return))
Beispiel #2
0
    def test_parse_and_convert1(self):
        ast = ctoc.minic_parse_file('./c_files/minic.c')
        self.failUnless(isinstance(ast, mast.FileAST))
        self.assertEqual(len(ast.ext), 2)
        self.failUnless(isinstance(ast.ext[0], mast.FuncDef))

        funcdef_mss = ast.ext[0]
        self.assertEqual(funcdef_mss.decl.name, 'mss')
        mss_body = funcdef_mss.body
        self.assertTrue(isinstance(mss_body, mast.Block))
        self.assertEqual(len(mss_body.block_items), 5)
        self.failUnless(isinstance(mss_body.block_items[0], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[1], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[2], mast.Decl))
        self.failUnless(isinstance(mss_body.block_items[3], mast.For))
        forstmt = mss_body.block_items[3]
        self.assertTrue(isinstance(forstmt.next, mast.Assignment))
        self.failUnless(isinstance(mss_body.block_items[4], mast.Return))

        funcdef_main = ast.ext[1]
        self.assertEqual(funcdef_main.decl.name, 'main')
        main_body = funcdef_main.body
        self.assertEqual(len(main_body.block_items), 4)
        self.failUnless(isinstance(main_body.block_items[0], mast.Decl))
        self.failUnless(isinstance(main_body.block_items[1], mast.Decl))
        self.failUnless(isinstance(main_body.block_items[2], mast.Assignment))
        self.failUnless(isinstance(main_body.block_items[3], mast.Return))
Beispiel #3
0
    def test_reachingdefs(self):
        ast = ctoc.minic_parse_file('./c_files/loop_analysis.c')
        # Reaching Definitions analysis
        rdefs_analyzer = mana.FuncBodiesAnalysis('ReachingDefinitions')
        rdefs_analyzer.visit(ast)

        # Reaching Definitions analysis
        liveness_analyzer = mana.FuncBodiesAnalysis('LiveVariables')
        liveness_analyzer.visit(ast)
Beispiel #4
0
    def test_analyze(self):
        ast = ctoc.minic_parse_file('./c_files/nested_loops.c')
        # Reaching Definitions analysis
        rdefs_analyzer = mana.FuncBodiesAnalysis('ReachingDefinitions')
        rdefs_analyzer.visit(ast)
        rdefs_analyzer.print_results()

        # Reaching Definitions analysis
        liveness_analyzer = mana.FuncBodiesAnalysis('LiveVariables')
        liveness_analyzer.visit(ast)
        liveness_analyzer.print_results()
 def test_parse_and_convert_constructs(self):
     ast = ctoc.minic_parse_file('./c_files/constructs.c')
     self.failUnless(isinstance(ast, mast.FileAST))
 def test_parse_and_convert2(self):
     converted = ctoc.minic_parse_file('./c_files/test2.c')
     self.failUnless(isinstance(converted, mast.FileAST))
Beispiel #7
0
 def test_parse_and_convert_p1(self):
     for file in uts.locate(r'p1_input\d\.c', './c_files/'):
         print(file)
         ast = ctoc.minic_parse_file(file)
         self.failUnless(isinstance(ast, mast.FileAST))
     print("  ....OK")
Beispiel #8
0
 def test_parse_and_convert_constructs(self):
     ast = ctoc.minic_parse_file('./c_files/constructs.c')
     self.failUnless(isinstance(ast, mast.FileAST))
Beispiel #9
0
 def test_parse_and_convert2(self):
     converted = ctoc.minic_parse_file('./c_files/test2.c')
     self.failUnless(isinstance(converted, mast.FileAST))
 def test_parse_and_convert_p1(self):
     for file in uts.locate(r'p1_input\d\.c', './c_files/'):
         print(file)
         ast = ctoc.minic_parse_file(file)
         self.failUnless(isinstance(ast, mast.FileAST))
     print("  ....OK")