mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 13:00:17 +00:00
re
This commit is contained in:
parent
0b1ba59024
commit
5057e333cd
@ -10,7 +10,7 @@ const _Int _Int_MAX_NEG = -9223372036854775807LL;
|
|||||||
const _Float _FLOAT_INF_POS = INFINITY;
|
const _Float _FLOAT_INF_POS = INFINITY;
|
||||||
const _Float _FLOAT_INF_NEG = -INFINITY;
|
const _Float _FLOAT_INF_NEG = -INFINITY;
|
||||||
|
|
||||||
#define PK_VERSION "0.2.5"
|
#define PK_VERSION "0.2.6"
|
||||||
|
|
||||||
class CodeObject;
|
class CodeObject;
|
||||||
class BasePointer;
|
class BasePointer;
|
||||||
|
@ -309,12 +309,12 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
|||||||
|
|
||||||
_vm->bindMethod("str", "__repr__", [](VM* vm, PyVarList args) {
|
_vm->bindMethod("str", "__repr__", [](VM* vm, PyVarList args) {
|
||||||
const _Str& _self = vm->PyStr_AS_C(args[0]);
|
const _Str& _self = vm->PyStr_AS_C(args[0]);
|
||||||
return vm->PyStr("'" + _self.__escape(true).str() + "'");
|
return vm->PyStr(_self.__escape(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
_vm->bindMethod("str", "__json__", [](VM* vm, PyVarList args) {
|
_vm->bindMethod("str", "__json__", [](VM* vm, PyVarList args) {
|
||||||
const _Str& _self = vm->PyStr_AS_C(args[0]);
|
const _Str& _self = vm->PyStr_AS_C(args[0]);
|
||||||
return vm->PyStr("\"" + _self.__escape(false) + "\"");
|
return vm->PyStr(_self.__escape(false));
|
||||||
});
|
});
|
||||||
|
|
||||||
_vm->bindMethod("str", "__eq__", [](VM* vm, PyVarList args) {
|
_vm->bindMethod("str", "__eq__", [](VM* vm, PyVarList args) {
|
||||||
|
@ -207,6 +207,7 @@ public:
|
|||||||
|
|
||||||
_Str __escape(bool single_quote) const {
|
_Str __escape(bool single_quote) const {
|
||||||
_StrStream ss;
|
_StrStream ss;
|
||||||
|
ss << (single_quote ? '\'' : '"');
|
||||||
for (auto c = _s->cbegin(); c != _s->cend(); c++) {
|
for (auto c = _s->cbegin(); c != _s->cend(); c++) {
|
||||||
switch (*c) {
|
switch (*c) {
|
||||||
case '"':
|
case '"':
|
||||||
@ -230,6 +231,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ss << (single_quote ? '\'' : '"');
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user