Add support for primitive->string, compound->string and macro->string,
thanks to Derek Peschel <dpeschel@eskimo.com>. Patch slightly reworked. git-svn-id: svn://svn.zoy.org/elk/trunk@277 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
parent
66a624fb53
commit
8797e16d7b
|
@ -366,8 +366,11 @@ extern Object P_Macro (Object);
|
||||||
extern Object P_Macro_Body (Object);
|
extern Object P_Macro_Body (Object);
|
||||||
extern Object P_Macro_Expand (Object);
|
extern Object P_Macro_Expand (Object);
|
||||||
extern Object P_Primitivep (Object);
|
extern Object P_Primitivep (Object);
|
||||||
|
extern Object P_Primitive_To_String (Object);
|
||||||
extern Object P_Compoundp (Object);
|
extern Object P_Compoundp (Object);
|
||||||
|
extern Object P_Compound_To_String (Object);
|
||||||
extern Object P_Macrop (Object);
|
extern Object P_Macrop (Object);
|
||||||
|
extern Object P_Macro_To_String (Object);
|
||||||
extern void Check_Procedure (Object);
|
extern void Check_Procedure (Object);
|
||||||
|
|
||||||
/* Delay and force
|
/* Delay and force
|
||||||
|
|
|
@ -301,8 +301,13 @@ struct Prim_Init {
|
||||||
*/
|
*/
|
||||||
{ P_Procedurep, "procedure?", 1, 1, EVAL },
|
{ P_Procedurep, "procedure?", 1, 1, EVAL },
|
||||||
{ P_Primitivep, "primitive?", 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_Compoundp, "compound?", 1, 1, EVAL },
|
||||||
|
{ P_Compound_To_String,
|
||||||
|
"compound->string", 1, 1, EVAL },
|
||||||
{ P_Macrop, "macro?", 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_Eval, "eval", 1, 2, VARARGS },
|
||||||
{ P_Apply, "apply", 2, MANY, VARARGS },
|
{ P_Apply, "apply", 2, MANY, VARARGS },
|
||||||
{ P_Lambda, "lambda", 2, MANY, NOEVAL },
|
{ P_Lambda, "lambda", 2, MANY, NOEVAL },
|
||||||
|
|
25
src/proc.c
25
src/proc.c
|
@ -100,14 +100,39 @@ Object P_Primitivep (Object x) {
|
||||||
return TYPE(x) == T_Primitive ? True : False;
|
return TYPE(x) == T_Primitive ? True : False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
Object P_Compoundp (Object x) {
|
||||||
return TYPE(x) == T_Compound ? True : False;
|
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) {
|
Object P_Macrop (Object x) {
|
||||||
return TYPE(x) == T_Macro ? True : False;
|
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 Make_Compound () {
|
||||||
Object proc;
|
Object proc;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue