def execute_unexecuted_code(self, code_key, extra_scope=None, own_namespace=False): """ Executes a code in a dedicated env and put consequence exceptions in self. own_namespace: whether the execution uses the current local variables or no variables """ container = self._unexecuted_codes[code_key] analyzer = Analyzer() if not own_namespace: analyzer._namespaces = container.namespaces analyzer.variable_uses = self.variable_uses analyzer.delete_scope_level = container.delete_scope_level file = File(container.code._tokens) file.position = container.position this = Anything() this.position = container.position analyzer.execute_code(file, extra_scope=extra_scope, namespace_name=container.namespace_name, delete_mode=True) self.exceptions.extend(analyzer.exceptions)
def analyze(statement, analyzer=None): assert (isinstance(statement, Statement)) if analyzer is None: analyzer = Analyzer() file = File(statement.tokens) file.position = (1, 1) arg = Anything() arg.position = (1, 1) analyzer.execute_code(file, extra_scope={'_this': arg}) return analyzer
def analyze(statement, analyzer=None): assert (isinstance(statement, Statement)) if analyzer is None: analyzer = Analyzer() file = File(statement.tokens) file.position = (1, 1) arg = Anything() arg.position = (1, 1) analyzer.execute_code(file, params=arg) return analyzer
def execute_unexecuted_code(self, code_key): """ Executes a code in a dedicated env and put consequence exceptions in self. """ container = self._unexecuted_codes[code_key] analyzer = Analyzer() analyzer._namespaces = container.namespaces analyzer.variable_uses = self.variable_uses analyzer.delete_scope_level = container.delete_scope_level file = File(container.code._tokens) file.position = container.position this = Anything() this.position = container.position analyzer.execute_code(file, extra_scope={'_this': this}, namespace_name=container.namespace_name, delete_mode=True) self.exceptions.extend(analyzer.exceptions)