Luke Palmer wrote:
On a semi-related note, can I get a classoffset without doing a hash lookup? That is, can I store the class number I get assigned somewhere for quick fetching?
It *could* be something like the example below. But that doesn't work yet. Currently subroutines denoted with @IMMEDIATE are run, after the whole source files was parsed and that one sub got compiled.
The question is, if the sub should already be run, when the subroutine is parsed. If yes, the example code would run, if the whole parser/lexer thingy were reentrant.
The code just compiles the enum type constant, classoffsets could just follow that scheme.
leo
# doesn't work yet .sub first @IMMEDIATE, @ANON .local pmc T T = newclass "Test" addattribute T, "a" addattribute T, "b" $I0 = find_type "Test" .local pmc comp comp = compreg "PIR" $S0 = ".const int T_TYPE = " $S1 = $I0 $S0 .= $S1 $S0 .= "\n" ## print $S0 $P0 = compile comp, $S0 .end .sub _main @MAIN .local pmc t t = new T_TYPE print t .end
.namespace ["Test"] .sub __get_string .return ("ok\n") .end