summaryrefslogtreecommitdiff
path: root/pit/src/native.c
diff options
context:
space:
mode:
Diffstat (limited to 'pit/src/native.c')
-rw-r--r--pit/src/native.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/pit/src/native.c b/pit/src/native.c
index 2ffba0a..e4e0bf1 100644
--- a/pit/src/native.c
+++ b/pit/src/native.c
@@ -33,11 +33,11 @@ void pit_dump_to_file(pit_runtime *rt, void *vf, pit_value v, bool readable) {
bool pit_runtime_print_error(pit_runtime *rt) {
if (!pit_value_eq(rt->error, PIT_NIL)) {
- for (i64 i = 0; i < rt->backtrace->next; ++i) {
- pit_backtrace_entry *a = pit_vec_get(pit_backtrace_entry)(rt->backtrace, i);
+ for (i64 i = 0; i < rt->callstack->next; ++i) {
+ pit_callstack_entry *a = pit_vec_get(pit_callstack_entry)(rt->callstack, i);
if (a == NULL) continue;
fprintf(stderr, "on line %ld, column %ld (call to ", a->ann.line, a->ann.column);
- pit_dump_to_file(rt, stderr, a->val, false);
+ pit_dump_to_file(rt, stderr, a->tag, false);
fprintf(stderr, "):\n");
}
fprintf(stderr, "error at line %ld, column %ld: ", rt->error_line, rt->error_column);
@@ -45,7 +45,7 @@ bool pit_runtime_print_error(pit_runtime *rt) {
fprintf(stderr, "\n");
return true;
}
- pit_vec_reset(pit_backtrace_entry)(rt->backtrace);
+ pit_vec_reset(pit_callstack_entry)(rt->callstack);
return false;
}
@@ -95,25 +95,27 @@ static void check_invariants(pit_runtime *rt) {
}
}
pit_value pit_load_file(pit_runtime *rt, char *path) {
- pit_lexer lex;
- pit_parser parse;
- bool eof = false;
- pit_value p = PIT_NIL;
- pit_value ret = PIT_NIL;
- if (pit_lex_file(&lex, path) < 0) {
- pit_error(rt, "failed to lex file: %s", path);
- return PIT_NIL;
- }
- pit_parser_from_lexer(&parse, &lex);
- while (p = pit_parse(rt, &parse, &eof), !eof) {
- check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
- ret = pit_eval(rt, p);
- check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
- pit_gc(rt);
- check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
- }
- check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
- return ret;
+ // TODO
+ return PIT_NIL;
+ // pit_lexer lex;
+ // pit_parser parse;
+ // bool eof = false;
+ // pit_value p = PIT_NIL;
+ // pit_value ret = PIT_NIL;
+ // if (pit_lex_file(&lex, path) < 0) {
+ // pit_error(rt, "failed to lex file: %s", path);
+ // return PIT_NIL;
+ // }
+ // pit_parser_from_lexer(&parse, &lex);
+ // while (p = pit_parse(rt, &parse, &eof), !eof) {
+ // check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
+ // ret = pit_eval(rt, p);
+ // check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
+ // pit_gc(rt);
+ // check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
+ // }
+ // check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
+ // return ret;
}
void pit_repl(pit_runtime *rt) {
@@ -153,7 +155,8 @@ void pit_repl(pit_runtime *rt) {
pit_parser_from_lexer(&parse, &lex);
while (p = pit_parse(rt, &parse, &eof), !eof) {
check_invariants(rt);
- res = pit_eval(rt, p);
+ // res = pit_eval(rt, p);
+ res = pit_vm_eval(rt, pit_vm_compile(rt, p));
check_invariants(rt);
}
if (pit_runtime_print_error(rt)) {