|
- proc delete_error() -> void {
- using Globals::error;
-
- if (error) {
- free(error);
- error = nullptr;
- }
- }
-
- proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, String* message) -> void {
-
- printf("Error created in:\n%s:%d\n", c_file_name, c_file_line);
-
- delete_error();
- debug_break();
-
- using Globals::error;
- error = new(Error);
- error->type = type;
- error->message = message;
- }
-
-
- proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...) -> void {
- // HACK(Felix): the length of all error strings is 200!!!!!!!!!!
-
- int length = 200;
- String* formatted_string = Memory::create_string("", length);
-
- int written_length;
- va_list args;
- va_start(args, format);
- written_length = vsnprintf(&formatted_string->data, length, format, args);
- va_end(args);
-
- formatted_string->length = written_length;
-
- create_error(c_file_name, c_file_line, type, formatted_string);
- }
-
- // proc Error_Type_to_string(Error_Type type) -> const char* {
- // switch (type) {
- // case Error_Type::Assertion_Error: return "Assertion failed";
- // case Error_Type::File_Not_Found: return "File not found";
- // case Error_Type::Ill_Formed_Arguments: return "Evaluation-error: Ill formed arguments";
- // case Error_Type::Ill_Formed_Lambda_List: return "Evaluation-error: Ill formed lambda list";
- // case Error_Type::Ill_Formed_List: return "Evaluation-error: Ill formed list";
- // case Error_Type::Not_A_Function: return "Evaluation-error: Not a function";
- // case Error_Type::Not_Yet_Implemented: return "Evaluation-error: Not yet implemented";
- // case Error_Type::Symbol_Not_Defined: return "Evaluation-error: Symbol not defined";
- // case Error_Type::Syntax_Error: return "Syntax Error";
- // case Error_Type::Trailing_Garbage: return "Evaluation-error: Trailing garbage following expression";
- // case Error_Type::Type_Missmatch: return "Evaluation-error: Type Missmatch";
- // case Error_Type::Unbalanced_Parenthesis: return "Parsing-error: Unbalanced parenthesis";
- // case Error_Type::Unexpected_Eof: return "Parsing-error: Unexpected EOF";
- // case Error_Type::Unknown_Keyword_Argument: return "Evaluation-error: Unknown keyword argument";
- // case Error_Type::Wrong_Number_Of_Arguments: return "Evaluation-error: Wrong number of arguments";
- // case Error_Type::Out_Of_Memory: return "Runtime-error: Out of memory";
- // default: return "this error type doesn't have a desciption..";
- // }
- // }
-
- // proc assert_type(Lisp_Object* node, Lisp_Object_Type type) -> void {
- // if (!node) {
- // create_generic_error(
- // "The node where the type should have"
- // "been checked was nullptr.");
- // return;
- // }
-
- // if (node->type != type)
- // create_type_missmatch_error(
- // ""
- // );
- // }
|