From c889a33d51fda3bf56083f1206b7007acd9bb373 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 17 Jun 2023 12:59:16 +0800 Subject: [PATCH] ... --- src/codeobject.h | 1 - src/compiler.h | 4 ++-- src/expr.h | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codeobject.h b/src/codeobject.h index 55df6123..6919fc02 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -60,7 +60,6 @@ struct CodeObject { List consts; std::vector varnames; // local variables NameDictInt varnames_inv; - std::set global_names; std::vector blocks = { CodeBlock(NO_BLOCK, -1, 0, 0) }; NameDictInt labels; std::vector func_decls; diff --git a/src/compiler.h b/src/compiler.h index 3861d898..cf158895 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -422,7 +422,7 @@ class Compiler { void exprName(){ Str name = prev().str(); NameScope scope = name_scope(); - if(ctx()->co->global_names.count(name)){ + if(ctx()->global_names.count(name)){ scope = NAME_GLOBAL; } ctx()->s_expr.push(make_expr(name, scope)); @@ -803,7 +803,7 @@ __SUBSCR_END: case TK("global"): do { consume(TK("@id")); - ctx()->co->global_names.insert(prev().str()); + ctx()->global_names.insert(prev().str()); } while (match(TK(","))); consume_end_stmt(); break; diff --git a/src/expr.h b/src/expr.h index 3ab5f3b0..fd3d173d 100644 --- a/src/expr.h +++ b/src/expr.h @@ -38,6 +38,7 @@ struct CodeEmitContext{ CodeObject_ co; stack s_expr; int level; + std::set global_names; CodeEmitContext(VM* vm, CodeObject_ co, int level): vm(vm), co(co), level(level) {} int curr_block_i = 0;