(self, stmt, local_vars, allow_recursion=100)
| 868 | self._objects = objects |
| 869 | |
| 870 | def interpret_statement(self, stmt, local_vars, allow_recursion=100): |
| 871 | if allow_recursion < 0: |
| 872 | raise JSInterpreterError('Recursion limit reached') |
| 873 | |
| 874 | should_abort = False |
| 875 | stmt = stmt.lstrip() |
| 876 | stmt_m = re.match(r'var\s', stmt) |
| 877 | if stmt_m: |
| 878 | expr = stmt[len(stmt_m.group(0)):] |
| 879 | |
| 880 | else: |
| 881 | return_m = re.match(r'return(?:\s+|$)', stmt) |
| 882 | if return_m: |
| 883 | expr = stmt[len(return_m.group(0)):] |
| 884 | should_abort = True |
| 885 | else: |
| 886 | # Try interpreting it as an expression |
| 887 | expr = stmt |
| 888 | |
| 889 | v = self.interpret_expression(expr, local_vars, allow_recursion) |
| 890 | return v, should_abort |
| 891 | |
| 892 | def interpret_expression(self, expr, local_vars, allow_recursion): |
| 893 | expr = expr.strip() |
no test coverage detected