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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
|
subroutine compcl(job)
c ======================================================================
c compilation des structures de controle
c ======================================================================
c Copyright INRIA
include '../stack.h'
c
parameter (nz1=nsiz-1,nz2=nsiz-2)
parameter (iif=1,iwhile=2,iselect=3)
logical eqid
integer else(nsiz),r,cas(nsiz),elsif(nsiz)
integer sadr
c job is used for try catch
integer job
data else/236721422,nz1*673720360/
data cas/236718604,nz1*673720360/
data elsif/236721422,673713938,nz2*673720360/
c
sadr(l)=(l/2)+1
c
l=comp(1)
r = rstk(pt)-800
if (ddt .eq. 4) then
write(buf(1:20),'(2i4,2i6)') pt,rstk(pt),l,comp(2)
call basout(io,wte,' compcl pt:'//buf(1:4)//' rstk(pt):'
& //buf(5:8)//' comp(1):'//buf(9:14)//' comp(2):'
& //buf(15:20))
endif
if(ids(1,pt).eq.iselect) goto 10
goto(02,03,04,05,06,08,10,20),r
c
c for : <7 l.boucle boucle.ops l.ops varn(1:nsiz) for.ops>
c
c debut for
01 continue
err=sadr(l+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
istk(l)=7
l0=l+2
istk(l0-1)=comp(2)
comp(2)=l0
comp(1)=l+2
return
02 err=sadr(l+nsiz+2)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
l0=comp(2)
comp(2)=istk(l0-1)
istk(l0-1)=l-l0
l0=l
call putid(istk(l+1),ids(1,pt))
l=l+nsiz+1
istk(l0)=comp(2)
comp(2)=l0
comp(1)=l
return
c fin for
03 l0=comp(2)
comp(2)=istk(l0)
istk(l0)=l-(l0+nsiz+1)
call setlnb
return
c
c while : <8 0 l.exprs l.then l.else exprs.ops then.ops else.ops>
c if : <9 0 l.exprs l.then l.else exprs.ops then.ops else.ops>
c le "0" est present pour conserver la compatibilite avec la version precedente
c
c debut d'un if ou while
04 err=sadr(l+2)-lstk(bot)
if(err.gt.0) then
call error(17)
if(err.gt.0) return
endif
istk(l)=l
istk(l+1)=comp(2)
lc=l+2
istk(lc)=0
comp(2)=l+3
comp(1)=l+4
c
l=comp(1)
l0=comp(2)
istk(l)=l0-2
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
return
c fin des expressions du if ou des elseif
05 l0=comp(2)
istk(l)=istk(l0)
lc=istk(l0)+1
istk(lc)=istk(lc)+1
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
call setlnb
return
c fin d'un Then
06 l0=comp(2)
istk(l)=istk(l0)
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
if(eqid(syn(1),elsif))return
c fin de la sequence des then
c on debute le else par une sequence expression vide
istk(l+1)=istk(l)
istk(l)=0
comp(2)=l+1
comp(1)=l+2
call setlnb
if(eqid(syn(1),else)) return
c il n'y a pas de else,
c on introduit une sequence else_instructions vide
istk(l+2)=istk(l+1)
istk(l+1)=0
comp(2)=l+2
l=l+3
comp(1)=l
c et on termine le if/while
goto 09
c
c fin du else
08 l0=comp(2)
istk(l)=istk(l0)
istk(l0)=l-(l0+1)
comp(2)=l
c
c fin if/while
09 l0=comp(2)
l0=istk(comp(2))
comp(2)=istk(l0)
istk(l0)=-(l-istk(l0-1))
istk(l0-1)=8
if(ids(1,pt).eq.iwhile) istk(l0-1)=9
call setlnb
return
c
c
c select case <10,???>
10 continue
goto(11,13,14,15,12),r-2
goto 99
c
c debut selec (premiere expression)
11 err=sadr(l+2)-lstk(bot)
if(err.gt.0) then
call error(17)
if(err.gt.0) return
endif
istk(l)=l
istk(l+1)=comp(2)
lc=l+2
istk(lc)=0
comp(2)=l+3
comp(1)=l+4
return
c
c fin premiere expression
12 l0=comp(2)
istk(l)=l0-2
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
return
c
c fin des expressions des cases
13 l0=comp(2)
istk(l)=istk(l0)
lc=istk(l0)+1
istk(lc)=istk(lc)+1
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
call setlnb
return
c fin d'un case (partie Then)
14 l0=comp(2)
istk(l)=istk(l0)
istk(l0)=l-(l0+1)
comp(2)=l
comp(1)=l+1
if(eqid(syn(1),cas))return
c fin de la sequence de cases
c on debute le else par une sequence expression vide
istk(l+1)=istk(l)
istk(l)=0
comp(2)=l+1
comp(1)=l+2
if(eqid(syn(1),else)) then
call setlnb
return
endif
c il n'y a pas de else,
c on introduit une sequence else_instructions vide
istk(l+2)=istk(l+1)
istk(l+1)=0
comp(2)=l+2
l=l+3
comp(1)=l
c et on termine le select
goto 17
c
c fin du else
15 l0=comp(2)
istk(l)=istk(l0)
istk(l0)=l-(l0+1)
comp(2)=l
c
c fin selec
17 l0=comp(2)
l0=istk(comp(2))
comp(2)=istk(l0)
istk(l0)=l-istk(l0-1)
istk(l0-1)=10
call setlnb
return
c
c try <11 l.try l.catch try.ops catch.ops >
20 continue
goto (21,22,23) job
21 continue
c initialize the try structure
err=sadr(l+3)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
istk(l)=11
istk(l+1)=-1
istk(l+2)=comp(2)
comp(2)=l+2
comp(1)=l+3
return
22 continue
c end of try instructions
l0=comp(2)
istk(l0-1)=l-(l0+1)
return
23 continue
c end of catch instructions
l0=comp(2)
comp(2)=istk(l0)
if (istk(l0-1).eq.-1) then
c . no catch keyword,
istk(l0-1)=l-(l0+1)
istk(l0)=0
else
istk(l0)=l-(l0+1)-istk(l0-1)
endif
return
99 call error(22)
return
end
|