version 1.31, 2004/02/09 08:23:30 |
version 1.42, 2005/09/13 06:54:22 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/eval.c,v 1.30 2003/11/08 01:12:03 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/eval.c,v 1.41 2005/09/13 06:40:46 noro Exp $ |
*/ |
*/ |
#include <ctype.h> |
#include <ctype.h> |
#include "ca.h" |
#include "ca.h" |
Line 71 pointer eval(FNODE f) |
|
Line 71 pointer eval(FNODE f) |
|
STRING str; |
STRING str; |
pointer val = 0; |
pointer val = 0; |
pointer a,a1,a2; |
pointer a,a1,a2; |
NODE tn,ind; |
NODE tn,ind,match; |
R u; |
R u; |
DP dp; |
DP dp; |
unsigned int pv; |
unsigned int pv; |
int c; |
int c,ret; |
FNODE f1; |
FNODE f1; |
UP2 up2; |
UP2 up2; |
UP up; |
UP up; |
Line 85 pointer eval(FNODE f) |
|
Line 85 pointer eval(FNODE f) |
|
GFPN gfpn; |
GFPN gfpn; |
GFSN gfsn; |
GFSN gfsn; |
RANGE range; |
RANGE range; |
|
QUOTE expr,pattern; |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) |
if ( recv_intr ) { |
if ( recv_intr ) { |
Line 223 pointer eval(FNODE f) |
|
Line 224 pointer eval(FNODE f) |
|
error("-- : not implemented yet"); |
error("-- : not implemented yet"); |
break; |
break; |
case I_PVAR: |
case I_PVAR: |
pv = (unsigned int)FA0(f); ind = (NODE)FA1(f); GETPV(pv,a); |
pv = (unsigned int)FA0(f); |
|
ind = (NODE)FA1(f); |
|
GETPV(pv,a); |
if ( !ind ) |
if ( !ind ) |
val = a; |
val = a; |
else { |
else { |
Line 306 pointer eval(FNODE f) |
|
Line 309 pointer eval(FNODE f) |
|
MKLIST(t,NEXT(BDY((LIST)a))); val = (pointer)t; |
MKLIST(t,NEXT(BDY((LIST)a))); val = (pointer)t; |
} |
} |
break; |
break; |
case I_PROC: |
|
val = (pointer)FA0(f); break; |
|
case I_INDEX: |
case I_INDEX: |
a = eval((FNODE)FA0(f)); ind = (NODE)FA1(f); |
a = eval((FNODE)FA0(f)); ind = (NODE)FA1(f); |
evalnodebody(ind,&tn); getarray(a,tn,&val); |
evalnodebody(ind,&tn); getarray(a,tn,&val); |
Line 430 pointer evalstat(SNODE f) |
|
Line 431 pointer evalstat(SNODE f) |
|
break; |
break; |
} |
} |
f_break = 0; break; |
f_break = 0; break; |
|
case S_MODULE: |
|
CUR_MODULE = (MODULE)FA0(f); |
|
if ( CUR_MODULE ) |
|
MPVS = CUR_MODULE->pvs; |
|
else |
|
MPVS = 0; |
|
break; |
default: |
default: |
error("evalstat : unknown id"); |
error("evalstat : unknown id"); |
break; |
break; |
Line 454 extern NODE PVSS; |
|
Line 462 extern NODE PVSS; |
|
pointer evalf(FUNC f,FNODE a,FNODE opt) |
pointer evalf(FUNC f,FNODE a,FNODE opt) |
{ |
{ |
LIST args; |
LIST args; |
OPTLIST optlist; |
|
pointer val; |
pointer val; |
int i,n,level; |
int i,n,level; |
NODE tn,sn,opts,opt1,dmy; |
NODE tn,sn,opts,opt1,dmy; |
Line 467 pointer evalf(FUNC f,FNODE a,FNODE opt) |
|
Line 474 pointer evalf(FUNC f,FNODE a,FNODE opt) |
|
sprintf(errbuf,"evalf : %s undefined",NAME(f)); |
sprintf(errbuf,"evalf : %s undefined",NAME(f)); |
error(errbuf); |
error(errbuf); |
} |
} |
|
if ( getsecuremode() && !PVSS && !f->secure ) { |
|
sprintf(errbuf,"evalf : %s not permitted",NAME(f)); |
|
error(errbuf); |
|
} |
if ( f->id != A_PARI ) { |
if ( f->id != A_PARI ) { |
for ( i = 0, tn = a?(NODE)FA0(a):0; tn; i++, tn = NEXT(tn) ); |
for ( i = 0, tn = a?(NODE)FA0(a):0; tn; i++, tn = NEXT(tn) ); |
if ( ((n = f->argc)>= 0 && i != n) || (n < 0 && i > -n) ) { |
if ( ((n = f->argc)>= 0 && i != n) || (n < 0 && i > -n) ) { |
Line 495 pointer evalf(FUNC f,FNODE a,FNODE opt) |
|
Line 506 pointer evalf(FUNC f,FNODE a,FNODE opt) |
|
(*f->f.binf)(&val); |
(*f->f.binf)(&val); |
} else { |
} else { |
args = (LIST)eval(a); |
args = (LIST)eval(a); |
if ( opts ) { |
current_option = opts; |
NEWOPTLIST(optlist); |
|
BDY(optlist) = opts; |
|
appendtonode(BDY(args),(pointer)optlist,&dmy); |
|
} |
|
cur_binf = f; |
cur_binf = f; |
(*f->f.binf)(args?BDY(args):0,&val); |
(*f->f.binf)(args?BDY(args):0,&val); |
} |
} |
Line 694 pointer bevalf(FUNC f,NODE a) |
|
Line 701 pointer bevalf(FUNC f,NODE a) |
|
pointer val; |
pointer val; |
int i,n; |
int i,n; |
NODE tn,sn; |
NODE tn,sn; |
VS pvs; |
VS pvs,prev_mpvs; |
char errbuf[BUFSIZ]; |
char errbuf[BUFSIZ]; |
|
|
if ( f->id == A_UNDEF ) { |
if ( f->id == A_UNDEF ) { |
sprintf(errbuf,"bevalf : %s undefined",NAME(f)); |
sprintf(errbuf,"bevalf : %s undefined",NAME(f)); |
error(errbuf); |
error(errbuf); |
} |
} |
|
if ( getsecuremode() && !PVSS && !f->secure ) { |
|
sprintf(errbuf,"bevalf : %s not permitted",NAME(f)); |
|
error(errbuf); |
|
} |
if ( f->id != A_PARI ) { |
if ( f->id != A_PARI ) { |
for ( i = 0, tn = a; tn; i++, tn = NEXT(tn) ); |
for ( i = 0, tn = a; tn; i++, tn = NEXT(tn) ); |
if ( ((n = f->argc)>= 0 && i != n) || (n < 0 && i > -n) ) { |
if ( ((n = f->argc)>= 0 && i != n) || (n < 0 && i > -n) ) { |
Line 742 pointer bevalf(FUNC f,NODE a) |
|
Line 753 pointer bevalf(FUNC f,NODE a) |
|
for ( tn = f->f.usrf->args, sn = a; |
for ( tn = f->f.usrf->args, sn = a; |
sn; tn = NEXT(tn), sn = NEXT(sn) ) |
sn; tn = NEXT(tn), sn = NEXT(sn) ) |
ASSPV((int)FA0((FNODE)BDY(tn)),BDY(sn)); |
ASSPV((int)FA0((FNODE)BDY(tn)),BDY(sn)); |
val = evalstat((SNODE)BDY(f->f.usrf)); |
if ( f->f.usrf->module ) { |
|
prev_mpvs = MPVS; |
|
MPVS = f->f.usrf->module->pvs; |
|
val = evalstat((SNODE)BDY(f->f.usrf)); |
|
MPVS = prev_mpvs; |
|
} else |
|
val = evalstat((SNODE)BDY(f->f.usrf)); |
f_return = f_break = f_continue = 0; poppvs(); |
f_return = f_break = f_continue = 0; poppvs(); |
break; |
break; |
case A_PURE: |
case A_PURE: |
Line 759 pointer bevalf(FUNC f,NODE a) |
|
Line 776 pointer bevalf(FUNC f,NODE a) |
|
pointer evalif(FNODE f,FNODE a) |
pointer evalif(FNODE f,FNODE a) |
{ |
{ |
Obj g; |
Obj g; |
|
FNODE t; |
|
|
g = (Obj)eval(f); |
g = (Obj)eval(f); |
if ( g && (OID(g) == O_P) && (VR((P)g)->attr == (pointer)V_SR) ) |
if ( g && (OID(g) == O_P) && (VR((P)g)->attr == (pointer)V_SR) ) |
return evalf((FUNC)VR((P)g)->priv,a,0); |
return evalf((FUNC)VR((P)g)->priv,a,0); |
else { |
else if ( g && OID(g) == O_QUOTEARG && ((QUOTEARG)g)->type == A_func ) { |
|
t = mkfnode(2,I_FUNC,((QUOTEARG)g)->body,a); |
|
return eval(t); |
|
} else { |
error("invalid function pointer"); |
error("invalid function pointer"); |
/* NOTREACHED */ |
/* NOTREACHED */ |
return (pointer)-1; |
return (pointer)-1; |
Line 871 void gen_searchf(char *name,FUNC *r) |
|
Line 892 void gen_searchf(char *name,FUNC *r) |
|
*r = val; |
*r = val; |
} |
} |
|
|
|
void gen_searchf_searchonly(char *name,FUNC *r) |
|
{ |
|
FUNC val = 0; |
|
int global = 0; |
|
if ( *name == ':' ) { |
|
global = 1; |
|
name += 2; |
|
} |
|
if ( CUR_MODULE && !global ) |
|
searchf(CUR_MODULE->usrf_list,name,&val); |
|
if ( !val ) |
|
searchf(sysf,name,&val); |
|
if ( !val ) |
|
searchf(ubinf,name,&val); |
|
if ( !val ) |
|
searchpf(name,&val); |
|
if ( !val ) |
|
searchuf(name,&val); |
|
*r = val; |
|
} |
|
|
void searchf(NODE fn,char *name,FUNC *r) |
void searchf(NODE fn,char *name,FUNC *r) |
{ |
{ |
NODE tn; |
NODE tn; |
Line 966 void mkuf(char *name,char *fname,NODE args,SNODE body, |
|
Line 1008 void mkuf(char *name,char *fname,NODE args,SNODE body, |
|
char *longname; |
char *longname; |
int argc; |
int argc; |
|
|
|
if ( getsecuremode() ) { |
|
error("defining function is not permitted in the secure mode"); |
|
} |
if ( *name == ':' ) |
if ( *name == ':' ) |
name += 2; |
name += 2; |
if ( !module ) { |
if ( !module ) { |