Skip to content

Commit 8e7376c

Browse files
committed
Basic python interpreter works. STDIO still unstable. WIP.
1 parent c5b842f commit 8e7376c

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

frosted/main.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ STATIC int usage(char **argv) {
314314

315315
return 1;
316316
}
317-
#if 0
318317
// Process options which set interpreter init options
319318
STATIC void pre_process_options(int argc, char **argv) {
320319
for (int a = 1; a < argc; a++) {
@@ -364,7 +363,6 @@ STATIC void pre_process_options(int argc, char **argv) {
364363
}
365364
}
366365
}
367-
#endif
368366

369367
STATIC void set_sys_argv(char *argv[], int argc, int start_arg) {
370368
for (int i = start_arg; i < argc; i++) {
@@ -389,14 +387,14 @@ int main(int argc, char **argv) {
389387
// For this, actual main (renamed main_) should not be inlined into
390388
// this function. main_() itself may have other functions inlined (with
391389
// their own stack variables), that's why we need this main/main_ split.
392-
//mp_stack_ctrl_init();
390+
mp_stack_ctrl_init();
393391
return main_(argc, argv);
394392
}
395393

396394
MP_NOINLINE int main_(int argc, char **argv) {
397-
//mp_stack_set_limit(40000 * (BYTES_PER_WORD / 4));
395+
mp_stack_set_limit(40000 * (BYTES_PER_WORD / 4));
398396

399-
//pre_process_options(argc, argv);
397+
pre_process_options(argc, argv);
400398

401399
#if MICROPY_ENABLE_GC
402400
char *heap = malloc(heap_size);
@@ -408,7 +406,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
408406
// create keyboard interrupt object
409407
MP_STATE_VM(keyboard_interrupt_obj) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
410408

411-
char *home = getenv("HOME");
412409
char *path = getenv("MICROPYPATH");
413410
if (path == NULL) {
414411
#ifdef MICROPY_PY_SYS_PATH_DEFAULT
@@ -435,15 +432,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
435432
if (p1 == NULL) {
436433
p1 = p + strlen(p);
437434
}
438-
if (p[0] == '~' && p[1] == '/' && home != NULL) {
439-
// Expand standalone ~ to $HOME
440-
CHECKBUF(buf, PATH_MAX);
441-
CHECKBUF_APPEND(buf, home, strlen(home));
442-
CHECKBUF_APPEND(buf, p + 1, (size_t)(p1 - p - 1));
443-
path_items[i] = MP_OBJ_NEW_QSTR(qstr_from_strn(buf, CHECKBUF_LEN(buf)));
444-
} else {
445-
path_items[i] = MP_OBJ_NEW_QSTR(qstr_from_strn(p, p1 - p));
446-
}
435+
path_items[i] = MP_OBJ_NEW_QSTR(qstr_from_strn(p, p1 - p));
447436
p = p1 + 1;
448437
}
449438
}

frosted/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#if defined(__APPLE__) && defined(__MACH__)
8686
#define MICROPY_PY_SYS_PLATFORM "darwin"
8787
#else
88-
#define MICROPY_PY_SYS_PLATFORM "linux"
88+
#define MICROPY_PY_SYS_PLATFORM "frosted"
8989
#endif
9090
#define MICROPY_PY_SYS_MAXSIZE (1)
9191
#define MICROPY_PY_SYS_STDFILES (1)

py/mpconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
// Maximum length of a path in the filesystem
186186
// So we can allocate a buffer on the stack for path manipulation in import
187187
#ifndef MICROPY_ALLOC_PATH_MAX
188-
#define MICROPY_ALLOC_PATH_MAX (512)
188+
#define MICROPY_ALLOC_PATH_MAX (256)
189189
#endif
190190

191191
// Initial size of module dict

0 commit comments

Comments
 (0)