Handle exit event.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
861159b916
commit
d4f9291ad1
17
src/main.c
17
src/main.c
|
@ -90,6 +90,12 @@ static void app_mrb_runtime_task(void *parameters) {
|
|||
mrb_show_version(mrb);
|
||||
mrb_show_copyright(mrb);
|
||||
|
||||
char mrb_code[] = "name = 'LPCXpresso55S69'\nputs \"Greetings #{name}, from MRuby #{RUBY_VERSION}.\"";
|
||||
|
||||
struct mrb_parser_state *parser_state = mrb_parse_string(mrb, mrb_code, cxt);
|
||||
|
||||
mrb_load_exec(mrb, parser_state, cxt);
|
||||
|
||||
char *line;
|
||||
|
||||
while ((line = linenoise("hello> ")) != NULL) {
|
||||
|
@ -98,16 +104,9 @@ static void app_mrb_runtime_task(void *parameters) {
|
|||
free(line);
|
||||
}
|
||||
|
||||
char mrb_code[] = "name = 'LPCXpresso55S69'\nputs \"Greetings #{name}, from MRuby #{RUBY_VERSION}.\"";
|
||||
printf("REPL thread received ^D, cleaning up...\n");
|
||||
|
||||
struct mrb_parser_state *parser_state = mrb_parse_string(mrb, mrb_code, cxt);
|
||||
|
||||
mrb_load_exec(mrb, parser_state, cxt);
|
||||
|
||||
for (;;) {
|
||||
/* Wait for REPL commands */
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
}
|
||||
/* User pressed ^D */
|
||||
|
||||
mrbc_cleanup_local_variables(mrb, cxt);
|
||||
mrbc_context_free(mrb, cxt);
|
||||
|
|
Loading…
Reference in New Issue