=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/strobj.c,v retrieving revision 1.56 retrieving revision 1.63 diff -u -p -r1.56 -r1.63 --- OpenXM_contrib2/asir2000/builtin/strobj.c 2005/09/13 06:40:45 1.56 +++ OpenXM_contrib2/asir2000/builtin/strobj.c 2005/09/28 08:08:34 1.63 @@ -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/builtin/strobj.c,v 1.55 2005/07/26 01:33:46 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.62 2005/09/27 09:32:22 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -78,7 +78,9 @@ void Pquotetotex(); void Pquotetotex_env(); void Pflatten_quote(); void Pquote_to_funargs(),Pfunargs_to_quote(),Pget_function_name(); -void Pquote_unify(); +void Pquote_unify(),Pget_quote_id(); +void Pquote_bin_to_nary(),Pquote_nary_to_bin(); +void do_assign(NODE arg); void fnodetotex_tb(FNODE f,TB tb); char *symbol_name(char *name); char *conv_rule(char *name); @@ -104,6 +106,9 @@ struct ftab str_tab[] = { {"clear_tb",Pclear_tb,1}, {"tb_to_string",Ptb_to_string,1}, {"string_to_tb",Pstring_to_tb,1}, + {"get_quote_id",Pget_quote_id,1}, + {"quote_bin_to_nary",Pquote_bin_to_nary,1}, + {"quote_nary_to_bin",Pquote_nary_to_bin,2}, {"quotetotex_tb",Pquotetotex_tb,2}, {"quotetotex",Pquotetotex,1}, {"quotetotex_env",Pquotetotex_env,-99999999}, @@ -507,15 +512,45 @@ void Pwrite_to_tb(NODE arg,Q *rp) *rp = 0; } -void Pquote_unify(NODE arg,LIST *rp) +FNODE partial_eval(FNODE), quote_bin_to_nary(FNODE), quote_nary_to_bin(FNODE,int); + +void Pquote_bin_to_nary(NODE arg,QUOTE *rp) { + FNODE f; + + f = quote_bin_to_nary(BDY((QUOTE)ARG0(arg))); + MKQUOTE(*rp,f); +} + +void Pquote_nary_to_bin(NODE arg,QUOTE *rp) +{ + FNODE f; + int direction; + + direction = QTOS((Q)ARG1(arg)); + f = quote_nary_to_bin(BDY((QUOTE)ARG0(arg)),direction); + + MKQUOTE(*rp,f); +} + +void Pquote_unify(NODE arg,Q *rp) +{ + FNODE f,g; + QUOTE q; NODE r; int ret; +#if 0 + g = partial_eval(BDY(((QUOTE)ARG0(arg)))); + MKQUOTE(q,g); + ret = quote_unify((Obj)q,(Obj)ARG1(arg),&r); +#else ret = quote_unify((Obj)ARG0(arg),(Obj)ARG1(arg),&r); - if ( ret ) - MKLIST(*rp,r); - else +#endif + if ( ret ) { + do_assign(r); + *rp = ONE; + } else *rp = 0; } @@ -1510,6 +1545,18 @@ void Pflatten_quote(NODE arg,Obj *rp) MKQUOTE(q,f); *rp = (Obj)q; } +} + +void Pget_quote_id(NODE arg,Q *rp) +{ + FNODE f; + QUOTE q; + + q = (QUOTE)ARG0(arg); + if ( !q || OID(q) != O_QUOTE ) + error("get_quote_id : invalid argument"); + f = BDY(q); + STOQ((int)f->id,*rp); } void Pquote_to_funargs(NODE arg,LIST *rp)