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

(class parallell_progn): Deleted.

(do_parallell_progn, make_parallell_progn)
(progn_command): Deleted.
(class catch_handler_info): Deleted.
(make_catch_handler_info): Deleted.
(class catch_handler): Deleted.
(do_catch_handler, make_catch_handler): Deleted.
(class catch_apply): Deleted.
(do_catch_apply, make_catch_apply): Deleted.
(class catch_report_apply): Deleted.
(do_catch_report_apply, make_catch_report_apply)
(do_catch_report_collect): Deleted.
(class protect_handler): Deleted.
(do_exc_protect_handler, make_protect_exception_handler)
(protect_command): Deleted.

Rev: src/command.c:1.50.2.4
parent a9bb16e3
......@@ -444,284 +444,3 @@ struct lsh_object *collect_trace(const char *name, struct lsh_object *c)
return &make_trace(name, real)->super;
}
#endif /* DEBUG_TRACE */
/* GABA:
(class
(name parallell_progn)
(super command)
(vars
(body object object_list)))
*/
static void
do_parallell_progn(struct command *s,
struct lsh_object *x,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(parallell_progn, self, s);
unsigned i;
for (i=0; i < LIST_LENGTH(self->body) - 1; i++)
{
CAST_SUBTYPE(command, command, LIST(self->body)[i]);
COMMAND_CALL(command, x, &discard_continuation, e);
}
{
CAST_SUBTYPE(command, command, LIST(self->body)[i]);
COMMAND_CALL(command, x, c, e);
}
}
struct command *make_parallell_progn(struct object_list *body)
{
assert(LIST_LENGTH(body));
{
NEW(parallell_progn, self);
self->body = body;
self->super.call = do_parallell_progn;
return &self->super;
}
}
DEFINE_COMMAND(progn_command)
(struct command *s UNUSED,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{
CAST(object_list, body, a);
COMMAND_RETURN(c, (LIST_LENGTH(body)
? make_parallell_progn(body)
: &command_I));
}
/* Catch command
*
* (catch handler body x)
*
* or
*
* ( (catch handler body) x)
*
* Invokes (body x), with an exception handler that passes exceptions
* of certain types to handler. */
/* GABA:
(class
(name catch_handler_info)
(vars
(mask . uint32_t)
(value . uint32_t)
(ignore_value . int)
; NULL handler means ignore all caught exceptions.
(handler object command)))
*/
struct catch_handler_info *
make_catch_handler_info(uint32_t mask, uint32_t value,
int ignore_value,
struct command *handler)
{
NEW(catch_handler_info, self);
self->mask = mask;
self->value = value;
self->ignore_value = ignore_value;
self->handler = handler;
return self;
}
#if 0
/* ;; GABA:
(class
(name catch_handler)
(super exception_handler)
(vars
(c object command_continuation)
(info object catch_handler_info)))
*/
static void
do_catch_handler(struct exception_handler *s,
const struct exception *e)
{
CAST(catch_handler, self, s);
if ((e->type & self->info->mask) == self->info->value)
{
if (self->info->handler)
COMMAND_CALL(self->info->handler,
e, self->c, self->super.parent);
else
trace("do_catch_handler: Ignoring exception: %z.\n",
e->msg);
}
else
EXCEPTION_RAISE(self->super.parent, e);
}
static struct exception_handler *
make_catch_handler(struct catch_handler_info *info,
struct command_continuation *c,
struct exception_handler *e,
const char *context)
{
NEW(catch_handler, self);
self->super.raise = do_catch_handler;
self->super.parent = e;
self->super.context = context;
self->c = c;
self->info = info;
return &self->super;
}
/* ;; GABA:
(class
(name catch_apply)
(super command)
(vars
(info object catch_handler_info)
(body object command)))
*/
static void
do_catch_apply(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(catch_apply, self, s);
COMMAND_CALL(self->body, a, (self->info->ignore_value
? &discard_continuation
: c),
make_catch_handler(self->info, c, e,
HANDLER_CONTEXT));
}
struct command *
make_catch_apply(struct catch_handler_info *info,
struct command *body)
{
NEW(catch_apply, self);
self->super.call = do_catch_apply;
self->info = info;
self->body = body;
return &self->super;
}
/* Catch and report some exceptions.
*
* FIXME: This duplicates most of the catch command. */
/* ;; GABA:
(class
(name catch_report_apply)
(super command)
(vars
(info const object report_exception_info)
(body object command)))
*/
static void
do_catch_report_apply(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(catch_report_apply, self, s);
COMMAND_CALL(self->body, a, c,
make_report_exception_handler(self->info, e,
HANDLER_CONTEXT));
}
struct command *
make_catch_report_apply(const struct report_exception_info *info,
struct command *body)
{
NEW(catch_report_apply, self);
self->super.call = do_catch_report_apply;
self->info = info;
self->body = body;
return &self->super;
}
void
do_catch_report_collect(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{
CAST(catch_report_collect, self, s);
CAST_SUBTYPE(command, body, a);
COMMAND_RETURN(c,
make_catch_report_apply(self->info, body));
}
#endif
/* Protecting resources.
*
* (protect resource f)
*
* calls (f resource), and if any exception is raised, the resource is
* killed. */
/* GABA:
(class
(name protect_handler)
(super exception_handler)
(vars
(resource object resource)
(parent object exception_handler)))
*/
static void
do_exc_protect_handler(struct exception_handler *s,
const struct exception *e)
{
CAST(protect_handler, self, s);
KILL_RESOURCE(self->resource);
EXCEPTION_RAISE(self->parent, e);
}
static struct exception_handler *
make_protect_exception_handler(struct resource *resource,
struct exception_handler *e,
const char *context)
{
NEW(protect_handler, self);
self->super.raise = do_exc_protect_handler;
self->super.context = context;
self->parent = e;
self->resource = resource;
return &self->super;
}
DEFINE_COMMAND2(protect_command)
(struct lsh_object *a1,
struct lsh_object *a2,
struct command_continuation *c,
struct exception_handler *e)
{
CAST_SUBTYPE(resource, resource, a1);
CAST_SUBTYPE(command, f, a2);
COMMAND_CALL(f, a1, c,
make_protect_exception_handler(resource, e, HANDLER_CONTEXT));
}
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