Skip to content

Instantly share code, notes, and snippets.

@atrodo
Created June 10, 2010 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atrodo/433158 to your computer and use it in GitHub Desktop.
Save atrodo/433158 to your computer and use it in GitHub Desktop.
hll := 'nqp';
code := 'Q:PIR { say $S0 };';
sa[ 0] := '.sub "" :anon';
sa[ 1] := ' .param string hll';
sa[ 2] := ' .param string code';
sa[ 3] := ' ';
sa[ 4] := ' $P0 = compreg hll';
sa[ 5] := ' unless_null $P0, compile';
sa[ 6] := ' load_language "nqprx"';
sa[ 7] := ' $P0 = compreg "NQP-rx"';
sa[ 8] := ' compile:';
sa[ 9] := ' $P1 = $P0."compile"(code)';
sa[10] := ' typeof $S2, ccc';
sa[11] := ' say $S2 #say $P1 #trace 1';
sa[12] := ' .return ($P1)';
sa[13] := '.end';
eval := Parrot_compile_string( interp, compiler, PChar(join(sa)), errstr);
// This works, no problem. It returns a NQP-rx compiled eval from code above
Parrot_ext_call(interp, eval, 'SS->P', create_string(hll), create_string(code), @hllcode);
// This prints a blank line, since I have no idea how to retrieve the passed in string from NQP or PIR
Parrot_ext_call(interp, hllcode, 'S->', create_string('Hello World'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment