25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
3.0 KiB

  1. proc delete_error() -> void {
  2. using Globals::error;
  3. if (error) {
  4. free(error);
  5. error = nullptr;
  6. }
  7. }
  8. proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, String* message) -> void {
  9. printf("Error created in:\n%s:%d\n", c_file_name, c_file_line);
  10. delete_error();
  11. debug_break();
  12. using Globals::error;
  13. error = new(Error);
  14. error->type = type;
  15. error->message = message;
  16. }
  17. proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...) -> void {
  18. // HACK(Felix): the length of all error strings is 200!!!!!!!!!!
  19. int length = 200;
  20. String* formatted_string = Memory::create_string("", length);
  21. int written_length;
  22. va_list args;
  23. va_start(args, format);
  24. written_length = vsnprintf(&formatted_string->data, length, format, args);
  25. va_end(args);
  26. formatted_string->length = written_length;
  27. create_error(c_file_name, c_file_line, type, formatted_string);
  28. }
  29. // proc Error_Type_to_string(Error_Type type) -> const char* {
  30. // switch (type) {
  31. // case Error_Type::Assertion_Error: return "Assertion failed";
  32. // case Error_Type::File_Not_Found: return "File not found";
  33. // case Error_Type::Ill_Formed_Arguments: return "Evaluation-error: Ill formed arguments";
  34. // case Error_Type::Ill_Formed_Lambda_List: return "Evaluation-error: Ill formed lambda list";
  35. // case Error_Type::Ill_Formed_List: return "Evaluation-error: Ill formed list";
  36. // case Error_Type::Not_A_Function: return "Evaluation-error: Not a function";
  37. // case Error_Type::Not_Yet_Implemented: return "Evaluation-error: Not yet implemented";
  38. // case Error_Type::Symbol_Not_Defined: return "Evaluation-error: Symbol not defined";
  39. // case Error_Type::Syntax_Error: return "Syntax Error";
  40. // case Error_Type::Trailing_Garbage: return "Evaluation-error: Trailing garbage following expression";
  41. // case Error_Type::Type_Missmatch: return "Evaluation-error: Type Missmatch";
  42. // case Error_Type::Unbalanced_Parenthesis: return "Parsing-error: Unbalanced parenthesis";
  43. // case Error_Type::Unexpected_Eof: return "Parsing-error: Unexpected EOF";
  44. // case Error_Type::Unknown_Keyword_Argument: return "Evaluation-error: Unknown keyword argument";
  45. // case Error_Type::Wrong_Number_Of_Arguments: return "Evaluation-error: Wrong number of arguments";
  46. // case Error_Type::Out_Of_Memory: return "Runtime-error: Out of memory";
  47. // default: return "this error type doesn't have a desciption..";
  48. // }
  49. // }
  50. // proc assert_type(Lisp_Object* node, Lisp_Object_Type type) -> void {
  51. // if (!node) {
  52. // create_generic_error(
  53. // "The node where the type should have"
  54. // "been checked was nullptr.");
  55. // return;
  56. // }
  57. // if (node->type != type)
  58. // create_type_missmatch_error(
  59. // ""
  60. // );
  61. // }