py/compile: Convert scope test to SCOPE_IS_COMP_LIKE macro.
This macro can be used elsewhere.
This commit is contained in:
parent
b4d0d7bf03
commit
0fd91e39b1
@ -3083,7 +3083,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
|
|||||||
EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
|
EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
|
||||||
}
|
}
|
||||||
EMIT(return_value);
|
EMIT(return_value);
|
||||||
} else if (scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) {
|
} else if (SCOPE_IS_COMP_LIKE(scope->kind)) {
|
||||||
// a bit of a hack at the moment
|
// a bit of a hack at the moment
|
||||||
|
|
||||||
assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
|
assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
|
||||||
|
@ -55,6 +55,7 @@ typedef struct _id_info_t {
|
|||||||
} id_info_t;
|
} id_info_t;
|
||||||
|
|
||||||
#define SCOPE_IS_FUNC_LIKE(s) ((s) >= SCOPE_LAMBDA)
|
#define SCOPE_IS_FUNC_LIKE(s) ((s) >= SCOPE_LAMBDA)
|
||||||
|
#define SCOPE_IS_COMP_LIKE(s) (SCOPE_LIST_COMP <= (s) && (s) <= SCOPE_GEN_EXPR)
|
||||||
|
|
||||||
// scope is a "block" in Python parlance
|
// scope is a "block" in Python parlance
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user