Leopold Toetsch (via RT) wrote:

# New Ticket Created by Leopold Toetsch # Please include the string: [perl #20315]
# in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20315 >


Attached is a first try towards eval.

I have now eval/compile also running inside imcc. There are two registered compregs: "PASM" and "PIR" aka .imc, e.g.

set S0, 'set S1, "42\n"'
concat S0, "\n"
concat S0, "print S1\nend\n"
compile P1, S0, "PASM"
print "\n"
end

I still would like to have some design advice.

1)
The call function to the compiler/assembler is kept as a NCI. Better would be a subclass of NCI (Compiler.pmc or so), which provides

invoke_keyed(key, next)

This would look up the compreg "key" and prepare the registers for calling the compiler function.

I think such a vtable method would also be handy for the OO stuff:

callmethod P1, "foo"

which would translate too a invoke_keyed() on the object. For methods known at compile time, the HL could spit out

callmethod P1, n

which would then be invoke_keyed_int().

2) The return value of the compile ops should be a pointer to a bytecode segment, already in the interpreter and ready for calling.
So how should a "code_segment_PMC" look like and how should the structure in the packfile be defined?
Just an array of code pointers containing byte_code and byte_code_size?
The code_segment_PMC would probably be a [subclass of]? Sub.pmc, which can then be invoked for actually evalling the code.

Comments welcome,
leo



Reply via email to