Compare commits

..

1 Commits

6 changed files with 52 additions and 68 deletions

View File

@ -56,11 +56,11 @@ jobs:
- name: Setup Clang - name: Setup Clang
uses: egor-tensin/setup-clang@v1 uses: egor-tensin/setup-clang@v1
with: with:
version: 19 version: 17
platform: x64 platform: x64
- name: Run Sanitizers - name: Run Sanitizers
run: | run: |
sudo apt-get install -y libclang-rt-19-dev sudo apt-get install -y libclang-rt-17-dev
bash build_g.sh bash build_g.sh
bash run_tests.sh bash run_tests.sh
rm -rf ./main rm -rf ./main

View File

@ -4,7 +4,7 @@
typedef struct PyObject PyObject; typedef struct PyObject PyObject;
typedef struct VM VM; typedef struct VM VM;
extern PK_THREAD_LOCAL VM* pk_current_vm; extern _Thread_local VM* pk_current_vm;
typedef struct py_TValue { typedef struct py_TValue {
py_Type type; py_Type type;

View File

@ -17,7 +17,7 @@ rm -rf .coverage
mkdir .coverage mkdir .coverage
UNITS=$(find ./ -name "*.gcno") UNITS=$(find ./ -name "*.gcno")
llvm-cov-19 gcov ${UNITS} -r -s include/ -r -s src/ >> .coverage/coverage.txt llvm-cov-17 gcov ${UNITS} -r -s include/ -r -s src/ >> .coverage/coverage.txt
mv *.gcov .coverage mv *.gcov .coverage
rm *.gcda rm *.gcda

View File

@ -189,8 +189,8 @@ static Error* LexerError(Lexer* self, const char* fmt, ...) {
err->src = self->src; err->src = self->src;
PK_INCREF(self->src); PK_INCREF(self->src);
err->lineno = self->current_line; err->lineno = self->current_line;
const char* p_end = self->src->source->data + self->src->source->size; const char* end = self->src->source->data + self->src->source->size;
if(self->curr_char <= p_end && *self->curr_char == '\n') { err->lineno--; } if(self->curr_char <= end && *self->curr_char == '\n') { err->lineno--; }
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vsnprintf(err->msg, sizeof(err->msg), fmt, args); vsnprintf(err->msg, sizeof(err->msg), fmt, args);
@ -282,16 +282,9 @@ static Error* _eat_string(Lexer* self, c11_sbuf* buff, char quote, enum StringTy
case 'b': c11_sbuf__write_char(buff, '\b'); break; case 'b': c11_sbuf__write_char(buff, '\b'); break;
case 'f': c11_sbuf__write_char(buff, '\f'); break; case 'f': c11_sbuf__write_char(buff, '\f'); break;
case 'v': c11_sbuf__write_char(buff, '\v'); break; case 'v': c11_sbuf__write_char(buff, '\v'); break;
// Special case for the often used \0 while we don't have full support for octal // Special case for the often used \0 while we don't have full support for octal literals.
// literals.
case '0': c11_sbuf__write_char(buff, '\0'); break; case '0': c11_sbuf__write_char(buff, '\0'); break;
case 'x': { case 'x': {
// check there are at least 2 chars can read
const char* p_end = self->src->source->data + self->src->source->size;
if(p_end - self->curr_char < 2) {
return LexerError(self, "invalid hex escape");
}
char hex[3] = {eatchar(self), eatchar(self), '\0'}; char hex[3] = {eatchar(self), eatchar(self), '\0'};
int code; int code;
if(sscanf(hex, "%x", &code) != 1 || code > 0xFF) { if(sscanf(hex, "%x", &code) != 1 || code > 0xFF) {

View File

@ -714,16 +714,8 @@ void ManagedHeap__mark(ManagedHeap* self) {
} }
} }
if(obj->type > tp_object) {
// NOTE: `defaultdict` -> `dict` -> `object`
// NOTE: native types must extend from `object`.
py_TypeInfo* ti = pk_typeinfo(obj->type);
while(ti->base != tp_object) {
ti = ti->base_ti;
}
void* ud = PyObject__userdata(obj); void* ud = PyObject__userdata(obj);
switch(ti->index) { switch(obj->type) {
case tp_list: { case tp_list: {
List* self = ud; List* self = ud;
for(int i = 0; i < self->length; i++) { for(int i = 0; i < self->length; i++) {
@ -772,5 +764,4 @@ void ManagedHeap__mark(ManagedHeap* self) {
} }
} }
} }
}
} }

View File

@ -5,7 +5,7 @@
#include "pocketpy/common/name.h" #include "pocketpy/common/name.h"
#include "pocketpy/interpreter/vm.h" #include "pocketpy/interpreter/vm.h"
PK_THREAD_LOCAL VM* pk_current_vm; _Thread_local VM* pk_current_vm;
static bool pk_initialized; static bool pk_initialized;
static bool pk_finalized; static bool pk_finalized;