1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-20 17:47:48 +00:00

Cleanup EVAL macro definition (#334)

Reformat and make use of PTRMASK & swapx() as appropriate.
It's likely that nnewframe() could be reworked to avoid needing
to unconditionally swapx() the result and, like native_newframe()
return the appropriate value as the result.
This commit is contained in:
Nick Briggs 2021-02-04 16:20:26 -08:00 committed by GitHub
parent f0a53302ce
commit 9957f5c305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -545,110 +545,89 @@ op_fn_common: \
/****** EVAL ********/
/****************************************************************/
#ifndef BIGATOMS
#define EVAL \
{ \
LispPTR scratch; \
register LispPTR work; \
register LispPTR lookuped; /* keep looked up value */ \
\
switch(TOPOFSTACK & SEGMASK) \
{ \
case S_POSITIVE: \
case S_NEGATIVE: nextop1; \
\
case ATOM_OFFSET: if( (TOPOFSTACK==NIL_PTR) \
||(TOPOFSTACK==ATOM_T)) \
goto Hack_Label; \
nnewframe(CURRENTFX,&scratch, \
TOPOFSTACK & 0xffff); \
work = ((scratch & 0xffff0000)>> 16) | \
((scratch & 0x00ff) <<16); \
lookuped = *((LispPTR *) \
(Addr68k_from_LADDR(work))); \
if(lookuped==NOBIND_PTR) goto op_ufn; \
TOPOFSTACK = lookuped; \
Hack_Label: nextop1; \
\
default: switch(GetTypeNumber(TOPOFSTACK)) \
{ \
case TYPE_FIXP : \
case TYPE_FLOATP : \
case TYPE_STRINGP : \
case TYPE_ONED_ARRAY : \
case TYPE_GENERAL_ARRAY : nextop1; \
\
case TYPE_LISTP : \
fn_atom_index = ATOM_EVALFORM; \
fn_num_args = 1; \
fn_opcode_size = 1; \
fn_defcell = (DefCell *) \
GetDEFCELL68k(ATOM_EVALFORM); \
fn_apply = 0; \
goto op_fn_common; \
\
default : goto op_ufn; \
} \
\
} /* end switch */ \
\
}/* EVAL end */
#define EVAL \
{ \
LispPTR scratch, work, lookuped; \
switch (TOPOFSTACK & SEGMASK) { \
case S_POSITIVE: \
case S_NEGATIVE: \
nextop1; \
case ATOM_OFFSET: \
if ((TOPOFSTACK == NIL_PTR) || (TOPOFSTACK == ATOM_T)) \
goto Hack_Label; \
nnewframe(CURRENTFX, &scratch, TOPOFSTACK & 0xffff); \
work = POINTERMASK & swapx(scratch); \
lookuped = *((LispPTR *)(Addr68k_from_LADDR(work))); \
if (lookuped == NOBIND_PTR) \
goto op_ufn; \
TOPOFSTACK = lookuped; \
Hack_Label: \
nextop1; \
default: \
switch (GetTypeNumber(TOPOFSTACK)) { \
case TYPE_FIXP: \
case TYPE_FLOATP: \
case TYPE_STRINGP: \
case TYPE_ONED_ARRAY: \
case TYPE_GENERAL_ARRAY: \
nextop1; \
case TYPE_LISTP: \
fn_atom_index = ATOM_EVALFORM; \
fn_num_args = 1; \
fn_opcode_size = 1; \
fn_defcell = (DefCell *)GetDEFCELL68k(ATOM_EVALFORM); \
fn_apply = 0; \
goto op_fn_common; \
default: \
goto op_ufn; \
} \
} /* end switch */ \
} /* EVAL end */
#else
#define EVAL \
{ \
LispPTR scratch; \
register LispPTR work; \
register LispPTR lookuped; /* keep looked up value */ \
\
switch(TOPOFSTACK & SEGMASK) \
{ \
case S_POSITIVE: \
case S_NEGATIVE: nextop1; \
\
case ATOM_OFFSET: if( (TOPOFSTACK==NIL_PTR) \
||(TOPOFSTACK==ATOM_T)) \
goto Hack_Label; \
nnewframe(CURRENTFX,&scratch, \
TOPOFSTACK & 0xffff); \
work = ((scratch & 0xffff0000)>> 16) | \
((scratch & 0x0fff) <<16); \
lookuped = *((LispPTR *) \
(Addr68k_from_LADDR(work))); \
if(lookuped==NOBIND_PTR) goto op_ufn; \
TOPOFSTACK = lookuped; \
Hack_Label: nextop1; \
\
default: switch(GetTypeNumber(TOPOFSTACK)) \
{ \
case TYPE_FIXP : \
case TYPE_FLOATP : \
case TYPE_STRINGP : \
case TYPE_ONED_ARRAY : \
case TYPE_GENERAL_ARRAY : nextop1; \
\
case TYPE_LISTP : \
fn_atom_index = ATOM_EVALFORM; \
fn_num_args = 1; \
fn_opcode_size = 1; \
fn_defcell = (DefCell *) \
GetDEFCELL68k(ATOM_EVALFORM); \
fn_apply = 0; \
goto op_fn_common; \
\
case TYPE_NEWATOM: \
nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \
work = POINTERMASK & swapx(scratch); \
lookuped = *((LispPTR *) \
(Addr68k_from_LADDR(work))); \
if(lookuped==NOBIND_PTR) goto op_ufn; \
TOPOFSTACK = lookuped; \
nextop1; \
default : goto op_ufn; \
} \
\
} /* end switch */ \
\
}/* EVAL end */
#endif /* BIGATOMS */
#define EVAL \
{ \
LispPTR scratch, work, lookuped; \
switch (TOPOFSTACK & SEGMASK) { \
case S_POSITIVE: \
case S_NEGATIVE: \
nextop1; \
case ATOM_OFFSET: \
if ((TOPOFSTACK == NIL_PTR) || (TOPOFSTACK == ATOM_T)) \
goto Hack_Label; \
nnewframe(CURRENTFX, &scratch, TOPOFSTACK & 0xffff); \
work = POINTERMASK & swapx(scratch); \
lookuped = *((LispPTR *)(Addr68k_from_LADDR(work))); \
if (lookuped == NOBIND_PTR) \
goto op_ufn; \
TOPOFSTACK = lookuped; \
Hack_Label: \
nextop1; \
default: \
switch (GetTypeNumber(TOPOFSTACK)) { \
case TYPE_FIXP: \
case TYPE_FLOATP: \
case TYPE_STRINGP: \
case TYPE_ONED_ARRAY: \
case TYPE_GENERAL_ARRAY: \
nextop1; \
case TYPE_LISTP: \
fn_atom_index = ATOM_EVALFORM; \
fn_num_args = 1; \
fn_opcode_size = 1; \
fn_defcell = (DefCell *)GetDEFCELL68k(ATOM_EVALFORM); \
fn_apply = 0; \
goto op_fn_common; \
case TYPE_NEWATOM: \
nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \
work = POINTERMASK & swapx(scratch); \
lookuped = *((LispPTR *)(Addr68k_from_LADDR(work))); \
if (lookuped == NOBIND_PTR) \
goto op_ufn; \
TOPOFSTACK = lookuped; \
nextop1; \
default: \
goto op_ufn; \
} \
} /* end switch */ \
} /* EVAL end */
#endif