Ratforプリプロセッサー -- コード生成 "while"
2017-06-24


while文にであったら、whileの条件を取り出して、ラベルL、L+1を 作りだし、

          continue
        L if ( .not. (条件)) goto L+1
を出力します。そして、whileの終わりに達したら、
          goto L
      L+1 continue
を出力します。ここで、ラベルL+1は、breakに出会ったときの行き先になります。また、ラベルLは、 nextに出会った時の行き先になります。 具体的には、whilec()でwhile文のはじめを生成します。

whilec()のRatofor版は以下の通り。

# whilec.r4 -- generate code for beginning of while
      subroutine whilec(lab)
      integer lab

      call outcon(0)
      lab = labgen(2)
      call outnum(lab)
      call ifgo(lab+1)
      return
      end

WATCOM Fortran77版は以下の通り。

c whilec.f -- generate code for beginning of while
      subroutine whilec(lab)
      integer lab

      call outcon(0)
      lab = labgen(2)
      call outnum(lab)
      call ifgo(lab+1)
      return
      end

whileの終わりは、whiles()でコードを生成します。

whiles()のRatofor版は以下の通り。

# whiles.r4 -- generate code for end of while
      subroutine whiles(lab)
      integer lab

      call outgo(lab)
      call outcon(lab+1)
      return
      end

WATCOM Fortran77版は以下の通り。

c whiles.f -- generate code for end of while
      subroutine whiles(lab)
      integer lab

      call outgo(lab)
      call outcon(lab+1)
      return
      end
[コンピューター]
[RATFOR]

コメント(全50件)
※コメントの受付件数を超えているため、この記事にコメントすることができません。


記事を書く
powered by ASAHIネット