Created an awful hack for a clean exit on die().
This commit is contained in:
6
TODO.md
6
TODO.md
@@ -1,5 +1,7 @@
|
||||
1. Differentiate parameters and arguments -- params for function definitions,
|
||||
arguments for function calls
|
||||
EXCEPTION HANDLING: exception ast type should have as data a giant enum of
|
||||
possible types, rather than a char* message. A description of each type could be
|
||||
handled under the exception type and print logic. For now, executor checks
|
||||
message for special exceptions e.g. exit().
|
||||
|
||||
Change editor to GNU Readline.
|
||||
Make variables persist through lines in the editor.
|
||||
|
@@ -136,5 +136,5 @@ AST* builtin_div(size_t argc, AST** argv, Scope* parent) {
|
||||
}
|
||||
|
||||
AST* builtin_die(size_t argc, AST** argv, Scope* parent) {
|
||||
return ast_init(AST_TYPE_EXC, ast_exc_data_init("exit", NULL));
|
||||
return ast_init(AST_TYPE_EXC, ast_exc_data_init("8", NULL));
|
||||
}
|
||||
|
@@ -62,6 +62,13 @@ int main(int argc, char** argv) {
|
||||
|
||||
AST* eval = exec_start(root);
|
||||
ast_print(eval);
|
||||
// Awful hack to exit when die() is called, until proper exception
|
||||
// handling is implemented. TODO TODO TODO PLSFIX.
|
||||
if (eval->type == AST_TYPE_EXC &&
|
||||
((ASTExcData*)eval->data)->msg[0] == '8') {
|
||||
gc_hack_free();
|
||||
exit(1);
|
||||
}
|
||||
gc_hack_free();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user