blueloveTH 1 year ago
parent
commit
f359d07a02

+ 1 - 1
include/pocketpy/compiler/expr.hpp

@@ -112,7 +112,7 @@ struct CodeEmitContext {
     CodeObject_ co;  // 1 CodeEmitContext <=> 1 CodeObject_
     vector<Expr_> s_expr;
     int level;
-    vector<Str> global_names;
+    vector<StrName> global_names;
 
     CodeEmitContext(VM* vm, CodeObject_ co, int level) : vm(vm), co(co), level(level) {}
 

+ 1 - 1
include/pocketpy/interpreter/vm.hpp

@@ -81,7 +81,7 @@ struct PyTypeInfo {
     PyTypeInfo(PyObject* obj, Type base, PyObject* mod, StrName name, bool subclass_enabled, Vt vt = {}) :
         obj(obj), base(base), mod(mod), name(name), subclass_enabled(subclass_enabled), vt(vt) {}
 
-    vector<StrName> annotated_fields = {};
+    vector<StrName> annotated_fields;
 
     // unary operators
     Str (*m__repr__)(VM* vm, PyVar) = nullptr;

+ 2 - 2
src/compiler/compiler.cpp

@@ -425,7 +425,7 @@ void Compiler::exprCall() {
 }
 
 void Compiler::exprName() {
-    Str name = prev().str();
+    StrName name(prev().sv());
     NameScope scope = name_scope();
     if(ctx()->global_names.contains(name)) { scope = NAME_GLOBAL; }
     ctx()->s_expr.push_back(make_expr<NameExpr>(name, scope));
@@ -882,7 +882,7 @@ void Compiler::compile_stmt() {
         case TK("global"):
             do {
                 consume(TK("@id"));
-                ctx()->global_names.push_back(prev().sv());
+                ctx()->global_names.push_back(StrName(prev().sv()));
             } while(match(TK(",")));
             consume_end_stmt();
             break;