From 352688e9ae9b090742ebd30b5bc6d34fc268f8ee Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 6 Apr 2023 14:58:38 +0800 Subject: [PATCH] up --- src/error.h | 5 +++-- src/lexer.h | 2 +- src/vector.h | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/error.h b/src/error.h index 561ce40d..6a82967e 100644 --- a/src/error.h +++ b/src/error.h @@ -75,9 +75,10 @@ struct SourceData { }; class Exception { + using StackTrace = stack; StrName type; Str msg; - stack stacktrace; + StackTrace stacktrace; public: Exception(StrName type, Str msg): type(type), msg(msg) {} bool match_type(StrName type) const { return this->type == type;} @@ -89,7 +90,7 @@ public: } Str summary() const { - stack st(stacktrace); + StackTrace st(stacktrace); StrStream ss; if(is_re) ss << "Traceback (most recent call last):\n"; while(!st.empty()) { ss << st.top() << '\n'; st.pop(); } diff --git a/src/lexer.h b/src/lexer.h index 74c8f96b..3b5b762c 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -100,7 +100,7 @@ struct Lexer { const char* curr_char; int current_line = 1; std::vector nexts; - stack indents; + small_stack indents; int brackets_level = 0; bool used = false; diff --git a/src/vector.h b/src/vector.h index e4f05474..e952e0c3 100644 --- a/src/vector.h +++ b/src/vector.h @@ -52,6 +52,9 @@ struct small_vector{ return *this; } + // remove copy assignment + small_vector& operator=(const small_vector& other) = delete; + template void push_back(__ValueT&& t) { if (_size == _capacity) { @@ -107,6 +110,6 @@ public: const Container& data() const { return vec; } }; -template +template using small_stack = stack>; } // namespace pkpy \ No newline at end of file