=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/eval.c,v retrieving revision 1.31 retrieving revision 1.40 diff -u -p -r1.31 -r1.40 --- OpenXM_contrib2/asir2000/parse/eval.c 2004/02/09 08:23:30 1.31 +++ OpenXM_contrib2/asir2000/parse/eval.c 2005/07/27 04:35:11 1.40 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * 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.39 2004/12/18 03:27:17 noro Exp $ */ #include #include "ca.h" @@ -223,7 +223,9 @@ pointer eval(FNODE f) error("-- : not implemented yet"); break; 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 ) val = a; else { @@ -306,8 +308,6 @@ pointer eval(FNODE f) MKLIST(t,NEXT(BDY((LIST)a))); val = (pointer)t; } break; - case I_PROC: - val = (pointer)FA0(f); break; case I_INDEX: a = eval((FNODE)FA0(f)); ind = (NODE)FA1(f); evalnodebody(ind,&tn); getarray(a,tn,&val); @@ -430,6 +430,13 @@ pointer evalstat(SNODE f) 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: error("evalstat : unknown id"); break; @@ -454,7 +461,6 @@ extern NODE PVSS; pointer evalf(FUNC f,FNODE a,FNODE opt) { LIST args; - OPTLIST optlist; pointer val; int i,n,level; NODE tn,sn,opts,opt1,dmy; @@ -467,6 +473,10 @@ pointer evalf(FUNC f,FNODE a,FNODE opt) sprintf(errbuf,"evalf : %s undefined",NAME(f)); error(errbuf); } + if ( getsecuremode() && !PVSS && !f->secure ) { + sprintf(errbuf,"evalf : %s not permitted",NAME(f)); + error(errbuf); + } if ( f->id != A_PARI ) { 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) ) { @@ -495,11 +505,7 @@ pointer evalf(FUNC f,FNODE a,FNODE opt) (*f->f.binf)(&val); } else { args = (LIST)eval(a); - if ( opts ) { - NEWOPTLIST(optlist); - BDY(optlist) = opts; - appendtonode(BDY(args),(pointer)optlist,&dmy); - } + current_option = opts; cur_binf = f; (*f->f.binf)(args?BDY(args):0,&val); } @@ -694,13 +700,17 @@ pointer bevalf(FUNC f,NODE a) pointer val; int i,n; NODE tn,sn; - VS pvs; + VS pvs,prev_mpvs; char errbuf[BUFSIZ]; if ( f->id == A_UNDEF ) { sprintf(errbuf,"bevalf : %s undefined",NAME(f)); error(errbuf); } + if ( getsecuremode() && !PVSS && !f->secure ) { + sprintf(errbuf,"bevalf : %s not permitted",NAME(f)); + error(errbuf); + } if ( f->id != A_PARI ) { for ( i = 0, tn = a; tn; i++, tn = NEXT(tn) ); if ( ((n = f->argc)>= 0 && i != n) || (n < 0 && i > -n) ) { @@ -742,7 +752,13 @@ pointer bevalf(FUNC f,NODE a) for ( tn = f->f.usrf->args, sn = a; sn; tn = NEXT(tn), sn = NEXT(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(); break; case A_PURE: @@ -871,6 +887,27 @@ void gen_searchf(char *name,FUNC *r) *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) { NODE tn; @@ -966,6 +1003,9 @@ void mkuf(char *name,char *fname,NODE args,SNODE body, char *longname; int argc; + if ( getsecuremode() ) { + error("defining function is not permitted in the secure mode"); + } if ( *name == ':' ) name += 2; if ( !module ) {