From: Martin R. <ru...@us...> - 2010-04-26 15:53:27
|
Update of /cvsroot/foo/fooelk/src In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv12614/src Modified Files: prim.c proc.c Log Message: equiv to revision level r277 of original elk: Add support for primitive->string, compound->string and macro->string, thanks to Derek Peschel <dpe...@es...>. Patch slightly reworked. Index: prim.c =================================================================== RCS file: /cvsroot/foo/fooelk/src/prim.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** prim.c 26 Apr 2010 15:41:08 -0000 1.2 --- prim.c 26 Apr 2010 15:53:19 -0000 1.3 *************** *** 302,307 **** --- 302,312 ---- { P_Procedurep, "procedure?", 1, 1, EVAL }, { P_Primitivep, "primitive?", 1, 1, EVAL }, + { P_Primitive_To_String, + "primitive->string", 1, 1, EVAL }, { P_Compoundp, "compound?", 1, 1, EVAL }, + { P_Compound_To_String, + "compound->string", 1, 1, EVAL }, { P_Macrop, "macro?", 1, 1, EVAL }, + { P_Macro_To_String, "macro->string", 1, 1, EVAL }, { P_Eval, "eval", 1, 2, VARARGS }, { P_Apply, "apply", 2, MANY, VARARGS }, Index: proc.c =================================================================== RCS file: /cvsroot/foo/fooelk/src/proc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** proc.c 26 Apr 2010 15:41:08 -0000 1.3 --- proc.c 26 Apr 2010 15:53:19 -0000 1.4 *************** *** 101,112 **** --- 101,137 ---- } + Object P_Primitive_To_String (Object x) { + Check_Type (x, T_Primitive); + return Make_String (PRIM(x)->name, strlen(PRIM(x)->name)); + } + Object P_Compoundp (Object x) { return TYPE(x) == T_Compound ? True : False; } + Object P_Compound_To_String (Object x) { + Check_Type (x, T_Compound); + if (Nullp (COMPOUND(x)->name)) { + static char buf[64]; + sprintf (buf, "#<compound %lu>", POINTER(x)); + return Make_String (buf, strlen(buf)); + } + return COMPOUND(x)->name; + } + Object P_Macrop (Object x) { return TYPE(x) == T_Macro ? True : False; } + Object P_Macro_To_String (Object x) { + Check_Type (x, T_Macro); + if (Nullp (MACRO(x)->name)) { + static char buf[64]; + sprintf (buf, "#<macro %lu>", POINTER(x)); + return Make_String (buf, strlen(buf)); + } + return MACRO(x)->name; + } + Object Make_Compound () { Object proc; |