mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 13:00:17 +00:00
some rename
This commit is contained in:
parent
9c7d1c5fe1
commit
8f6b539b37
@ -27,7 +27,7 @@ c11_string* c11_string__new2(const char* data, int size);
|
||||
c11_string* c11_string__copy(c11_string* self);
|
||||
void c11_string__delete(c11_string* self);
|
||||
int c11_string__len(c11_string* self);
|
||||
c11_sv c11_string__view(c11_string* self);
|
||||
c11_sv c11_string__sv(c11_string* self);
|
||||
c11_string* c11_string__replace(c11_string* self, char old, char new_);
|
||||
|
||||
int c11_string__u8_length(const c11_string* self);
|
||||
|
@ -36,7 +36,7 @@ int c11_string__len(c11_string* self) {
|
||||
return *p;
|
||||
}
|
||||
|
||||
c11_sv c11_string__view(c11_string* self) {
|
||||
c11_sv c11_string__sv(c11_string* self) {
|
||||
int* p = (int*)self - 1;
|
||||
return (c11_sv){self, *p};
|
||||
}
|
||||
@ -59,7 +59,7 @@ int c11_string__u8_length(c11_string* self) {
|
||||
c11_sv c11_string__u8_getitem(c11_string* self, int i) {
|
||||
i = c11__unicode_index_to_byte(self, i);
|
||||
int size = c11__u8_header(self[i], false);
|
||||
return c11_sv__slice2(c11_string__view(self), i, i + size);
|
||||
return c11_sv__slice2(c11_string__sv(self), i, i + size);
|
||||
}
|
||||
|
||||
c11_string* c11_string__u8_slice(c11_string* self, int start, int stop, int step) {
|
||||
|
@ -289,7 +289,7 @@ void LiteralExpr__emit_(Expr* self_, Ctx* ctx) {
|
||||
break;
|
||||
}
|
||||
case TokenValue_STR: {
|
||||
c11_sv sv = c11_string__view(self->value->_str);
|
||||
c11_sv sv = c11_string__sv(self->value->_str);
|
||||
int index = Ctx__add_const_string(ctx, sv);
|
||||
Ctx__emit_(ctx, OP_LOAD_CONST, index, self->line);
|
||||
break;
|
||||
@ -1354,7 +1354,7 @@ int Ctx__add_const_string(Ctx* self, c11_sv key) {
|
||||
c11_vector__push(py_TValue, &self->co->consts, tmp);
|
||||
int index = self->co->consts.count - 1;
|
||||
c11_smallmap_s2n__set(&self->co_consts_string_dedup_map,
|
||||
c11_string__view(PyObject__value(tmp._obj)),
|
||||
c11_string__sv(PyObject__value(tmp._obj)),
|
||||
index);
|
||||
return index;
|
||||
}
|
||||
@ -1665,13 +1665,13 @@ static Error* exprLong(Compiler* self) {
|
||||
}
|
||||
|
||||
static Error* exprBytes(Compiler* self) {
|
||||
c11_sv sv = c11_string__view(prev()->value._str);
|
||||
c11_sv sv = c11_string__sv(prev()->value._str);
|
||||
Ctx__s_push(ctx(), (Expr*)RawStringExpr__new(prev()->line, sv, OP_BUILD_BYTES));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Error* exprFString(Compiler* self) {
|
||||
c11_sv sv = c11_string__view(prev()->value._str);
|
||||
c11_sv sv = c11_string__sv(prev()->value._str);
|
||||
Ctx__s_push(ctx(), (Expr*)FStringExpr__new(prev()->line, sv));
|
||||
return NULL;
|
||||
}
|
||||
@ -2064,7 +2064,7 @@ Error* pk_compile(pk_SourceData_ src, CodeObject* out) {
|
||||
|
||||
Compiler compiler;
|
||||
Compiler__ctor(&compiler, src, tokens);
|
||||
CodeObject__ctor(out, src, c11_string__view(src->filename));
|
||||
CodeObject__ctor(out, src, c11_string__sv(src->filename));
|
||||
err = Compiler__compile(&compiler, out);
|
||||
if(err) {
|
||||
// if error occurs, dispose the code object
|
||||
|
@ -821,7 +821,7 @@ Error* pk_Lexer__process_and_dump(pk_SourceData_ src, c11_string** out) {
|
||||
break;
|
||||
case TokenValue_STR: {
|
||||
pk_SStream__write_char(&ss, 'S');
|
||||
c11_sv sv = c11_string__view(token->value._str);
|
||||
c11_sv sv = c11_string__sv(token->value._str);
|
||||
for(int i=0; i<sv.size; i++){
|
||||
pk_SStream__write_hex(&ss, sv.data[i], false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user