Куча говна / Говнокод #28190 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
with Ada.Unchecked_Conversion;
with Interfaces.C;
with System.Address_To_Access_Conversions;
with System.Address_Operations; use System.Address_Operations;

with VGA_Console; use VGA_Console;

procedure Crash (Source_Location : System.Address; Line : Integer) is
   package C renames Interfaces.C;

   --  Get the length of the C NULL terminated string.
   function Length (Source_Location : System.Address) return C.size_t is
      use type C.size_t;

      function Convert is new Ada.Unchecked_Conversion (Source => C.size_t,
                                                        Target => System.Address);

      package To_Char is new System.Address_To_Access_Conversions (Object => C.char);

      Count : C.size_t               := 0;
      Char  : To_Char.Object_Pointer := To_Char.To_Pointer (AddA (Source_Location, Convert (Count)));
   begin
      while C.char'Pos (Char.all) /= 0 loop
         Count := Count + 1;
         Char  := To_Char.To_Pointer (AddA (Source_Location, Convert (Count)));
      end loop;

      return Count;
   end Length;

   --  This is really ugly, just to convert an address pointing to a C NULL terminated string to an Ada String!
   Source_Length : constant C.size_t := Length (Source_Location);

   type Source_Chars is new C.char_array (0 .. Source_Length);

   C_Str         : Source_Chars with
     Address => Source_Location;
   pragma Import (Convention => Ada, Entity => C_Str);
   Source_Str    : constant String := C.To_Ada (C.char_array (C_Str));
begin
   Put (Str        => "** Kernel crashed at: " & Source_Str & ":" & Integer'Image (Line) & " **",
        X          => 1,
        Y          => 10,
        Foreground => White,
        Background => Red);

   --  TODO: Dump registers.

   Hang : loop
      null;
   end loop Hang;
end Crash;

Запостил: 3_dar 3_dar, (Updated )

Комментарии (13) RSS

  • Ого, тоже хочу на Аде писать
    Ответить
    • > with System.Address_Operations; use System.Address_Operations;
      > with VGA_Console; use VGA_Console;
      Такую вербозятину ты и сейчас можешь писать сам знаешь на чем.
      Ответить
        • > и сейчас
          > crt
          Которая сломана с 1994 года из-за бизилупа и сираный броланд так и не починил.
          Я конечно же про ThrowableException extends Exception impelments IThrowable
          Ответить
          • Runtime Error 200?

            >ThrowableException extends Exception impelments IThrowable

            public static final class AbstractToolsFactoryProviderImpl {
                public static final void init()
            }
            Ответить
            • Оно самое. Мне Иава напоминает монгольфьер, груженный балластом, который предполагается выкидывать за борт для регулирования высоты и одновременно забитый хламом балкон совковой хрущобы, потому что этот хлам никогда не будет выкинут.
              Ответить

Добавить комментарий

Где здесь C++, guest?!

    А не использовать ли нам bbcode?


    8