This file is indexed.

/usr/share/doc/gnat-gps/examples/demo/struct/values-operations.adb is in gnat-gps-doc 5.3dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
with Except;
with Screen_Output;
with Stack;

package body Values.Operations is

   ----------
   -- Read --
   ----------

   function Read (Op : String) return Operation is
   begin
      if Op = "+" then
         return Add;

      elsif Op = "-" then
         return Sub;

      elsif Op = "*" then
         return Mul;

      elsif Op = "/" then
         return Div;

      elsif Op = "#" then
         return Matrix;
      else
         raise Except.User_Error;
      end if;
   end Read;

   -------------
   -- Process --
   -------------

   procedure Process (Op : Operation) is
      V2 : Value := Stack.Pop;
      V1 : Value := Stack.Pop;

      Result   : Integer;
      Result_M : Matrix_Type;

   begin
      case V1.Kind is
         when Int =>
            case Op is
               when Add =>
                  Result := V1.E + V2.E;
                  Stack.Push (new Value_Info'(Kind => Int, E => Result));

               when Div =>
                  Result := V1.E / V2.E;
                  Stack.Push (new Value_Info'(Kind => Int, E => Result));

               when Mul =>
                  Result := V1.E * V2.E;
                  Stack.Push (new Value_Info'(Kind => Int, E => Result));

               when Sub =>
                  Result := V1.E - V2.E;
                  Stack.Push (new Value_Info'(Kind => Int, E => Result));

               when Matrix =>
                  Result_M := Alloc (2, 2);
                  Set (Result_M, 1, 0, V1.E);
                  Set (Result_M, 1, 1, V2.E);
                  Set (Result_M, 0, 1, Stack.Pop.E);
                  Set (Result_M, 0, 0, Stack.Pop.E);
                  Stack.Push (new Value_Info'(Kind => Matrix, M => Result_M));

            end case;

         when Matrix =>
            --  This is a Matrix operation

            case Op is
               when Add =>
                  Result_M := V1.M + V2.M;

               when Div =>
                  raise Except.User_Error;

               when Mul =>
                  Result_M := V1.M * V2.M;

               when Sub =>
                  raise Except.User_Error;

               when Matrix =>
                  raise Except.User_Error;
            end case;

            Stack.Push (new Value_Info'(Kind => Matrix, M => Result_M));
      end case;

   exception
      --  If we get a Constraint_Error exception, then we had a computation
      --  overflow or a divide by zero.

      when Constraint_Error =>
         Screen_Output.Error_Msg ("Operation error. Values popped.");
         raise;

   end Process;

end Values.Operations;