Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

56 строки
1.7 KiB

  1. namespace Slime {
  2. proc delete_error() -> void {
  3. using Globals::error;
  4. free(error);
  5. error = nullptr;
  6. }
  7. proc create_error(const char* c_func_name, const char* c_file_name,
  8. u32 c_file_line, Lisp_Object* type, String message) -> void
  9. {
  10. using Globals::error;
  11. delete_error();
  12. error = (Error*)malloc(sizeof(Error)) ;
  13. error->type = type;
  14. error->message = message;
  15. log_error();
  16. if (Globals::breaking_on_errors) {
  17. debug_break();
  18. }
  19. if (Globals::log_level > Log_Level::None) {
  20. // c error location
  21. printf("in");
  22. s32 spacing = 30-((s32)strlen(c_file_name) + (s32)log10(c_file_line));
  23. if (spacing < 1) spacing = 1;
  24. for (s32 i = 0; i < spacing; ++i)
  25. printf(" ");
  26. printf("%s (%u) ", c_file_name, c_file_line);
  27. printf("-> %s\n", c_func_name);
  28. }
  29. // visualize_lisp_machine();
  30. }
  31. proc create_error(const char* c_func_name, const char* c_file_name,
  32. u32 c_file_line, Lisp_Object* type, const char* format, ...) -> void {
  33. using Globals::error;
  34. if (error) {
  35. error = new(Error);
  36. error->type = type;
  37. }
  38. // contents will be filled in
  39. String formatted_string = Memory::create_string("", 0);
  40. va_list args;
  41. va_start(args, format);
  42. formatted_string.length = vasprintf(&formatted_string.data, format, args);
  43. va_end(args);
  44. create_error(c_func_name, c_file_name, c_file_line, type, formatted_string);
  45. }
  46. }