Attached is a small patchlet, that allows the following code to execute:
.pcc_sub _main prototyped .sym PerlUndef a a = new PerlUndef a = 10 + 5 print a .end
And avoids having to instead do:
.pcc_sub _main prototyped .sym PerlUndef a a = new PerlUndef .sym PerlUndef TEMP0 TEMP0 = new PerlUndef TEMP0 = 10 .sym PerlUndef TEMP1 TEMP1 = 5 a = TEMP0 + TEMP1 print a .end
I've just attached the add operation for integers, because I'm not sure if I'm on the right track (ie, how do i cast to float in the case of division, when appropriate).
Anyhow, if anyone has any other ideas on how this should be implemented, please let me know. Otherwise I'll start working on a full patch for math.ops
-Sterling
Index: math.ops =================================================================== RCS file: /cvs/public/parrot/ops/math.ops,v retrieving revision 1.11 diff -u -r1.11 math.ops --- math.ops 23 Oct 2003 17:41:55 -0000 1.11 +++ math.ops 28 Oct 2003 19:08:03 -0000 @@ -126,6 +126,8 @@ =item B<add>(in PMC, in PMC, in PMC) +=item B<add>(out PMC, in INT, in INT) + Set $1 to the sum of $2 and $3. =cut @@ -187,6 +189,11 @@ inline op add (in PMC, in PMC, in PMC) { $2->vtable->add(interpreter, $2, $3, $1); + goto NEXT(); +} + +inline op add (out PMC, in INT, in INT) { + $1->vtable->set_integer_native(interpreter, $1, $2 + $3); goto NEXT(); }