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
|
subroutine stackg(id)
c =============================================================
c get variables from storage
c
c action realisees selon que la variable existe ou non :
c
c fin=0 : oui retour de la variable fin=-1
c non fin=0
c fin=-1 : oui fin=numero de la variable
c non fin=0
c fin=-2 : extraction ou recherche d'une macro pour execution
c oui retour d'une variable de type indirect fin=-1
c non fin=0
c fin=-3 : recherche dans l'environnement propre au niveau courant
c uniquement (insertion)
c oui : retour d'une variable de type indirect fin=-1
c non : retour d'une matrice vide fin=-1
c fin=-4 : demande de retour d'une variable de type indirect
c =============================================================
c
c Copyright INRIA
INCLUDE '../stack.h'
logical compil,vcopyobj
integer id(nsiz),fun1,vol,vk
c
logical eqid,local
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
if (ddt .eq. 4) then
call cvname(id,buf,1)
write(buf(nlgh+1:),'(i8)') fin
call basout(io,wte,' stackg '//buf(1:nlgh+9))
endif
c
if(err1.gt.0) return
c
if ( compil(2,id,fin,rhs,0)) goto 99
c
if(top+1.ge.bot) then
call error(18)
if(err.gt.0) return
endif
c
c set environnement where variable is searched
if(fin.eq.-3.and.(macr.ne.0.or.paus.ne.0)) then
k=lpt(1)-(13+nsiz)
last=lin(k+5)-1
local=.true.
else
last=isiz-1
local=.false.
endif
c
c look for id in the defined variables
k=bot-1
21 k = k+1
if(k.gt.last) then
c variable has not been found in the variables
k = 0
if(fin.eq.-3) then
call defmat
fin = -1
fun = 0
else
fin=0
endif
return
endif
if (.not.eqid(idstk(1,k), id)) go to 21
c
c variable has been found in position k
if(fin.eq.-1) then
fin=k
fun=0
return
endif
lk = lstk(k)
ilk=iadr(lk)
c
c perform operation on the found variable
if(fin.eq.-4) goto 31
if(fin.eq.-2) then
c extraction or macro call
if(abs(istk(ilk)).eq.11.or.abs(istk(ilk)).eq.13) then
c . macro call
if(istk(ilk).lt.0) lk=istk(ilk+1)
fin=lk
fun=0
return
endif
if(istk(ilk).gt.0) then
goto 31
else
goto 25
endif
elseif(fin.eq.-3) then
c insertion
if(istk(ilk).lt.0.and.local) then
c . insertion in a local indirect variable
c . replace indirect variable by its value
k1=istk(ilk+2)
if (k .ne. bot) then
c . shift storage down
vk=lstk(k+1)-lstk(k)
ls = lstk(bot)
call dcopy(lstk(k)-lstk(bot),stk(ls),-1,stk(ls+vk),-1)
do 26 i = k-1,bot,-1
call putid(idstk(1,i+1),idstk(1,i))
infstk(i+1)=infstk(i)
lstk(i+1) = lstk(i)+vk
26 continue
endif
c . destroy old variable
bot = bot+1
c . copy the value
vol=lstk(k1+1)-lstk(k1)
k=bot-1
lstk(k)=lstk(k+1)-vol
call dcopy(vol,stk(lstk(k1)),1,stk(lstk(k)),1)
call putid(idstk(1,k), id)
infstk(k)=0
bot=k
lk = lstk(k)
ilk=iadr(lk)
endif
goto 31
endif
c
c copy the variable at the top of the stack
if(istk(ilk).lt.0) then
c if indirect variable copy the variable pointed by
k=istk(ilk+2)
endif
25 top = top+1
if (.not.vcopyobj(' ',k,top)) return
infstk(top)=0
call putid(idstk(1,top),id)
go to 99
c
31 continue
c return indirect variable
top=top+1
il=iadr(lstk(top))
infstk(top)=0
call putid(idstk(1,top),id)
if(istk(ilk).gt.0) then
istk(il)=-istk(ilk)
istk(il+1)=lk
istk(il+2)=k
else
istk(il)=istk(ilk)
istk(il+1)=istk(ilk+1)
istk(il+2)=istk(ilk+2)
endif
lstk(top+1)=sadr(il+3)
goto 99
c
99 fin = -1
fun = 0
return
end
|