mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 04:20:17 +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); }
|
[[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;
|
if(!p) return;
|
||||||
p->Expr::~Expr();
|
p->Expr::~Expr();
|
||||||
PoolExpr_dealloc(p);
|
PoolExpr_dealloc(p);
|
||||||
|
@ -49,7 +49,7 @@ constexpr TokenIndex TK(const char token[]) {
|
|||||||
return 255;
|
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]
|
#define TK_STR(t) kTokens[t]
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ struct Token {
|
|||||||
int brackets_level;
|
int brackets_level;
|
||||||
TokenValue value;
|
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
|
// https://docs.python.org/3/reference/expressions.html#operator-precedence
|
||||||
@ -153,11 +153,11 @@ struct TokenDeserializer {
|
|||||||
const char* curr;
|
const char* curr;
|
||||||
const char* source;
|
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) {
|
if(*curr == c) {
|
||||||
curr++;
|
curr++;
|
||||||
return true;
|
return true;
|
||||||
@ -165,11 +165,11 @@ struct TokenDeserializer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view read_string(char c);
|
std::string_view read_string(char c) noexcept;
|
||||||
Str read_string_from_hex(char c);
|
Str read_string_from_hex(char c) noexcept;
|
||||||
int read_count();
|
int read_count() noexcept;
|
||||||
i64 read_uint(char c);
|
i64 read_uint(char c) noexcept;
|
||||||
f64 read_float(char c);
|
f64 read_float(char c) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
||||||
|
@ -666,7 +666,7 @@ Error* Lexer::precompile(Str* out) noexcept{
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view TokenDeserializer::read_string(char c) {
|
std::string_view TokenDeserializer::read_string(char c) noexcept{
|
||||||
const char* start = curr;
|
const char* start = curr;
|
||||||
while(*curr != c)
|
while(*curr != c)
|
||||||
curr++;
|
curr++;
|
||||||
@ -675,7 +675,7 @@ std::string_view TokenDeserializer::read_string(char c) {
|
|||||||
return retval;
|
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);
|
std::string_view s = read_string(c);
|
||||||
char* buffer = (char*)std::malloc(s.size() / 2 + 1);
|
char* buffer = (char*)std::malloc(s.size() / 2 + 1);
|
||||||
for(int i = 0; i < s.size(); i += 2) {
|
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);
|
return pair<char*, int>(buffer, s.size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TokenDeserializer::read_count() {
|
int TokenDeserializer::read_count() noexcept{
|
||||||
assert(*curr == '=');
|
assert(*curr == '=');
|
||||||
curr++;
|
curr++;
|
||||||
return read_uint('\n');
|
return read_uint('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
i64 TokenDeserializer::read_uint(char c) {
|
i64 TokenDeserializer::read_uint(char c) noexcept{
|
||||||
i64 out = 0;
|
i64 out = 0;
|
||||||
while(*curr != c) {
|
while(*curr != c) {
|
||||||
out = out * 10 + (*curr - '0');
|
out = out * 10 + (*curr - '0');
|
||||||
@ -715,7 +715,7 @@ i64 TokenDeserializer::read_uint(char c) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
f64 TokenDeserializer::read_float(char c) {
|
f64 TokenDeserializer::read_float(char c) noexcept{
|
||||||
std::string_view sv = read_string(c);
|
std::string_view sv = read_string(c);
|
||||||
return std::stod(std::string(sv));
|
return std::stod(std::string(sv));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user