@@ -22,32 +22,35 @@ def __init__(self):
2222 self .namespaces = {}
2323
2424
25- def parse_cursor (children_nodes , cursor : clang .cindex .Cursor , parent_node ):
25+ def parse_cursor (children_nodes , cursor : clang .cindex .Cursor , parent_node , bruteforce : bool , verbose : bool ):
2626 if cursor .kind .name == 'COMPOUND_STMT' :
2727 for i in cursor .get_children ():
28- parse_cursor (children_nodes , i , parent_node )
28+ parse_cursor (children_nodes , i , parent_node , bruteforce , verbose )
2929 elif cursor .kind .name == 'FOR_STMT' :
30- children_nodes .append (ForLoop (parent_node , cursor ))
30+ children_nodes .append (ForLoop (parent_node , cursor , bruteforce , verbose ))
3131 elif cursor .kind .name == 'CXX_FOR_RANGE_STMT' :
32- children_nodes .append (ForRangeLoop (parent_node , cursor ))
32+ children_nodes .append (ForRangeLoop (parent_node , cursor , bruteforce , verbose ))
3333 elif cursor .kind .name == 'WHILE_STMT' :
34- children_nodes .append (WhileLoop (parent_node , cursor ))
34+ children_nodes .append (WhileLoop (parent_node , cursor , bruteforce , verbose ))
3535 elif cursor .kind .name == 'IF_STMT' :
36- children_nodes .append (If (parent_node , cursor ))
36+ children_nodes .append (If (parent_node , cursor , bruteforce , verbose ))
3737 elif cursor .kind .name in ['BINARY_OPERATOR' ,
3838 'CALL_EXPR' ,
3939 'RETURN_STMT' ,
4040 'DECL_STMT' ,
4141 'UNARY_OPERATOR' ,
4242 'UNEXPOSED_EXPR' ,
4343 'CXX_DELETE_EXPR' ,
44+ 'BREAK_STMT' ,
45+ 'CXX_TRY_STMT' ,
46+ 'COMPOUND_ASSIGNMENT_OPERATOR' ,
47+ 'CXX_UNARY_EXPR' ,
4448 ]:
4549 if len (children_nodes ) == 0 or type (children_nodes [- 1 ]) != CodeBlock :
46- children_nodes .append (CodeBlock (parent_node ))
47- children_nodes [- 1 ].add_line (cursor )
50+ children_nodes .append (CodeBlock (parent_node , bruteforce , verbose ))
51+ children_nodes [- 1 ].add_line (cursor , bruteforce , verbose )
4852 else :
49- # FIXME: pass brute-force
50- output_error (False , "Unknown object: " , cursor .kind .name , " located: " , cursor .location )
53+ output_error (bruteforce , "Unknown object: " , cursor .kind .name , " located: " , cursor .location )
5154
5255
5356class Node :
@@ -61,7 +64,7 @@ def __init__(self, parent_node):
6164
6265class CodeLine (Node ):
6366 # FIXME: move construction away from constructor
64- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
67+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
6568 super ().__init__ (parent_node )
6669 self .cursor = cursor
6770
@@ -71,12 +74,12 @@ def print(self, depth):
7174
7275class CodeBlock (Node ):
7376 # FIXME: move construction away from constructor
74- def __init__ (self , parent_node ):
77+ def __init__ (self , parent_node , bruteforce : bool , verbose : bool ):
7578 super ().__init__ (parent_node )
7679 self .body_nodes = []
7780
78- def add_line (self , cursor : clang .cindex .Cursor ):
79- self .body_nodes .append (CodeLine (self , cursor ))
81+ def add_line (self , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
82+ self .body_nodes .append (CodeLine (self , cursor , bruteforce , verbose ))
8083
8184 def print (self , depth ):
8285 print ('\t ' * depth , 'Block of code:' )
@@ -86,7 +89,7 @@ def print(self, depth):
8689
8790class Loop (Node ):
8891 # FIXME: move construction away from constructor
89- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
92+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
9093 super ().__init__ (parent_node )
9194 self .body_nodes = []
9295
@@ -97,11 +100,11 @@ def print(self, depth):
97100
98101class ForLoop (Loop ):
99102 # FIXME: move construction away from constructor
100- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
101- super ().__init__ (parent_node , cursor )
103+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
104+ super ().__init__ (parent_node , cursor , bruteforce , verbose )
102105
103106 cursor_children = list (cursor .get_children ())
104- parse_cursor (self .body_nodes , cursor_children [- 1 ], self )
107+ parse_cursor (self .body_nodes , cursor_children [- 1 ], self , bruteforce , verbose )
105108 # FIXME: make a proper loop arguments parse
106109
107110 def print (self , depth ):
@@ -111,11 +114,11 @@ def print(self, depth):
111114
112115class ForRangeLoop (Loop ):
113116 # FIXME: move construction away from constructor
114- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
115- super ().__init__ (parent_node , cursor )
117+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
118+ super ().__init__ (parent_node , cursor , bruteforce , verbose )
116119
117120 cursor_children = list (cursor .get_children ())
118- parse_cursor (self .body_nodes , cursor_children [- 1 ], self )
121+ parse_cursor (self .body_nodes , cursor_children [- 1 ], self , bruteforce , verbose )
119122 # FIXME: make a proper loop arguments parse
120123
121124 def print (self , depth ):
@@ -125,11 +128,11 @@ def print(self, depth):
125128
126129class WhileLoop (Loop ):
127130 # FIXME: move construction away from constructor
128- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
129- super ().__init__ (parent_node , cursor )
131+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
132+ super ().__init__ (parent_node , cursor , bruteforce , verbose )
130133
131134 cursor_children = list (cursor .get_children ())
132- parse_cursor (self .body_nodes , cursor_children [- 1 ], self )
135+ parse_cursor (self .body_nodes , cursor_children [- 1 ], self , bruteforce , verbose )
133136 # FIXME: make a proper loop arguments parse
134137
135138 def print (self , depth ):
@@ -139,7 +142,7 @@ def print(self, depth):
139142
140143class If (Node ):
141144 # FIXME: move construction away from constructor
142- def __init__ (self , parent_node , cursor : clang .cindex .Cursor ):
145+ def __init__ (self , parent_node , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
143146 super ().__init__ (parent_node )
144147
145148 self .body_nodes = []
@@ -150,9 +153,9 @@ def __init__(self, parent_node, cursor: clang.cindex.Cursor):
150153 # FIXME: parse condition
151154
152155 for i in cursor_children [1 ].get_children ():
153- parse_cursor (self .body_nodes , i , self )
156+ parse_cursor (self .body_nodes , i , self , bruteforce , verbose )
154157 if len (cursor_children ) == 3 :
155- parse_cursor (self .else_nodes , cursor_children [2 ], self )
158+ parse_cursor (self .else_nodes , cursor_children [2 ], self , bruteforce , verbose )
156159
157160 def print (self , depth ):
158161 print ('\t ' * depth , 'If:' )
@@ -171,13 +174,13 @@ def __init__(self, parent_node):
171174 self .body_nodes = []
172175 self .name = ""
173176
174- def parse_cpp (self , cursor : clang .cindex .Cursor ):
177+ def parse_cpp (self , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
175178 self .name = cursor .spelling
176179
177180 cursor_children = list (cursor .get_children ())
178181
179182 if len (cursor_children ) and cursor_children [- 1 ].kind .name == 'COMPOUND_STMT' :
180- parse_cursor (self .body_nodes , cursor_children [- 1 ], self )
183+ parse_cursor (self .body_nodes , cursor_children [- 1 ], self , bruteforce , verbose )
181184 # FIXME: parse function arguments
182185 # FIXME: parse function return
183186 # TODO: add print method
@@ -189,7 +192,7 @@ def __init__(self, parent_node):
189192 self .body_nodes = []
190193 self .name = ""
191194
192- def parse_cpp (self , cursor : clang .cindex .Cursor ):
195+ def parse_cpp (self , cursor : clang .cindex .Cursor , bruteforce : bool , verbose : bool ):
193196 self .name = cursor .spelling
194197
195198 # FIXME: parse class data (methods are parsed externally)
@@ -202,7 +205,7 @@ def __init__(self, parent_node):
202205 self .body_nodes = []
203206 self .name = ""
204207
205- def parse_cpp (self , cursor : clang .cindex .Cursor , code_tree : CodeTree ):
208+ def parse_cpp (self , cursor : clang .cindex .Cursor , code_tree : CodeTree , bruteforce : bool , verbose : bool ):
206209 self .name = cursor .spelling
207210
208211 # cursor_dump_rec(cursor, 0, 2)
@@ -217,7 +220,7 @@ def parse_cpp(self, cursor: clang.cindex.Cursor, code_tree: CodeTree):
217220 elif i .kind .name == 'CXX_METHOD' :
218221 code_tree .methods [i .get_usr ()] = Function (self )
219222 self .body_nodes .append (code_tree .methods [i .get_usr ()])
220- code_tree .methods [i .get_usr ()].parse_cpp (i )
223+ code_tree .methods [i .get_usr ()].parse_cpp (i , bruteforce , verbose )
221224 else :
222225 output_error (False , "Unknown structure field: " , i .kind .name )
223226
0 commit comments