Hi,

The long story short:
* EXCEPTION_LEX_NOT_FOUND is not picked up correctly from the include file
* The return continuation of the exception does not save registers,
  since $P1 (mapped to P16 by imcc) is messed up by $P2 (also mapped to
  P16).
* I would really like the name of the missing lexical in a field
  "_lexical" of the exception hash.

What am I missing?

The short story long:

I am experimenting with find_lex and the exception is throws as of
yesterday (LEX_NOT_FOUND). I use the test program below. When I run
this, the exception is thrown but the handler complains that the
exception object is of the wrong type.

$ ../parrot-head/parrot/parrot test8.pir 
Exception object is of the wrong type!

When I zap the EXCEPTION_LEX_NOT_FOUND to the fixed constant 4 it works,
but then I get:

$ ../parrot-head/parrot/parrot test8.pir 
Hello from handler!, message is Lexical 'n' not found
get_string() not implemented in class 'Continuation'

which is caused by the "print $P1" in sub "_print_n". It turns out that
both $P1 in "_print_n" and "$P2" in "_handler" map to P16. Thus the
return invocation from the exception handler does not restore the
registers. I thought (hoped, prayed) it would. Am I missing something?

Furthermore, I would really (really) like the name of the lexical that
caused the exception as a field in the exception PMC (e.g. "_lexical").

++Jos.nl

------------------------------------------------------------------------
.include "../parrot-head/parrot/runtime/parrot/include/except_types.pasm"

.sub    _main
        new_pad 0
        call _print_n
        end
.end

.sub    _print_n
        saveall
        newsub $P2, .Exception_Handler, _handler
        set_eh $P2
        find_lex $P1, "n"
        clear_eh
        defined $I0,$P1
        eq $I0,0,_noprint
        print $P1
        print "\n"
_noprint:
        restoreall
        ret
.end

.sub    _handler
        set $I0, P5["_type"]
        ne $I0, EXCEPTION_LEX_NOT_FOUND, _wrongtype
        print "Hello from handler!, message is "
        set $S0, P5["_message"]
        print $S0
        print "\n"
        set $P2, P5["_invoke_cc"]    # the return continuation
        invoke $P2

_wrongtype:
        print "Exception object is of the wrong type!\n"
        end
.end
------------------------------------------------------------------------


-- 
ek is so lug jy vlieg deur my
sonder jou is ek sonder patroon
   "Breyten Breytenbach"

Reply via email to