Commit fae122f7 authored by Niels Möller's avatar Niels Möller
Browse files

Added more GABA_* macros, and made the needed symbols non-static.

Rev: src/combinators.c:1.4
Rev: src/command.h:1.15
parent be4825bc
......@@ -160,9 +160,9 @@ struct command *make_command_S_2(struct command *f,
return &res->super.super;
}
static struct lsh_object *collect_S_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g)
struct lsh_object *collect_S_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
......@@ -177,6 +177,79 @@ STATIC_COLLECT_2_FINAL(collect_S_2);
struct collect_info_1 command_S =
STATIC_COLLECT_1(&collect_info_S_2);
/* S' c f g x == c (f x) (g x) */
/* Represents S' c f g */
/* GABA:
(class
(name command_Sp_3)
(super command_simple)
(vars
(c object command)
(f object command)
(g object command)))
*/
static int do_command_Sp_3(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(command_Sp_3, self, s);
return COMMAND_CALL(self->f, x,
make_apply(self->c,
make_command_S_continuation(self->g,
x, c)));
}
static struct lsh_object *
do_simple_command_Sp_3(struct command_simple *s,
struct lsh_object *x)
{
CAST(command_Sp_3, self, s);
CAST_SUBTYPE(command_simple, cs, self->c);
CAST_SUBTYPE(command_simple, fs, self->f);
CAST_SUBTYPE(command_simple, gs, self->g);
CAST_SUBTYPE(command_simple, op, COMMAND_SIMPLE(cs, COMMAND_SIMPLE(fs, x)));
return COMMAND_SIMPLE(op, COMMAND_SIMPLE(gs, x));
}
struct command *make_command_Sp_3(struct command *c,
struct command *f,
struct command *g)
{
NEW(command_Sp_3, res);
res->c = c;
res->f = f;
res->g = g;
res->super.super.call = do_command_Sp_3;
res->super.call_simple = do_simple_command_Sp_3;
return &res->super.super;
}
struct lsh_object *collect_Sp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cc, c);
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
assert(!info);
return &make_command_Sp_3(cc, cf, cg)->super;
}
struct collect_info_3 collect_info_Sp_3 =
STATIC_COLLECT_3_FINAL(collect_Sp_3);
struct collect_info_2 collect_info_Sp_2 =
STATIC_COLLECT_2(&collect_info_Sp_3);
struct collect_info_1 command_Sp =
STATIC_COLLECT_1(&collect_info_Sp_2);
/* B f g x == f (g x) */
/* Represents (B f g) */
......@@ -207,7 +280,7 @@ do_simple_command_B_2(struct command_simple *s,
return COMMAND_SIMPLE(fs, COMMAND_SIMPLE(gs, x));
}
static struct command *
struct command *
make_command_B_2(struct command *f,
struct command *g)
{
......@@ -220,10 +293,9 @@ make_command_B_2(struct command *f,
return &res->super.super;
}
static struct lsh_object *
collect_B_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g)
struct lsh_object *collect_B_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
......@@ -238,6 +310,79 @@ STATIC_COLLECT_2_FINAL(collect_B_2);
struct collect_info_1 command_B =
STATIC_COLLECT_1(&collect_info_B_2);
/* B' c f g x == c (f (g x)) */
/* Represents (B' c f g) */
/* GABA:
(class
(name command_Bp_3)
(super command_simple)
(vars
(c object command)
(f object command)
(g object command)))
*/
static int do_command_Bp_3(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(command_Bp_3, self, s);
return COMMAND_CALL(self->g, x,
make_apply(self->f,
make_apply(self->c, c)));
}
static struct lsh_object *
do_simple_command_Bp_3(struct command_simple *s,
struct lsh_object *x)
{
CAST(command_Bp_3, self, s);
CAST_SUBTYPE(command_simple, cs, self->c);
CAST_SUBTYPE(command_simple, fs, self->f);
CAST_SUBTYPE(command_simple, gs, self->g);
return COMMAND_SIMPLE(cs, COMMAND_SIMPLE(fs, COMMAND_SIMPLE(gs, x)));
}
struct command *
make_command_Bp_3(struct command *c,
struct command *f,
struct command *g)
{
NEW(command_Bp_3, res);
res->c = c;
res->f = f;
res->g = g;
res->super.super.call = do_command_Bp_3;
res->super.call_simple = do_simple_command_Bp_3;
return &res->super.super;
}
struct lsh_object *collect_Bp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cc, c);
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
assert(!info);
return &make_command_Bp_3(cc, cf, cg)->super;
}
struct collect_info_3 collect_info_Bp_3 =
STATIC_COLLECT_3_FINAL(collect_Bp_3);
struct collect_info_2 collect_info_Bp_2 =
STATIC_COLLECT_2(&collect_info_Bp_3);
struct collect_info_1 command_Bp =
STATIC_COLLECT_1(&collect_info_Bp_2);
/* ((C f) y) x == (f x) y */
/* Represents ((C f) g) */
......@@ -297,7 +442,7 @@ static struct lsh_object *do_simple_command_C_2(struct command_simple *s,
return COMMAND_SIMPLE(v, self->y);
}
static struct command *
struct command *
make_command_C_2(struct command *f,
struct lsh_object *y)
{
......@@ -310,9 +455,9 @@ make_command_C_2(struct command *f,
return &res->super.super;
}
static struct lsh_object *collect_C_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *y)
struct lsh_object *collect_C_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *y)
{
CAST_SUBTYPE(command, cf, f);
assert(!info);
......@@ -326,150 +471,6 @@ STATIC_COLLECT_2_FINAL(collect_C_2);
struct collect_info_1 command_C =
STATIC_COLLECT_1(&collect_info_C_2);
/* S' c f g x == c (f x) (g x) */
/* Represents S c f g */
/* GABA:
(class
(name command_Sp_3)
(super command_simple)
(vars
(c object command)
(f object command)
(g object command)))
*/
static int do_command_Sp_3(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(command_Sp_3, self, s);
return COMMAND_CALL(self->f, x,
make_apply(self->c,
make_command_S_continuation(self->g,
x, c)));
}
static struct lsh_object *
do_simple_command_Sp_3(struct command_simple *s,
struct lsh_object *x)
{
CAST(command_Sp_3, self, s);
CAST_SUBTYPE(command_simple, cs, self->c);
CAST_SUBTYPE(command_simple, fs, self->f);
CAST_SUBTYPE(command_simple, gs, self->g);
CAST_SUBTYPE(command_simple, op, COMMAND_SIMPLE(cs, COMMAND_SIMPLE(fs, x)));
return COMMAND_SIMPLE(op, COMMAND_SIMPLE(gs, x));
}
struct command *make_command_Sp_3(struct command *c,
struct command *f,
struct command *g)
{
NEW(command_Sp_3, res);
res->c = c;
res->f = f;
res->g = g;
res->super.super.call = do_command_Sp_3;
res->super.call_simple = do_simple_command_Sp_3;
return &res->super.super;
}
static struct lsh_object *collect_Sp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cc, c);
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
assert(!info);
return &make_command_Sp_3(cc, cf, cg)->super;
}
struct collect_info_3 collect_info_Sp_3 =
STATIC_COLLECT_3_FINAL(collect_Sp_3);
struct collect_info_2 collect_info_Sp_2 =
STATIC_COLLECT_2(&collect_info_Sp_3);
struct collect_info_1 command_Sp =
STATIC_COLLECT_1(&collect_info_Sp_2);
/* B' c f g x == c (f (g x)) */
/* Represents (B' c f g) */
/* GABA:
(class
(name command_Bp_3)
(super command_simple)
(vars
(c object command)
(f object command)
(g object command)))
*/
static int do_command_Bp_3(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(command_Bp_3, self, s);
return COMMAND_CALL(self->g, x,
make_apply(self->f,
make_apply(self->c, c)));
}
static struct lsh_object *
do_simple_command_Bp_3(struct command_simple *s,
struct lsh_object *x)
{
CAST(command_Bp_3, self, s);
CAST_SUBTYPE(command_simple, cs, self->c);
CAST_SUBTYPE(command_simple, fs, self->f);
CAST_SUBTYPE(command_simple, gs, self->g);
return COMMAND_SIMPLE(cs, COMMAND_SIMPLE(fs, COMMAND_SIMPLE(gs, x)));
}
static struct command *
make_command_Bp_3(struct command *c,
struct command *f,
struct command *g)
{
NEW(command_Bp_3, res);
res->c = c;
res->f = f;
res->g = g;
res->super.super.call = do_command_Bp_3;
res->super.call_simple = do_simple_command_Bp_3;
return &res->super.super;
}
static struct lsh_object *
collect_Bp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g)
{
CAST_SUBTYPE(command, cc, c);
CAST_SUBTYPE(command, cf, f);
CAST_SUBTYPE(command, cg, g);
assert(!info);
return &make_command_Bp_3(cc, cf, cg)->super;
}
struct collect_info_3 collect_info_Bp_3 =
STATIC_COLLECT_3_FINAL(collect_Bp_3);
struct collect_info_2 collect_info_Bp_2 =
STATIC_COLLECT_2(&collect_info_Bp_3);
struct collect_info_1 command_Bp =
STATIC_COLLECT_1(&collect_info_Bp_2);
/* C' c f y x == c (f x) y */
/* Represents (C' c f y x) */
......@@ -505,7 +506,7 @@ do_simple_command_Cp_3(struct command_simple *s,
return COMMAND_SIMPLE(op, self->y);
}
static struct command *
struct command *
make_command_Cp_3(struct command *c,
struct command *f,
struct lsh_object *y)
......@@ -520,7 +521,7 @@ make_command_Cp_3(struct command *c,
return &res->super.super;
}
static struct lsh_object *
struct lsh_object *
collect_Cp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
......@@ -536,9 +537,10 @@ collect_Cp_3(struct collect_info_3 *info,
struct collect_info_3 collect_info_Cp_3 =
STATIC_COLLECT_3_FINAL(collect_Cp_3);
struct collect_info_2 collect_info_Cp_2 =
struct collect_info_2 collect_info_Cp_2 =
STATIC_COLLECT_2(&collect_info_Cp_3);
struct collect_info_1 command_Cp =
STATIC_COLLECT_1(&collect_info_Cp_2);
......@@ -74,31 +74,6 @@ int do_call_simple_command(struct command *s,
#define STATIC_COMMAND_SIMPLE(f) \
{ { STATIC_HEADER, do_call_simple_command }, f}
struct lsh_object *
do_collect_1(struct command_simple *s, struct lsh_object *a);
#define STATIC_COLLECT_1(next) \
{ { { STATIC_HEADER, do_call_simple_command }, do_collect_1}, \
make_collect_state_1, next }
#if 0
#define STATIC_COLLECT_1_FINAL(f) \
{ { { STATIC_HEADER, do_call_simple_command }, do_collect_1}, \
f, NULL }
#endif
#define STATIC_COLLECT_2(next) \
{ STATIC_HEADER, make_collect_state_2, next }
#define STATIC_COLLECT_2_FINAL(f) \
{ STATIC_HEADER, f, NULL }
#define STATIC_COLLECT_3(next) \
{ STATIC_HEADER, make_collect_state_3, next }
#define STATIC_COLLECT_3_FINAL(f) \
{ STATIC_HEADER, f, NULL }
/* GABA:
(class
(name command_frame)
......@@ -154,6 +129,9 @@ do_collect_1(struct command_simple *s, struct lsh_object *a);
(next object collect_info_2)))
*/
struct lsh_object *
do_collect_1(struct command_simple *s, struct lsh_object *a);
struct lsh_object *
make_collect_state_1(struct collect_info_1 *info,
struct lsh_object *a);
......@@ -169,9 +147,27 @@ make_collect_state_3(struct collect_info_3 *info,
struct lsh_object *b,
struct lsh_object *c);
#define STATIC_COLLECT_1(next) \
{ { { STATIC_HEADER, do_call_simple_command }, do_collect_1}, \
make_collect_state_1, next }
#define STATIC_COLLECT_2(next) \
{ STATIC_HEADER, make_collect_state_2, next }
#define STATIC_COLLECT_2_FINAL(f) \
{ STATIC_HEADER, f, NULL }
#define STATIC_COLLECT_3(next) \
{ STATIC_HEADER, make_collect_state_3, next }
#define STATIC_COLLECT_3_FINAL(f) \
{ STATIC_HEADER, f, NULL }
extern struct command_simple command_unimplemented;
#define COMMAND_UNIMPLEMENTED (&command_unimplemented.super.super)
/* The GABA_* macros are used by automatically generated evaluation code */
struct command_continuation *
make_apply(struct command *f, struct command_continuation *c);
struct lsh_object *gaba_apply(struct lsh_object *f,
......@@ -189,19 +185,105 @@ struct command *make_command_K_1(struct lsh_object *x);
#define GABA_VALUE_K (&command_K.super.super)
#define GABA_APPLY_K_1(x) ((struct lsh_object *) make_command_K_1(x))
/* The macros are used by automatically generated evaluation code */
extern struct collect_info_1 command_S;
/* extern struct collect_info_2 collect_info_S_2; */
struct command *make_command_S_2(struct command *f,
struct command *g);
#define GABA_VALUE_S (&command_S.super.super)
#define GABA_APPLY_S_1(f) (make_collect_state_1(&collect_info_S_2, (f)))
#define GABA_APPLY_S_2(f, g) (make_collect_S_2(NULL, (f), (g)))
#define GABA_APPLY_S_1(f) (make_collect_state_1(&command_S, (f)))
#define GABA_APPLY_S_2(f, g) (collect_S_2(NULL, (f), (g)))
extern struct collect_info_1 command_Sp;
extern struct collect_info_2 collect_info_Sp_2;
/* extern struct collect_info_3 collect_info_Sp_3; */
struct command *make_command_Sp_3(struct command *c,
struct command *f,
struct command *g);
struct lsh_object *collect_S_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g);
struct lsh_object *collect_Sp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g);
#define GABA_VALUE_Sp (&command_Sp.super.super)
#define GABA_APPLY_Sp_1(c) (make_collect_state_1(&command_Sp, (c)))
#define GABA_APPLY_Sp_2(c, f) \
(make_collect_state_2(&collect_info_Sp_2, (c), (f)))
#define GABA_APPLY_Sp_3(c, f, g) (collect_Sp_3(NULL, (c), (f), (g)))
extern struct collect_info_1 command_B;
/* extern struct collect_info_2 collect_info_B_2; */
struct command *make_command_B_2(struct command *f,
struct command *g);
struct lsh_object *collect_B_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *g);
#define GABA_VALUE_B (&command_B.super.super)
#define GABA_APPLY_B_1(f) (make_collect_state_1(&command_B, (f)))
#define GABA_APPLY_B_2(f, g) (collect_B_2(NULL, (f), (g)))
extern struct collect_info_1 command_Bp;
extern struct collect_info_2 collect_info_Bp_2;
extern struct collect_info_3 collect_info_Bp_3;
struct command *make_command_Bp_3(struct command *c,
struct command *f,
struct command *g);
struct lsh_object *collect_Bp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *g);
#define GABA_VALUE_Bp (&command_Bp.super.super)
#define GABA_APPLY_Bp_1(c) (make_collect_state_1(&command_Bp, (c)))
#define GABA_APPLY_Bp_2(c, f) \
(make_collect_state_2(&collect_info_Bp_2, (c), (f)))
#define GABA_APPLY_Bp_3(c, f, g) (collect_Bp_3(NULL, (c), (f), (g)))
extern struct collect_info_1 command_C;
/* extern struct collect_info_2 collect_info_C_2; */
struct command *
make_command_C_2(struct command *f,
struct lsh_object *y);
struct lsh_object *
collect_C_2(struct collect_info_2 *info,
struct lsh_object *f,
struct lsh_object *y);
#define GABA_VALUE_C (&command_C.super.super)
#define GABA_APPLY_C_1(f) (make_collect_state_1(&command_C, (f)))
#define GABA_APPLY_C_2(f, y) (collect_C_2(NULL, (f), (y)))
extern struct collect_info_1 command_Cp;
extern struct collect_info_2 collect_info_Cp_2;
/* extern struct collect_info_3 collect_info_Cp_3; */
struct command *
make_command_Cp_3(struct command *c,
struct command *f,
struct lsh_object *y);
struct lsh_object *
collect_Cp_3(struct collect_info_3 *info,
struct lsh_object *c,
struct lsh_object *f,
struct lsh_object *y);
#define GABA_VALUE_Cp (&command_Cp.super.super)
#define GABA_APPLY_Cp_1(c) (make_collect_state_1(&command_Cp, (c)))
#define GABA_APPLY_Cp_2(c, f) \
(make_collect_state_2(&collect_info_Cp_2, (c), (f)))
#define GABA_APPLY_Cp_3(c, f, y) (collect_Cp_3(NULL, (c), (f), (y)))
#if 0
extern struct command_simple command_B;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment