forked from openresty/openresty-gdb-utils
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync-lj21
executable file
·73 lines (58 loc) · 1.72 KB
/
sync-lj21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env perl
use strict;
use warnings;
my $ljdir = shift or die "No luajit source directory specified.\n";
my $infile = "luajit21.py";
open my $in, $infile
or die "Cannot open $infile for reading: $!\n";
my $pysrc = do { local $/; <$in> };
close $in;
$infile = "$ljdir/src/jit/vmdef.lua";
open $in, $infile
or die "Cannot open $infile for reading: $!\n";
my $luasrc = do { local $/; <$in> };
close $in;
if ($luasrc =~ /^(irnames = ".*?"),$/sm) {
my $stmt = $1;
my $cnt = ($pysrc =~ s/^irnames = ".*?"$/$stmt/sm);
if (!$cnt) {
die "Cannot find irnames definition in luajit21.py.\n";
}
} else {
die "No irnames found in $infile.\n";
}
if ($luasrc =~ /^ircall = \{\s*\[0\]=(.*?)\},$/sm) {
my $elems = $1;
my $cnt = ($pysrc =~ s/^ircall = \[\n.*?\]$/ircall = [\n$elems]/sm);
if (!$cnt) {
die "Cannot find ircall definition in luajit21.py.\n";
}
} else {
die "No ircall found in $infile.\n";
}
if ($luasrc =~ /^irfield = \{\s*\[0\]=(.*?)\},$/sm) {
my $elems = $1;
$elems =~ s/,\s*$//;
my $cnt = ($pysrc =~ s/^irfield = \[.*?\]$/irfield = [ $elems ]/sm);
if (!$cnt) {
die "Cannot find irfield definition in luajit21.py.\n";
}
} else {
die "No irfield found in $infile.\n";
}
if ($luasrc =~ /^irfpm = \{\s*\[0\]=(.*?)\},$/sm) {
my $elems = $1;
$elems =~ s/,\s*$//;
my $cnt = ($pysrc =~ s/^irfpm = \[.*?\]$/irfpm = [ $elems ]/sm);
if (!$cnt) {
die "Cannot find irfpm definition in luajit21.py.\n";
}
} else {
die "No irfpm found in $infile.\n";
}
my $outfile = "luajit21.py_";
open my $out, ">$outfile" or
die "Failed to open $outfile for writing: $!\n";
print $out $pysrc;
close $out;
print "Wrote $outfile\n";