Visit GN condition: if (cond) {then_stmts} else {else_stmts}
(self, cond_expr, then_stmts, else_stmts=None)
| 150 | self.current_target, [str(token) for token in right.children]) |
| 151 | |
| 152 | def _Condition(self, cond_expr, then_stmts, else_stmts=None): |
| 153 | 'Visit GN condition: if (cond) {then_stmts} else {else_stmts}' |
| 154 | cond_expr = self._Expr(cond_expr) |
| 155 | then_stmts = self._StatementList(then_stmts.children) |
| 156 | if not then_stmts: |
| 157 | # Ignore conditions with empty then stmts. |
| 158 | return |
| 159 | if else_stmts is None: |
| 160 | return self.builder.BuildCondition(cond_expr, then_stmts) |
| 161 | elif else_stmts.data == 'condition': |
| 162 | else_cond = self._Condition(*else_stmts.children) |
| 163 | return self.builder.BuildConditionWithElseCond( |
| 164 | cond_expr, then_stmts, else_cond) |
| 165 | else: |
| 166 | assert 'statement_list' == else_stmts.data |
| 167 | else_stmts = self._StatementList(else_stmts.children) |
| 168 | return self.builder.BuildConditionWithElseStmts( |
| 169 | cond_expr, then_stmts, else_stmts) |
| 170 | |
| 171 | def _Expr(self, expr): |
| 172 | 'Post-order traverse expression trees' |
nothing calls this directly
no test coverage detected