qemu-arm: Move lexer constructors to within NLR handler block.
And raise an exception when mp_lexer_new_from_file is called.
This commit is contained in:
parent
bcd5adc65e
commit
25b6b62562
@ -12,15 +12,12 @@
|
|||||||
#include "py/stackctrl.h"
|
#include "py/stackctrl.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "py/repl.h"
|
#include "py/repl.h"
|
||||||
|
#include "py/mperrno.h"
|
||||||
|
|
||||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||||
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
|
||||||
if (lex == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nlr_buf_t nlr;
|
nlr_buf_t nlr;
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
|
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
||||||
qstr source_name = lex->source_name;
|
qstr source_name = lex->source_name;
|
||||||
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
||||||
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
|
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
|
||||||
@ -47,7 +44,7 @@ void gc_collect(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||||
return NULL;
|
mp_raise_OSError(MP_ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_import_stat_t mp_import_stat(const char *path) {
|
mp_import_stat_t mp_import_stat(const char *path) {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stackctrl.h"
|
#include "py/stackctrl.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "py/repl.h"
|
#include "py/mperrno.h"
|
||||||
|
|
||||||
#include "tinytest.h"
|
#include "tinytest.h"
|
||||||
#include "tinytest_macros.h"
|
#include "tinytest_macros.h"
|
||||||
@ -24,13 +24,9 @@ inline void do_str(const char *src) {
|
|||||||
gc_init(heap, (char*)heap + HEAP_SIZE);
|
gc_init(heap, (char*)heap + HEAP_SIZE);
|
||||||
mp_init();
|
mp_init();
|
||||||
|
|
||||||
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
|
||||||
if (lex == NULL) {
|
|
||||||
tt_abort_msg("Lexer initialization error");
|
|
||||||
}
|
|
||||||
|
|
||||||
nlr_buf_t nlr;
|
nlr_buf_t nlr;
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
|
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
||||||
qstr source_name = lex->source_name;
|
qstr source_name = lex->source_name;
|
||||||
mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT);
|
mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT);
|
||||||
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false);
|
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false);
|
||||||
@ -80,7 +76,7 @@ void gc_collect(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||||
return NULL;
|
mp_raise_OSError(MP_ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_import_stat_t mp_import_stat(const char *path) {
|
mp_import_stat_t mp_import_stat(const char *path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user