OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [ada/] [i-fortra.adb] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                   I N T E R F A C E S . F O R T R A N                    --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17
-- for  more details.  You should have  received  a copy of the GNU General --
18
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20
-- Boston, MA 02110-1301, USA.                                              --
21
--                                                                          --
22
-- As a special exception,  if other files  instantiate  generics from this --
23
-- unit, or you link  this unit with other files  to produce an executable, --
24
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
25
-- covered  by the  GNU  General  Public  License.  This exception does not --
26
-- however invalidate  any other reasons why  the executable file  might be --
27
-- covered by the  GNU Public License.                                      --
28
--                                                                          --
29
-- GNAT was originally developed  by the GNAT team at  New York University. --
30
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
31
--                                                                          --
32
------------------------------------------------------------------------------
33
 
34
package body Interfaces.Fortran is
35
 
36
   ------------
37
   -- To_Ada --
38
   ------------
39
 
40
   --  Single character case
41
 
42
   function To_Ada (Item : Character_Set) return Character is
43
   begin
44
      return Character (Item);
45
   end To_Ada;
46
 
47
   --  String case (function returning converted result)
48
 
49
   function To_Ada (Item : Fortran_Character) return String is
50
      T : String (1 .. Item'Length);
51
 
52
   begin
53
      for J in T'Range loop
54
         T (J) := Character (Item (J - 1 + Item'First));
55
      end loop;
56
 
57
      return T;
58
   end To_Ada;
59
 
60
   --  String case (procedure copying converted string to given buffer)
61
 
62
   procedure To_Ada
63
     (Item   : Fortran_Character;
64
      Target : out String;
65
      Last   : out Natural)
66
   is
67
   begin
68
      if Item'Length = 0 then
69
         Last := 0;
70
         return;
71
 
72
      elsif Target'Length = 0 then
73
         raise Constraint_Error;
74
 
75
      else
76
         Last := Target'First - 1;
77
 
78
         for J in Item'Range loop
79
            Last := Last + 1;
80
 
81
            if Last > Target'Last then
82
               raise Constraint_Error;
83
            else
84
               Target (Last) := Character (Item (J));
85
            end if;
86
         end loop;
87
      end if;
88
   end To_Ada;
89
 
90
   ----------------
91
   -- To_Fortran --
92
   ----------------
93
 
94
   --  Character case
95
 
96
   function To_Fortran (Item : Character) return Character_Set is
97
   begin
98
      return Character_Set (Item);
99
   end To_Fortran;
100
 
101
   --  String case (function returning converted result)
102
 
103
   function To_Fortran (Item : String) return Fortran_Character is
104
      T : Fortran_Character (1 .. Item'Length);
105
 
106
   begin
107
      for J in T'Range loop
108
         T (J) := Character_Set (Item (J - 1 + Item'First));
109
      end loop;
110
 
111
      return T;
112
   end To_Fortran;
113
 
114
   --  String case (procedure copying converted string to given buffer)
115
 
116
   procedure To_Fortran
117
     (Item   : String;
118
      Target : out Fortran_Character;
119
      Last   : out Natural)
120
   is
121
   begin
122
      if Item'Length = 0 then
123
         Last := 0;
124
         return;
125
 
126
      elsif Target'Length = 0 then
127
         raise Constraint_Error;
128
 
129
      else
130
         Last := Target'First - 1;
131
 
132
         for J in Item'Range loop
133
            Last := Last + 1;
134
 
135
            if Last > Target'Last then
136
               raise Constraint_Error;
137
            else
138
               Target (Last) := Character_Set (Item (J));
139
            end if;
140
         end loop;
141
      end if;
142
   end To_Fortran;
143
 
144
end Interfaces.Fortran;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.