So I did it. Check in the first version of eval.

First of all, I changed pdd06_pasm, the compile and compreg opcodes
didn't fit really well into - well - my scheme of objects.

A compiler is now a Parrot class, derived from NCI, living in
interpreter->Parrot_compreg_hash. This also needed a change to the NCI
code. Parrot_new_nci() is gone, the way to go now is: create a new
NCI/Compiler object and then call its set_string_keyed() method to set
the start address and the signature.

This is somewhat hackish but consistent with Sub.pmc's set_integer()
call to set the address of a parrot sub.
Please, have a look at the changes in core.ops and interpreter.c for the
construction of these objects. A parrot interpreter class would fit
in this scheme too - and it allows for early anchoring the PMC.

The return value of a compile call is currently - due to the lack of
byte code segments - a plain pointer to the generated code. For
PDB_compile() this is a static variable space, meaning: you should
invoke this code before compiling new one. For imcc the code gets
appended to the code->byte_code of the interpreter, which might cause
reallocation and segfaults, when returning from the evaled code.

So this code is not really usable until multiple code segments are
done too.

Test status:
make test succeeds, as well as -P, running the eval progs with JIT or
with -t (trace)/-b (bounds) option fails, probably related to messing
with the byte code.

Imcc notes:
As the evaled code runs in its own runloop it must be terminated with
an 'end' opcode. Imcc could provide one if needed.

Missing and left for an exercise for Joe Other Parrothacker:
build_nativecall.pl lacks to handle an 'I' signature type, the
interpreter should be pushed on the stack. Also the signature "pIt" is
missing. So eval runs only on jit/i386 now.

Finally:
please do a "make realclean" after checkout.

Have fun
leo

PS diffstat:
MANIFEST | 2
classes/csub.pmc | 2
classes/default.pmc | 19 -
classes/nci.pmc | 30 --
classes/sub.pmc | 5
core.ops | 35 ++
debug.c | 22 +
docs/pdds/pdd06_pasm.pod | 18 +
dod.c | 2
include/parrot/debug.h | 1
include/parrot/interpreter.h | 2
include/parrot/method_util.h | 1
interpreter.c | 40 +++
jit/i386/jit_emit.h | 3
languages/imcc/imcc.l | 7
languages/imcc/imclexer.c | 421 ++++++++++++++++-----------------
languages/imcc/main.c | 2
languages/imcc/parser.h | 3
languages/imcc/parser_util.c | 75 +++++
languages/imcc/pbc.c | 17 -
method_util.c | 18 -
parrot-leo/languages/imcc/t/syn/eval.t | 39 +++
parrot-leo/t/pmc/eval.t | 42 +++
23 files changed, 521 insertions(+), 285 deletions(-)

Reply via email to