Mercurial > hg > Members > anatofuz > MoarVM
changeset 14:b3f4341fabf8
create change_OPS_h_to_cbc.pl
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Oct 2018 17:43:47 +0900 |
parents | b0d43f1e6a04 |
children | e8ab4ff02207 |
files | cbctools/change_OPS_h_to_cbc.pl |
diffstat | 1 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbctools/change_OPS_h_to_cbc.pl Tue Oct 16 17:43:47 2018 +0900 @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use DDP { deparse => 1 }; +# +# Input file is dispatc.cbc +# + +my %codesegs = (); +my $file; + +{ + $file = shift or die "require .cbc file"; + open my $fh, '<',$file; + + while (my $line = <$fh>){ + if ($line =~ /__code cbc_(.*)\(INTERP i\)/){ + my $codesegment = $1; + $codesegs{$codesegment} = 1; + } + } + + close $fh; +} + +$file = shift or die "require .cbc file"; +open my $fh, '<',$file; +my @out = (); + +while(my $line = <$fh>){ + if ($line =~ /^\s+&&OP_(.*),/){ + if (exists($codesegs{$1})){ + push @out," cbc_$1,\n"; + next; + } + } +} + +close $fh; + + +for my $code_gear (@out){ + $code_gear =~ s/^\s+(\w+),\n/$1/g; + print "__code $code_gear();\n"; +} + +print "\n"; +print " static const void * const CODES[] = {\n"; +map {print " $_,\n";} @out; +print "};\n";