perm filename EINIT2.2[EAL,HE] blob
sn#704738 filedate 1983-04-05 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor initialization (part of it) }
C00004 00003 (* routine to make predeclared identifiers & constants: initIdents *)
C00013 ENDMK
C⊗;
{$NOMAIN Editor initialization (part of it) }
%include einit.hdr;
{ Externally defined routines from elsewhere: }
(* From ALLOC *)
function newNode: nodep; external;
function newToken: tokenp; external;
function newIdent: identp; external;
function newStrng: strngp; external;
function newVaridef: varidefp; external;
(* From EAUX1A *)
function hash(ch: ascii): integer; external;
(* routine to make predeclared identifiers & constants: initIdents *)
procedure init1Idents; external;
procedure init1Idents;
var i: integer; id: identp; v,vp: varidefp; n: nodep; str,Rstr: strngp;
function makeIdent(s: cstring): identp;
var id: identp; str: strngp; i: integer;
begin
id := newIdent;
with id↑ do
begin
predefined := nil;
str := newStrng;
str↑.ch := s;
name := str;
length := 10;
while s[length] = ' ' do length := length - 1;
end;
i := hash(id↑.name↑.ch[1]); (* find proper bucket *)
id↑.next := idents[i]; (* link us onto list of identifiers *)
idents[i] := id;
makeIdent := id;
end;
function DimMake(s: cstring): varidefp;
var id: identp; vdef: varidefp; n: nodep;
begin
id := makeIdent(s);
vdef := newVaridef;
id↑.predefined := vdef;
n := newNode; (* need to make up a dimension node *)
with n↑ do
begin
next := nil;
ntype := dimnode;
time := 0;
distance := 0;
angle := 0;
dforce := 0;
end;
with vdef↑ do
begin
name := id;
vtype := dimensiontype;
dtype := vdef; (* a bit circular, but... *)
offset := 0;
tbits := 0;
dbits := 0;
dim := n;
dnext := nil;
end;
DimMake := vdef;
end;
function Idmake(s: cstring; d: datatypes; vdim: varidefp; o: integer): identp;
var id: identp; vdef: varidefp;
begin
id := makeIdent(s);
vdef := newVaridef;
id↑.predefined := vdef;
with vdef↑ do
begin
name := id;
vtype := d;
dtype := vdim;
level := 0;
offset := o;
tbits := 0;
dbits := 0;
next := sysVars;
dnext := nil;
end;
sysVars := vdef; (* add us to list of system variables *)
Idmake := id;
end;
begin (* init1Idents *)
for i := 0 to 26 do idents[i] := nil;
nodim := DimMake('DIMENSIONL'); (* define basic dimension types *)
nodim↑.name↑.name↑.next := newStrng;
nodim↑.name↑.name↑.next↑.ch := 'ESS ';
nodim↑.name↑.length := 13;
angledim := DimMake('ANGLE ');
angledim↑.dim↑.angle := 64; (* really 1, but use 64 so sqrt has a chance *)
distancedim := DimMake('DISTANCE ');
distancedim↑.dim↑.distance := 64;
timedim := DimMake('TIME ');
timedim↑.dim↑.time := 64;
forcedim := DimMake('FORCE ');
forcedim↑.dim↑.dforce := 64;
torquedim := DimMake('TORQUE ');
torquedim↑.dim↑.dforce := 64; (* torque = distance * force *)
torquedim↑.dim↑.distance := 64;
veldim := DimMake('VELOCITY ');
veldim↑.dim↑.time := -64; (* velocity = distance / time *)
veldim↑.dim↑.distance := 64;
angveldim := DimMake('ANGULAR_VE');
angveldim↑.name↑.name↑.next := newStrng;
angveldim↑.name↑.name↑.next↑.ch := 'LOCITY ';
angveldim↑.name↑.length := 16;
angveldim↑.dim↑.time := -64; (* angular_velocity = angle / time *)
angveldim↑.dim↑.angle := 64;
fvstiffdim := newNode; (* stiffness fv = force / distance *)
with fvstiffdim↑ do
begin
next := nil;
ntype := dimnode;
time := 0;
distance := -64;
angle := 0;
dforce := 64;
end;
mvstiffdim := newNode; (* stiffness mv = torque / angle *)
with mvstiffdim↑ do
begin
next := nil;
ntype := dimnode;
time := 0;
distance := 64;
angle := -64;
dforce := 64;
end;
sysVars := nil; (* declare all the system variables *)
Rstr := newStrng;
Rstr↑.ch := 'R ';
id := Idmake('GARM ',frametype,distancedim,0);
id := Idmake('GARM_ERROR',svaltype,nodim,1);
id := Idmake('GHAND ',svaltype,distancedim,2);
id := Idmake('GHAND_ERRO',svaltype,nodim,3);
id↑.name↑.next := Rstr;
id↑.length := 11;
id := Idmake('RARM ',frametype,distancedim,4);
id := Idmake('RARM_ERROR',svaltype,nodim,5);
id := Idmake('RHAND ',svaltype,distancedim,6);
id := Idmake('RHAND_ERRO',svaltype,nodim,7);
id↑.name↑.next := Rstr;
id↑.length := 11;
id := Idmake('DRIVER ',svaltype,nodim,8); (* same as DRIVER_TURNS *)
id := Idmake('DRIVER_TUR',svaltype,nodim,8); (* same as DRIVER *)
id↑.name↑.next := newStrng;
id↑.name↑.next↑.ch := 'NS ';
id↑.length := 12;
sysVars := sysVars↑.next; (* don't want both in list of sysVars *)
id := Idmake('DRIVER_ERR',svaltype,nodim,9);
id↑.name↑.next := newStrng;
id↑.name↑.next↑.ch := 'OR ';
id↑.length := 12;
id := Idmake('DRIVER_TIP',frametype,distancedim,10);
id := Idmake('DRIVER_GRA',frametype,distancedim,11);
id↑.name↑.next := newStrng;
id↑.name↑.next↑.ch := 'SP ';
id↑.length := 12;
id := Idmake('VISE ',svaltype,distancedim,12);
id := Idmake('VISE_ERROR',svaltype,nodim,13);
id := Idmake('FIXED_JAW ',frametype,distancedim,14);
id := Idmake('MOVING_JAW',frametype,distancedim,15);
id := Idmake('SPEED_FACT',svaltype,nodim,16);
id↑.name↑.next := newStrng;
id↑.name↑.next↑.ch := 'OR ';
id↑.length := 12;
v := sysVars; (* reverse the list so it's in the right order *)
while v <> nil do
begin
vp := v↑.next;
if vp <> nil then vp↑.dnext := v (* set up a back pointer for next step *)
else sysVars := v;
v↑.next := v↑.dnext; (* use back pointer to reverse list *)
v↑.dnext := nil;
v := vp;
end;
end;