Mercurial > hg > Members > anatofuz > MoarVM
view cbctools/change_OPS_h_to_cbc.pl @ 16:5dad2b2a4da3
fix INTERP instance values and add __CODES array
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 18 Oct 2018 14:01:51 +0900 |
parents | e8ab4ff02207 |
children | f4636c3adb79 |
line wrap: on
line source
#!/usr/bin/env perl use strict; use warnings; # # 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 " __code (* CODES[])(INTERP) = {\n"; map {print " $_,\n";} @out; print "};\n";