From ca0ca229837e344df05bfa79333b1ed4993f9719 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 1 Oct 2015 06:58:23 -0700 Subject: Allow super to take an instance as an argument. * struct.c (super): Detect structure instance and resolve it to its type. Recursion eliminated in favor of imperative approach that eliminates redundant checks. * txr.1: Description of super updated. --- struct.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index 9de7d0c5..054b5f09 100644 --- a/struct.c +++ b/struct.c @@ -263,8 +263,12 @@ val super(val type) val stype = find_struct_type(type); if (!stype) no_such_struct(lit("super"), type); - return super(stype); - } else { + type = stype; + } else if (structp(type)) { + type = struct_type(type); + } + + { struct struct_type *st = coerce(struct struct_type *, cobj_handle(type, struct_type_s)); return st->super; -- cgit v1.2.3