File: typ2cod.f

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (210 lines) | stat: -rw-r--r-- 5,546 bytes parent folder | download | duplicates (2)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
      subroutine typ2cod(il,name,n)
c     returns in name(1:n) the code associated with the type of the
c     variable that began in istk(il)

c     Copyright INRIA
      INCLUDE '../stack.h'
      integer nmax
      parameter (nmax=8)
c     following common defines the initial database of type names
      integer maxtyp,nmmax,maxtypf,nmmaxf
      parameter (maxtyp=50,nmmax=200)
      integer tp(maxtyp),ptr(maxtyp),ln(maxtyp),namrec(nmmax),ptmax
      common /typnams/ tp,ptr,ln,namrec,ptmax
      integer name(*)
      integer iadr,sadr
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
c
      itype=abs(istk(il))
      if(itype.le.20) then
c     look for itype in predefined types
         if(itype.eq.16.or.itype.eq.17) then
            if(istk(il).lt.0) il=iadr(istk(il+1))
            n1=istk(il+1)
            iltyp=iadr(sadr(il+3+n1))
            nlt=min(nlgh-3,istk(iltyp+5)-1)
            iltyp=iltyp+5+istk(iltyp+1)*istk(iltyp+2)
            n=min(nlt,nmax)
            call icopy(n,istk(iltyp),1,name(1),1)
            return
         elseif(itype.eq.0) then
            n=1
            name(1)=0
         else
            n=ln(itype)
            call icopy(n,namrec(ptr(itype)),1,name,1)
         endif
      else
c     look for itype in dynamically added types
         it=20
 10      it=it+1
         if(it.gt.maxtyp) goto 9000
         if(tp(it).ne.itype) goto 10
         n=ln(it)
         call icopy(n,namrec(ptr(it)),1,name,1)
      endif
c      
      return
 9000 continue
      n=0
      return
      end
      
      subroutine settypnames()
c     initialize hard coded type names

c     Copyright INRIA
      INCLUDE '../stack.h'
c     following common defines the initial database of type names
      integer maxtyp,nmmax,maxtypf,nmmaxf
      parameter (maxtyp=50,nmmax=200)
      integer tp(maxtyp),ptr(maxtyp),ln(maxtyp),namrec(nmmax),ptmax
      common /typnams/ tp,ptr,ln,namrec,ptmax
      save /typnams/

      
      ip=1
      ptmax=1
      do 10 i=1,20
         tp(i)=i
         ln(i)=0
         ptr(i)=0
 10   continue


c     type 1 :s
      call addtypename(1,'s',ierr)
      if(ierr.ne.0) goto 99
c     type 2 : p
      call addtypename(2,'p',ierr)
      if(ierr.ne.0) goto 99
c     type 4 : b
      call addtypename(4,'b',ierr)
      if(ierr.ne.0) goto 99
c     type 5 : sp
      call addtypename(5,'sp',ierr)
      if(ierr.ne.0) goto 99
c     type 6 : spb
      call addtypename(6,'spb',ierr)
      if(ierr.ne.0) goto 99
C     type 7 : msp
      call addtypename(7,'msp',ierr)
      if(ierr.ne.0) goto 99
C     type 8 : i
      call addtypename(8,'i',ierr)
      if(ierr.ne.0) goto 99
C     type 9 : h
      call addtypename(9,'h',ierr)
      if(ierr.ne.0) goto 99
c     type 10 : c
      call addtypename(10,'c',ierr)
      if(ierr.ne.0) goto 99
c     type 11 : m
      call addtypename(11,'m',ierr)
      if(ierr.ne.0) goto 99
c     type 13 : mc
      call addtypename(13,'mc',ierr)
      if(ierr.ne.0) goto 99
c     type 14 : f
      call addtypename(14,'f',ierr)
      if(ierr.ne.0) goto 99
c     type 15 : l
      call addtypename(15,'l',ierr)
      if(ierr.ne.0) goto 99
c     type 16 : 
      call addtypename(16,'tl',ierr)
      if(ierr.ne.0) goto 99
c     type 17 : 
      call addtypename(17,'ml',ierr)
      if(ierr.ne.0) goto 99
c     type 128 : ptr (lu pointer)
      call addtypename(128,'ptr',ierr)
      if(ierr.ne.0) goto 99
c     type 129 : ip
      call addtypename(129,'ip',ierr)
      if(ierr.ne.0) goto 99
c     type 130 : fptr
      call addtypename(130,'fptr',ierr)
      if(ierr.ne.0) goto 99

      return
 99   if(ierr.eq.1) then
         call error(224)
      elseif(ierr.eq.2) then
         call error(225)
      elseif(ierr.eq.3) then
         call error(224)
      endif
      return
      end

      subroutine addtypename(typ,nam,ierr)
      integer pos,typ,ierr
      character*(*) nam
c
c     Copyright INRIA
c     following common defines the initial database of type names
      integer maxtyp,nmmax,maxtypf,nmmaxf
      parameter (maxtyp=50,nmmax=200)
      integer tp(maxtyp),ptr(maxtyp),ln(maxtyp),namrec(nmmax),ptmax
      common /typnams/ tp,ptr,ln,namrec,ptmax
      character*15 nam1
c
      ierr=0
c     
      n=len(nam)
      if(n.gt.0) then
c     add a type
         if(typ.le.20) then
            pos=typ
            if(ln(pos).ne.0) then
c     .     check if new type is the same as old type
               if(ln(pos).eq.len(nam)) then
                  n=ln(pos)
                  call cvstr(ln(pos),namrec(ptr(pos)),nam1,1)
                  if(nam1(1:n).eq.nam(1:n)) return
               endif
               ierr=2
               return
            endif
         else
            pos=20
 10         pos=pos+1
            if(pos.gt.maxtyp) then
               ierr=1
               return
            endif
            if(ln(pos).ne.0) goto 10
         endif
         tp(pos)=typ
         if(ptmax+n.gt.nmmax) then
            ierr=3
            return
         endif

         ln(pos)=n
         ptr(pos)=ptmax
         call cvstr(n,namrec(ptmax),nam,0)
         ptmax=ptmax+n
      else
c     supress a type
         if(typ.le.20) then
            pos=typ
            if(ln(pos).eq.0) return
         else
            pos=20
 20         pos=pos+1
            if(pos.gt.maxtyp) return
            if(tp(pos).ne.typ) goto 20
         endif
         n=ln(pos)
         ll=ptmax-(ptr(pos)+n)+1
         call icopy(ll,namrec(ptr(pos)+n),1,namrec(ptr(pos)),1)
         ptr(pos)=0
         ln(pos)=0
         ptmax=ptmax-n
      endif
      return
      end