From e623e9ac568bda655703a6997d79bc46d0351f76 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Thu, 1 Dec 2022 11:42:31 -0800 Subject: [PATCH] For String Refs, inherit the type of the reffed string object. --- ASTree.cpp | 1 - bytecode.cpp | 1 - pyc_object.h | 2 ++ pyc_string.cpp | 6 ++---- pycdas.cpp | 1 - 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ASTree.cpp b/ASTree.cpp index 0fb8497..f679b49 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -3356,7 +3356,6 @@ bool print_docstring(PycRef obj, int indent, PycModule* mod) case PycObject::TYPE_UNICODE: prefix = mod->strIsUnicode() ? 0 : 'u'; break; - case PycObject::TYPE_STRINGREF: case PycObject::TYPE_INTERNED: case PycObject::TYPE_ASCII: case PycObject::TYPE_ASCII_INTERNED: diff --git a/bytecode.cpp b/bytecode.cpp index eba8e0b..f30a258 100644 --- a/bytecode.cpp +++ b/bytecode.cpp @@ -173,7 +173,6 @@ void print_const(PycRef obj, PycModule* mod, const char* parent_f_str OutputString(obj.cast(), mod->strIsUnicode() ? 0 : 'u', false, pyc_output, parent_f_string_quote); break; - case PycObject::TYPE_STRINGREF: case PycObject::TYPE_INTERNED: case PycObject::TYPE_ASCII: case PycObject::TYPE_ASCII_INTERNED: diff --git a/pyc_object.h b/pyc_object.h index d05f388..fd7cc1a 100644 --- a/pyc_object.h +++ b/pyc_object.h @@ -143,6 +143,8 @@ public: private: int m_refs; + +protected: int m_type; public: diff --git a/pyc_string.cpp b/pyc_string.cpp index 62d8075..3c8befd 100644 --- a/pyc_string.cpp +++ b/pyc_string.cpp @@ -19,10 +19,8 @@ void PycString::load(PycData* stream, PycModule* mod) { if (type() == TYPE_STRINGREF) { PycRef str = mod->getIntern(stream->get32()); - m_value.resize(str->length()); - - if (str->length()) - std::char_traits::copy(&m_value.front(), str->value(), str->length()); + m_type = str->m_type; + m_value = str->m_value; } else { int length; if (type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) diff --git a/pycdas.cpp b/pycdas.cpp index 40333b7..bf54011 100644 --- a/pycdas.cpp +++ b/pycdas.cpp @@ -140,7 +140,6 @@ void output_object(PycRef obj, PycModule* mod, int indent) OutputString(obj.cast(), mod->strIsUnicode() ? 0 : 'u'); fputs("\n", pyc_output); break; - case PycObject::TYPE_STRINGREF: case PycObject::TYPE_INTERNED: case PycObject::TYPE_ASCII: case PycObject::TYPE_ASCII_INTERNED: