Created
May 24, 2010 20:21
-
-
Save cotto/412377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: compilers/opsc/src/Ops/Trans.pm | |
=================================================================== | |
--- compilers/opsc/src/Ops/Trans.pm (revision 46944) | |
+++ compilers/opsc/src/Ops/Trans.pm (working copy) | |
@@ -44,7 +44,7 @@ | |
our %arg_maps := {}; | |
-method access_arg($type, $num) { die('...'); } | |
+method access_arg($type, $dir, $num) { die('...'); } | |
method restart_address($addr) { die('...'); } | |
method restart_offset($offset) { die('...'); } | |
Index: compilers/opsc/src/Ops/Trans/C.pm | |
=================================================================== | |
--- compilers/opsc/src/Ops/Trans/C.pm (revision 46944) | |
+++ compilers/opsc/src/Ops/Trans/C.pm (working copy) | |
@@ -14,15 +14,15 @@ | |
self<num_entries> := 0; | |
- self<arg_maps> := hash( | |
+ self<const_arg_maps> := hash( | |
:op("cur_opcode[NUM]"), | |
- :i("IREG(NUM)"), | |
- :n("NREG(NUM)"), | |
- :p("PREG(NUM)"), | |
- :s("SREG(NUM)"), | |
- :k("PREG(NUM)"), | |
- :ki("IREG(NUM)"), | |
+ :i("(const INTVAL)IREG(NUM)"), | |
+ :n("(const NUMVAL)NREG(NUM)"), | |
+ :p("(const PMC *)PREG(NUM)"), | |
+ :s("(const STRING *)SREG(NUM)"), | |
+ :k("(const PMC *)PREG(NUM)"), | |
+ :ki("(const INTVAL)IREG(NUM)"), | |
:ic("cur_opcode[NUM]"), | |
:nc("CONST(NUM)->u.number"), | |
@@ -32,6 +32,15 @@ | |
:kic("cur_opcode[NUM]") | |
); | |
+ self<io_arg_maps> := hash( | |
+ :i("IREG(NUM)"), | |
+ :n("NREG(NUM)"), | |
+ :p("PREG(NUM)"), | |
+ :s("SREG(NUM)"), | |
+ :k("PREG(NUM)"), | |
+ :ki("IREG(NUM)"), | |
+ ); | |
+ | |
self; | |
} | |
@@ -75,9 +84,9 @@ | |
} | |
} | |
-method access_arg($type, $num) { | |
- my $access := self<arg_maps>{$type}; | |
- die("unrecognized arg type '$type'") unless $access; | |
+method access_arg($type, $dir, $num) { | |
+ my $access := $dir == 'i' ?? self<const_arg_maps>{$type} !! self<io_arg_maps>{$type}; | |
+ die("unrecognized arg type '$dir $type'") unless $access; | |
subst($access, /NUM/, $num); | |
} | |
Index: compilers/opsc/src/Ops/Op.pm | |
=================================================================== | |
--- compilers/opsc/src/Ops/Op.pm (revision 46944) | |
+++ compilers/opsc/src/Ops/Op.pm (working copy) | |
@@ -141,6 +141,11 @@ | |
@arg_types[$arg_num]; | |
} | |
+method arg_dir($arg_num) { | |
+ my @arg_dirs := self.arg_dirs; | |
+ @arg_dirs[$arg_num]; | |
+} | |
+ | |
method full_name() { | |
my $name := self.name; | |
my @arg_types := self.arg_types; | |
@@ -290,7 +295,7 @@ | |
# Poor man multis... | |
if $what eq 'PAST::Var()' { | |
my $n := +$chunk.name; | |
- return $trans.access_arg( self.arg_type($n - 1), $n); | |
+ return $trans.access_arg( self.arg_type($n - 1), self.arg_dir($n - 1), $n); | |
} | |
elsif $what eq 'PAST::Op()' { | |
my $type := $chunk.pasttype; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment