mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
add noexcept
This commit is contained in:
parent
bec168ab53
commit
1c053af8d1
@ -50,7 +50,7 @@ struct Expr {
|
||||
[[nodiscard]] virtual bool emit_store_inplace(CodeEmitContext* ctx) { return emit_store(ctx); }
|
||||
};
|
||||
|
||||
inline void delete_expr(Expr* p){
|
||||
inline void delete_expr(Expr* p) noexcept{
|
||||
if(!p) return;
|
||||
p->Expr::~Expr();
|
||||
PoolExpr_dealloc(p);
|
||||
|
@ -49,7 +49,7 @@ constexpr TokenIndex TK(const char token[]) {
|
||||
return 255;
|
||||
}
|
||||
|
||||
constexpr inline bool is_raw_string_used(TokenIndex t) { return t == TK("@id") || t == TK("@long"); }
|
||||
constexpr inline bool is_raw_string_used(TokenIndex t) noexcept{ return t == TK("@id") || t == TK("@long"); }
|
||||
|
||||
#define TK_STR(t) kTokens[t]
|
||||
|
||||
@ -61,9 +61,9 @@ struct Token {
|
||||
int brackets_level;
|
||||
TokenValue value;
|
||||
|
||||
Str str() const { return Str(start, length); }
|
||||
Str str() const noexcept{ return Str(start, length); }
|
||||
|
||||
std::string_view sv() const { return std::string_view(start, length); }
|
||||
std::string_view sv() const noexcept{ return std::string_view(start, length); }
|
||||
};
|
||||
|
||||
// https://docs.python.org/3/reference/expressions.html#operator-precedence
|
||||
@ -153,11 +153,11 @@ struct TokenDeserializer {
|
||||
const char* curr;
|
||||
const char* source;
|
||||
|
||||
TokenDeserializer(const char* source) : curr(source), source(source) {}
|
||||
TokenDeserializer(const char* source) noexcept: curr(source), source(source){}
|
||||
|
||||
char read_char() { return *curr++; }
|
||||
char read_char() noexcept{ return *curr++; }
|
||||
|
||||
bool match_char(char c) {
|
||||
bool match_char(char c) noexcept{
|
||||
if(*curr == c) {
|
||||
curr++;
|
||||
return true;
|
||||
@ -165,11 +165,11 @@ struct TokenDeserializer {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string_view read_string(char c);
|
||||
Str read_string_from_hex(char c);
|
||||
int read_count();
|
||||
i64 read_uint(char c);
|
||||
f64 read_float(char c);
|
||||
std::string_view read_string(char c) noexcept;
|
||||
Str read_string_from_hex(char c) noexcept;
|
||||
int read_count() noexcept;
|
||||
i64 read_uint(char c) noexcept;
|
||||
f64 read_float(char c) noexcept;
|
||||
};
|
||||
|
||||
} // namespace pkpy
|
||||
|
@ -666,7 +666,7 @@ Error* Lexer::precompile(Str* out) noexcept{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string_view TokenDeserializer::read_string(char c) {
|
||||
std::string_view TokenDeserializer::read_string(char c) noexcept{
|
||||
const char* start = curr;
|
||||
while(*curr != c)
|
||||
curr++;
|
||||
@ -675,7 +675,7 @@ std::string_view TokenDeserializer::read_string(char c) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
Str TokenDeserializer::read_string_from_hex(char c) {
|
||||
Str TokenDeserializer::read_string_from_hex(char c) noexcept{
|
||||
std::string_view s = read_string(c);
|
||||
char* buffer = (char*)std::malloc(s.size() / 2 + 1);
|
||||
for(int i = 0; i < s.size(); i += 2) {
|
||||
@ -699,13 +699,13 @@ Str TokenDeserializer::read_string_from_hex(char c) {
|
||||
return pair<char*, int>(buffer, s.size() / 2);
|
||||
}
|
||||
|
||||
int TokenDeserializer::read_count() {
|
||||
int TokenDeserializer::read_count() noexcept{
|
||||
assert(*curr == '=');
|
||||
curr++;
|
||||
return read_uint('\n');
|
||||
}
|
||||
|
||||
i64 TokenDeserializer::read_uint(char c) {
|
||||
i64 TokenDeserializer::read_uint(char c) noexcept{
|
||||
i64 out = 0;
|
||||
while(*curr != c) {
|
||||
out = out * 10 + (*curr - '0');
|
||||
@ -715,7 +715,7 @@ i64 TokenDeserializer::read_uint(char c) {
|
||||
return out;
|
||||
}
|
||||
|
||||
f64 TokenDeserializer::read_float(char c) {
|
||||
f64 TokenDeserializer::read_float(char c) noexcept{
|
||||
std::string_view sv = read_string(c);
|
||||
return std::stod(std::string(sv));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user