summaryrefslogtreecommitdiffstatshomepage
path: root/py/scope.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/scope.h')
-rw-r--r--py/scope.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/py/scope.h b/py/scope.h
index e210a5a9cf..012d906475 100644
--- a/py/scope.h
+++ b/py/scope.h
@@ -52,14 +52,26 @@ typedef struct _id_info_t {
qstr qst;
} id_info_t;
+#define SCOPE_IS_FUNC_LIKE(s) ((s) >= SCOPE_LAMBDA)
+
// scope is a "block" in Python parlance
-typedef enum { SCOPE_MODULE, SCOPE_FUNCTION, SCOPE_LAMBDA, SCOPE_LIST_COMP, SCOPE_DICT_COMP, SCOPE_SET_COMP, SCOPE_GEN_EXPR, SCOPE_CLASS } scope_kind_t;
+typedef enum {
+ SCOPE_MODULE,
+ SCOPE_CLASS,
+ SCOPE_LAMBDA,
+ SCOPE_LIST_COMP,
+ SCOPE_DICT_COMP,
+ SCOPE_SET_COMP,
+ SCOPE_GEN_EXPR,
+ SCOPE_FUNCTION,
+} scope_kind_t;
+
typedef struct _scope_t {
scope_kind_t kind;
struct _scope_t *parent;
const byte *pn; // points to the node after the scope index node
- qstr source_file;
- qstr simple_name;
+ uint16_t source_file; // a qstr
+ uint16_t simple_name; // a qstr
mp_raw_code_t *raw_code;
uint8_t scope_flags; // see runtime0.h
uint8_t emit_options; // see compile.h
@@ -79,7 +91,6 @@ void scope_free(scope_t *scope);
id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added);
id_info_t *scope_find(scope_t *scope, qstr qstr);
id_info_t *scope_find_global(scope_t *scope, qstr qstr);
-id_info_t *scope_find_local_in_parent(scope_t *scope, qstr qstr);
-void scope_close_over_in_parents(scope_t *scope, qstr qstr);
+void scope_find_local_and_close_over(scope_t *scope, id_info_t *id, qstr qst);
#endif // __MICROPY_INCLUDED_PY_SCOPE_H__