Check if s defines an Enum; if yes, store the definition in symbol table. Return True if this looks like an Enum definition (but maybe with errors), otherwise return False.
(self, s: AssignmentStmt, is_func_scope: bool)
| 61 | self.api = api |
| 62 | |
| 63 | def process_enum_call(self, s: AssignmentStmt, is_func_scope: bool) -> bool: |
| 64 | """Check if s defines an Enum; if yes, store the definition in symbol table. |
| 65 | |
| 66 | Return True if this looks like an Enum definition (but maybe with errors), |
| 67 | otherwise return False. |
| 68 | """ |
| 69 | if len(s.lvalues) != 1 or not isinstance(s.lvalues[0], (NameExpr, MemberExpr)): |
| 70 | return False |
| 71 | lvalue = s.lvalues[0] |
| 72 | name = lvalue.name |
| 73 | enum_call = self.check_enum_call(s.rvalue, name, is_func_scope) |
| 74 | if enum_call is None: |
| 75 | return False |
| 76 | if isinstance(lvalue, MemberExpr): |
| 77 | self.fail("Enum type as attribute is not supported", lvalue) |
| 78 | return False |
| 79 | # Yes, it's a valid Enum definition. Add it to the symbol table. |
| 80 | self.api.add_symbol(name, enum_call, s) |
| 81 | return True |
| 82 | |
| 83 | def check_enum_call( |
| 84 | self, node: Expression, var_name: str, is_func_scope: bool |
no test coverage detected