Gen3Impl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Jean Gastinel August 13, 1987 3:51:31 pm PDT
Oracle Generation
DIRECTORY
FS, IO, Rope, OracleGen, BitOps, Convert;
Gen3Impl: CEDAR PROGRAM
IMPORTS FS, IO, OracleGen, Rope, BitOps, Convert
~
BEGIN
OPEN OracleGen;
outf: IO.STREAM;
k : CARD;
nr:INT ← 3; --number of colums in the right side of the line
nl:INT ← 3; --number of colums in the left side of the line
NbRight, NbLeft : TYPE = [0..3);
RightLine: TYPE = ARRAY NbRight OF Rope.ROPE;
LeftLine: TYPE = ARRAY NbLeft OF Rope.ROPE;
rl: RightLine;
ll: LeftLine;
TwoExp32:
PROC [k:
CARD]
RETURNS [r: Rope.
ROPE] ~ {
This proc compute 2^k and transform it into a Rope of length 8 Hexa
x: BitOps.BitDWord = BitOps.DShift[1,k MOD 32];
y: Rope.ROPE = Hex[x];
r ← LExtend[y,8];
};
TwoExp4:
PROC [k:
CARD]
RETURNS [r: Rope.
ROPE] ~ {
This proc compute k MOD 16 and transform it into a Rope of length 1 Hexa
r ← LExtend[Hex[k MOD 16],1];
};
MergeOut:
PROC []
RETURNS [] ~ {
This proc merge into two Rope Right and Left different elements of the line
and write the result inthe output stream
column : INT;
r : Rope.ROPE;
r ← "";
FOR column
IN [0..nl)
DO r ← Rope.Cat[r,ll[column]," "];
ENDLOOP;
r ← Rope.Cat[r,"| "];
FOR column
IN [0..nr)
DO r ← Rope.Cat[r,rl[column]," "];
ENDLOOP;
outf.PutF["%g -- %g \n",IO.rope[r],IO.rope[Convert.RopeFromInt[k]]];
};
Start of the Program
Here the program start :
Create or Append the file
outf ← FS.StreamOpen["Gen.oracle", $create];
outf.PutF["-- Begining of the text : \n"];
Start Generation :
FOR k IN[0..66)
DO
SELECT k
FROM
IN[0..2) => {
ll[0] ← "00000000"; ll[1] ← "00000000"; ll[2] ← "0";
rl[0] ← "XXXXXXXX"; rl[1] ← "XXXXXXXX"; rl[2] ← "X";
};
IN[2..4) => {
ll[0] ← "00000000"; ll[1] ← TwoExp32[k-2]; ll[2] ← TwoExp4[k-2];
rl[0] ← "XXXXXXXX"; rl[1] ← "XXXXXXXX"; rl[2] ← "X";
};
IN[4..5) => {
ll[0] ← "00000000"; ll[1] ← TwoExp32[k-2]; ll[2] ← TwoExp4[k-2];
rl[0] ← "00000000"; rl[1] ← "00000000"; rl[2] ← "0";
};
IN[5..34) => {
ll[0] ← "00000000"; ll[1] ← TwoExp32[k-2]; ll[2] ← TwoExp4[k-2];
rl[0] ← "00000000"; rl[1] ← TwoExp32[k-5]; rl[2] ← TwoExp4[k-5];
};
IN[34..37) => {
ll[0] ← TwoExp32[k-2]; ll[1] ← "00000000"; ll[2] ← TwoExp4[k-2];
rl[0] ← "00000000"; rl[1] ← TwoExp32[k-5]; rl[2] ← TwoExp4[k-5];
};
IN[37..66) => {
ll[0] ← TwoExp32[k-2]; ll[1] ← "00000000"; ll[2] ← TwoExp4[k-2];
rl[0] ← TwoExp32[k-5]; rl[1] ← "00000000"; rl[2] ← TwoExp4[k-5];
};
ENDCASE ;
MergeOut[];
ENDLOOP;
outf.Close[];
END.