Mercurial > hg > Members > anatofuz > nqp-cbc-tools
diff lib/OPCODE2Function.pm @ 13:5bf045527a94
update opcode2function.pl
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 27 Nov 2018 13:05:20 +0900 |
parents | f873ae65aab1 |
children |
line wrap: on
line diff
--- a/lib/OPCODE2Function.pm Fri Nov 09 20:45:02 2018 +0900 +++ b/lib/OPCODE2Function.pm Tue Nov 27 13:05:20 2018 +0900 @@ -2,8 +2,7 @@ use strict; use warnings; -sub codes { - my @CODES = qw/ +my @CODES = qw/ cbc_no_op cbc_const_i8 cbc_const_i16 @@ -2054,7 +2053,12 @@ cbc_op_call_extop /; +my %REV_CODES = (); +#map { $REV_CODES{$CODES[$_]} = [] } (0..@CODES-1); +map { push @{$REV_CODES{$CODES[$_]}}, $_} (0..@CODES-1); + +sub codes { my ($class,$input) = @_; if ( 0 <= $input && $input < @CODES){ @@ -2065,4 +2069,11 @@ } +sub name2bitecode { + my ($class,$input) = @_; + + return $REV_CODES{$input} ? $REV_CODES{$input} : "not codes"; + +} + 1;