some changes to make smaller
This commit is contained in:
parent
dd2cf6bbaa
commit
ed2d6ab75b
6 changed files with 184 additions and 144 deletions
|
@ -332,27 +332,29 @@ cstset(expp)
|
|||
}
|
||||
expp->nd_class = Value;
|
||||
expp->nd_symb = INTEGER;
|
||||
if (expp->nd_left->nd_set) {
|
||||
free((char *) expp->nd_left->nd_set);
|
||||
}
|
||||
if (expp->nd_right->nd_set) {
|
||||
free((char *) expp->nd_right->nd_set);
|
||||
}
|
||||
FreeNode(expp->nd_left);
|
||||
FreeNode(expp->nd_right);
|
||||
expp->nd_left = expp->nd_right = 0;
|
||||
freesets(expp);
|
||||
return;
|
||||
default:
|
||||
crash("(cstset)");
|
||||
}
|
||||
if (expp->nd_right->nd_set) {
|
||||
free((char *) expp->nd_right->nd_set);
|
||||
}
|
||||
if (expp->nd_left->nd_set) {
|
||||
free((char *) expp->nd_left->nd_set);
|
||||
}
|
||||
freesets(expp);
|
||||
expp->nd_class = Set;
|
||||
expp->nd_set = resultset;
|
||||
return;
|
||||
}
|
||||
FreeNode(expp->nd_left);
|
||||
FreeNode(expp->nd_right);
|
||||
expp->nd_left = expp->nd_right = 0;
|
||||
}
|
||||
|
||||
freesets(expp)
|
||||
register struct node *expp;
|
||||
{
|
||||
if (expp->nd_right->nd_set) {
|
||||
free((char *) expp->nd_right->nd_set);
|
||||
}
|
||||
if (expp->nd_left->nd_set) {
|
||||
free((char *) expp->nd_left->nd_set);
|
||||
}
|
||||
FreeNode(expp->nd_left);
|
||||
FreeNode(expp->nd_right);
|
||||
|
|
|
@ -33,6 +33,45 @@
|
|||
extern int proclevel;
|
||||
struct desig InitDesig = {DSG_INIT, 0, 0};
|
||||
|
||||
int C_ste_dnam(), C_sde_dnam(), C_loe_dnam(), C_lde_dnam();
|
||||
int C_stl(), C_sdl(), C_lol(), C_ldl();
|
||||
|
||||
#define WRD 0
|
||||
#define DWRD 1
|
||||
#define LD 0
|
||||
#define STR 1
|
||||
|
||||
static int (*lcl_ld_and_str[2][2])() = {
|
||||
{ C_lol, C_stl },
|
||||
{ C_ldl, C_sdl }
|
||||
};
|
||||
|
||||
static int (*ext_ld_and_str[2][2])() = {
|
||||
{ C_loe_dnam, C_ste_dnam },
|
||||
{ C_lde_dnam, C_sde_dnam }
|
||||
};
|
||||
|
||||
int
|
||||
DoLoadOrStore(ds, size, LoadOrStoreFlag)
|
||||
register struct desig *ds;
|
||||
{
|
||||
int sz;
|
||||
|
||||
if (ds->dsg_offset % word_size != 0) return 0;
|
||||
|
||||
if (size == word_size) sz = WRD;
|
||||
else if (size == dword_size) sz = DWRD;
|
||||
else return 0;
|
||||
|
||||
if (ds->dsg_name) {
|
||||
(*(ext_ld_and_str[sz][LoadOrStoreFlag]))(ds->dsg_name, ds->dsg_offset);
|
||||
}
|
||||
else {
|
||||
(*(lcl_ld_and_str[sz][LoadOrStoreFlag]))(ds->dsg_offset);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
STATIC int
|
||||
properly(ds, size, al)
|
||||
register struct desig *ds;
|
||||
|
@ -73,23 +112,7 @@ CodeValue(ds, size, al)
|
|||
break;
|
||||
|
||||
case DSG_FIXED:
|
||||
if (ds->dsg_offset % word_size == 0) {
|
||||
if (size == word_size) {
|
||||
if (ds->dsg_name) {
|
||||
C_loe_dnam(ds->dsg_name,ds->dsg_offset);
|
||||
}
|
||||
else C_lol(ds->dsg_offset);
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == dword_size) {
|
||||
if (ds->dsg_name) {
|
||||
C_lde_dnam(ds->dsg_name,ds->dsg_offset);
|
||||
}
|
||||
else C_ldl(ds->dsg_offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (DoLoadOrStore(ds, size, LD)) break;
|
||||
/* Fall through */
|
||||
case DSG_PLOADED:
|
||||
case DSG_PFIXED:
|
||||
|
@ -138,23 +161,7 @@ CodeStore(ds, size, al)
|
|||
save = *ds;
|
||||
switch(ds->dsg_kind) {
|
||||
case DSG_FIXED:
|
||||
if (ds->dsg_offset % word_size == 0) {
|
||||
if (size == word_size) {
|
||||
if (ds->dsg_name) {
|
||||
C_ste_dnam(ds->dsg_name,ds->dsg_offset);
|
||||
}
|
||||
else C_stl(ds->dsg_offset);
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == dword_size) {
|
||||
if (ds->dsg_name) {
|
||||
C_sde_dnam(ds->dsg_name,ds->dsg_offset);
|
||||
}
|
||||
else C_sdl(ds->dsg_offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (DoLoadOrStore(ds, size, STR)) break;
|
||||
/* Fall through */
|
||||
case DSG_PLOADED:
|
||||
case DSG_PFIXED:
|
||||
|
@ -343,11 +350,7 @@ CodeAddress(ds)
|
|||
break;
|
||||
|
||||
case DSG_PFIXED:
|
||||
if (ds->dsg_name) {
|
||||
C_loe_dnam(ds->dsg_name,ds->dsg_offset);
|
||||
break;
|
||||
}
|
||||
C_lol(ds->dsg_offset);
|
||||
DoLoadOrStore(ds, word_size, LD);
|
||||
break;
|
||||
|
||||
case DSG_INDEXED:
|
||||
|
|
|
@ -43,6 +43,17 @@ Enter(name, kind, type, pnam)
|
|||
return df;
|
||||
}
|
||||
|
||||
EnterType(name, type)
|
||||
char *name;
|
||||
struct type *type;
|
||||
{
|
||||
/* Enter a type definition for "name" and type
|
||||
"type" in the Current Scope.
|
||||
*/
|
||||
|
||||
Enter(name, D_TYPE, type, 0);
|
||||
}
|
||||
|
||||
EnterEnumList(Idlist, type)
|
||||
struct node *Idlist;
|
||||
register struct type *type;
|
||||
|
|
|
@ -148,49 +148,58 @@ LexScan()
|
|||
}
|
||||
#endif
|
||||
|
||||
static struct stdproc {
|
||||
char *st_nam;
|
||||
int st_con;
|
||||
} stdproc[] = {
|
||||
{ "ABS", S_ABS },
|
||||
{ "CAP", S_CAP },
|
||||
{ "CHR", S_CHR },
|
||||
{ "FLOAT", S_FLOAT },
|
||||
{ "HIGH", S_HIGH },
|
||||
{ "HALT", S_HALT },
|
||||
{ "EXCL", S_EXCL },
|
||||
{ "DEC", S_DEC },
|
||||
{ "INC", S_INC },
|
||||
{ "VAL", S_VAL },
|
||||
{ "NEW", S_NEW },
|
||||
{ "DISPOSE", S_DISPOSE },
|
||||
{ "TRUNC", S_TRUNC },
|
||||
{ "SIZE", S_SIZE },
|
||||
{ "ORD", S_ORD },
|
||||
{ "ODD", S_ODD },
|
||||
{ "MAX", S_MAX },
|
||||
{ "MIN", S_MIN },
|
||||
{ "INCL", S_INCL },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
extern struct def *Enter();
|
||||
|
||||
AddStandards()
|
||||
{
|
||||
register struct def *df;
|
||||
extern struct def *Enter();
|
||||
register struct stdproc *p;
|
||||
static struct node nilnode = { 0, 0, Value, 0, { INTEGER, 0}};
|
||||
|
||||
Enter("ABS", D_PROCEDURE, std_type, S_ABS);
|
||||
Enter("CAP", D_PROCEDURE, std_type, S_CAP);
|
||||
Enter("CHR", D_PROCEDURE, std_type, S_CHR);
|
||||
Enter("FLOAT", D_PROCEDURE, std_type, S_FLOAT);
|
||||
Enter("HIGH", D_PROCEDURE, std_type, S_HIGH);
|
||||
Enter("HALT", D_PROCEDURE, std_type, S_HALT);
|
||||
Enter("EXCL", D_PROCEDURE, std_type, S_EXCL);
|
||||
Enter("DEC", D_PROCEDURE, std_type, S_DEC);
|
||||
Enter("INC", D_PROCEDURE, std_type, S_INC);
|
||||
Enter("VAL", D_PROCEDURE, std_type, S_VAL);
|
||||
Enter("NEW", D_PROCEDURE, std_type, S_NEW);
|
||||
Enter("DISPOSE", D_PROCEDURE, std_type, S_DISPOSE);
|
||||
Enter("TRUNC", D_PROCEDURE, std_type, S_TRUNC);
|
||||
Enter("SIZE", D_PROCEDURE, std_type, S_SIZE);
|
||||
Enter("ORD", D_PROCEDURE, std_type, S_ORD);
|
||||
Enter("ODD", D_PROCEDURE, std_type, S_ODD);
|
||||
Enter("MAX", D_PROCEDURE, std_type, S_MAX);
|
||||
Enter("MIN", D_PROCEDURE, std_type, S_MIN);
|
||||
Enter("INCL", D_PROCEDURE, std_type, S_INCL);
|
||||
for (p = stdproc; p->st_nam != 0; p++) {
|
||||
Enter(p->st_nam, D_PROCEDURE, std_type, p->st_con);
|
||||
}
|
||||
|
||||
Enter("CHAR", D_TYPE, char_type, 0);
|
||||
Enter("INTEGER", D_TYPE, int_type, 0);
|
||||
Enter("LONGINT", D_TYPE, longint_type, 0);
|
||||
Enter("REAL", D_TYPE, real_type, 0);
|
||||
Enter("LONGREAL", D_TYPE, longreal_type, 0);
|
||||
Enter("BOOLEAN", D_TYPE, bool_type, 0);
|
||||
Enter("CARDINAL", D_TYPE, card_type, 0);
|
||||
EnterType("CHAR", char_type);
|
||||
EnterType("INTEGER", int_type);
|
||||
EnterType("LONGINT", longint_type);
|
||||
EnterType("REAL", real_type);
|
||||
EnterType("LONGREAL", longreal_type);
|
||||
EnterType("BOOLEAN", bool_type);
|
||||
EnterType("CARDINAL", card_type);
|
||||
df = Enter("NIL", D_CONST, address_type, 0);
|
||||
df->con_const = &nilnode;
|
||||
nilnode.nd_INT = 0;
|
||||
nilnode.nd_type = address_type;
|
||||
|
||||
Enter("PROC",
|
||||
D_TYPE,
|
||||
construct_type(T_PROCEDURE, NULLTYPE),
|
||||
0);
|
||||
df = Enter("BITSET", D_TYPE, bitset_type, 0);
|
||||
EnterType("PROC", construct_type(T_PROCEDURE, NULLTYPE));
|
||||
EnterType("BITSET", bitset_type);
|
||||
df = Enter("TRUE", D_ENUM, bool_type, 0);
|
||||
df->enm_val = 1;
|
||||
df->enm_next = Enter("FALSE", D_ENUM, bool_type, 0);
|
||||
|
@ -206,9 +215,9 @@ do_SYSTEM()
|
|||
static char systemtext[] = SYSTEMTEXT;
|
||||
|
||||
open_scope(CLOSEDSCOPE);
|
||||
Enter("WORD", D_TYPE, word_type, 0);
|
||||
Enter("BYTE", D_TYPE, byte_type, 0);
|
||||
Enter("ADDRESS", D_TYPE, address_type, 0);
|
||||
EnterType("WORD", word_type);
|
||||
EnterType("BYTE", byte_type);
|
||||
EnterType("ADDRESS",address_type);
|
||||
Enter("ADR", D_PROCEDURE, std_type, S_ADR);
|
||||
Enter("TSIZE", D_PROCEDURE, std_type, S_TSIZE);
|
||||
if (!InsertText(systemtext, sizeof(systemtext) - 1)) {
|
||||
|
|
|
@ -141,12 +141,14 @@ DoOption(text)
|
|||
|
||||
case 'V' : /* set object sizes and alignment requirements */
|
||||
{
|
||||
arith size;
|
||||
int align;
|
||||
register arith size;
|
||||
register int align;
|
||||
char c;
|
||||
char *t;
|
||||
|
||||
while (c = *text++) {
|
||||
char *strindex();
|
||||
|
||||
t = text;
|
||||
size = txt2int(&t);
|
||||
align = 0;
|
||||
|
@ -155,44 +157,60 @@ DoOption(text)
|
|||
align = txt2int(&t);
|
||||
text = t;
|
||||
}
|
||||
switch (c) {
|
||||
if (! strindex("wislfdpS", c)) {
|
||||
error("-V: bad type indicator %c\n", c);
|
||||
}
|
||||
if (size != 0) switch (c) {
|
||||
|
||||
case 'w': /* word */
|
||||
if (size != (arith)0) {
|
||||
word_size = size;
|
||||
dword_size = 2 * size;
|
||||
}
|
||||
if (align != 0) word_align = align;
|
||||
word_size = size;
|
||||
dword_size = 2 * size;
|
||||
break;
|
||||
case 'i': /* int */
|
||||
if (size != (arith)0) int_size = size;
|
||||
if (align != 0) int_align = align;
|
||||
int_size = size;
|
||||
break;
|
||||
case 's': /* short (subranges) */
|
||||
if (size != 0) short_size = size;
|
||||
if (align != 0) short_align = align;
|
||||
short_size = size;
|
||||
break;
|
||||
case 'l': /* longint */
|
||||
if (size != (arith)0) long_size = size;
|
||||
if (align != 0) long_align = align;
|
||||
long_size = size;
|
||||
break;
|
||||
case 'f': /* real */
|
||||
if (size != (arith)0) float_size = size;
|
||||
if (align != 0) float_align = align;
|
||||
float_size = size;
|
||||
break;
|
||||
case 'd': /* longreal */
|
||||
if (size != (arith)0) double_size = size;
|
||||
if (align != 0) double_align = align;
|
||||
double_size = size;
|
||||
break;
|
||||
case 'p': /* pointer */
|
||||
if (size != (arith)0) pointer_size = size;
|
||||
if (align != 0) pointer_align = align;
|
||||
pointer_size = size;
|
||||
break;
|
||||
}
|
||||
if (align != 0) switch (c) {
|
||||
|
||||
case 'w': /* word */
|
||||
word_align = align;
|
||||
break;
|
||||
case 'i': /* int */
|
||||
int_align = align;
|
||||
break;
|
||||
case 's': /* short (subranges) */
|
||||
short_align = align;
|
||||
break;
|
||||
case 'l': /* longint */
|
||||
long_align = align;
|
||||
break;
|
||||
case 'f': /* real */
|
||||
float_align = align;
|
||||
break;
|
||||
case 'd': /* longreal */
|
||||
double_align = align;
|
||||
break;
|
||||
case 'p': /* pointer */
|
||||
pointer_align = align;
|
||||
break;
|
||||
case 'S': /* initial record alignment */
|
||||
if (align != (arith)0) struct_align = align;
|
||||
struct_align = align;
|
||||
break;
|
||||
default:
|
||||
error("-V: bad type indicator %c\n", c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -59,64 +59,61 @@ TmpSpace(sz, al)
|
|||
return sc->sc_off;
|
||||
}
|
||||
|
||||
arith
|
||||
NewInt()
|
||||
STATIC arith
|
||||
NewTmp(plist, sz, al, regtype)
|
||||
struct tmpvar **plist;
|
||||
arith sz;
|
||||
{
|
||||
register arith offset;
|
||||
register struct tmpvar *tmp;
|
||||
|
||||
if (!TmpInts) {
|
||||
offset = TmpSpace(int_size, int_align);
|
||||
if (! options['n']) C_ms_reg(offset, int_size, reg_any, 0);
|
||||
if (!*plist) {
|
||||
offset = TmpSpace(sz, al);
|
||||
if (! options['n']) C_ms_reg(offset, sz, regtype, 0);
|
||||
}
|
||||
else {
|
||||
tmp = TmpInts;
|
||||
tmp = *plist;
|
||||
offset = tmp->t_offset;
|
||||
TmpInts = tmp->next;
|
||||
*plist = tmp->next;
|
||||
free_tmpvar(tmp);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
arith
|
||||
NewInt()
|
||||
{
|
||||
return NewTmp(&TmpInts, int_size, int_align, reg_any);
|
||||
}
|
||||
|
||||
arith
|
||||
NewPtr()
|
||||
{
|
||||
register arith offset;
|
||||
register struct tmpvar *tmp;
|
||||
return NewTmp(&TmpPtrs, pointer_size, pointer_align, reg_pointer);
|
||||
}
|
||||
|
||||
if (!TmpPtrs) {
|
||||
offset = TmpSpace(pointer_size, pointer_align);
|
||||
if (! options['n']) C_ms_reg(offset, pointer_size, reg_pointer, 0);
|
||||
}
|
||||
else {
|
||||
tmp = TmpPtrs;
|
||||
offset = tmp->t_offset;
|
||||
TmpPtrs = tmp->next;
|
||||
free_tmpvar(tmp);
|
||||
}
|
||||
return offset;
|
||||
STATIC
|
||||
FreeTmp(plist, off)
|
||||
struct tmpvar **plist;
|
||||
arith off;
|
||||
{
|
||||
register struct tmpvar *tmp = new_tmpvar();
|
||||
|
||||
tmp->next = *plist;
|
||||
tmp->t_offset = off;
|
||||
*plist = tmp;
|
||||
}
|
||||
|
||||
FreeInt(off)
|
||||
arith off;
|
||||
{
|
||||
register struct tmpvar *tmp;
|
||||
|
||||
tmp = new_tmpvar();
|
||||
tmp->next = TmpInts;
|
||||
tmp->t_offset = off;
|
||||
TmpInts = tmp;
|
||||
FreeTmp(&TmpInts, off);
|
||||
}
|
||||
|
||||
FreePtr(off)
|
||||
arith off;
|
||||
{
|
||||
register struct tmpvar *tmp;
|
||||
|
||||
tmp = new_tmpvar();
|
||||
tmp->next = TmpPtrs;
|
||||
tmp->t_offset = off;
|
||||
TmpPtrs = tmp;
|
||||
FreeTmp(&TmpPtrs, off);
|
||||
}
|
||||
|
||||
TmpClose()
|
||||
|
|
Loading…
Reference in a new issue