]> git.saurik.com Git - apple/javascriptcore.git/blame - create_jit_stubs
JavaScriptCore-903.5.tar.gz
[apple/javascriptcore.git] / create_jit_stubs
CommitLineData
f9bf01c6
A
1#! /usr/bin/perl -w
2#
3# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
4e4e5a6f 4# Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
f9bf01c6
A
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Library General Public
8# License as published by the Free Software Foundation; either
9# version 2 of the License, or (at your option) any later version.
10#
11# This library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Library General Public License for more details.
15#
16# You should have received a copy of the GNU Library General Public License
17# along with this library; see the file COPYING.LIB. If not, write to
18# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19# Boston, MA 02110-1301, USA.
20
21use strict;
4e4e5a6f
A
22use File::Basename;
23use Getopt::Long;
f9bf01c6 24
14957cd0 25my $usage = basename($0) . " --prefix prefix file";
4e4e5a6f
A
26
27my $rtype_template = quotemeta("#rtype#");
4e4e5a6f
A
28my $op_template = quotemeta("#op#");
29
30my $prefix;
4e4e5a6f
A
31my $file;
32
33my $getOptionsResult = GetOptions(
14957cd0 34 'prefix=s' => \$prefix
4e4e5a6f
A
35);
36
37$file = $ARGV[0];
38
39die "$usage\n" unless ($prefix and $file);
f9bf01c6
A
40
41my $stub_template = "";
14957cd0 42my $output_end = "";
f9bf01c6
A
43my $stub = "";
44
45my $rtype = "";
46my $op = "";
47
4e4e5a6f 48print STDERR "Creating JIT stubs for $file \n";
f9bf01c6
A
49open(IN, $file) or die "No such file $file";
50
51while ( $_ = <IN> ) {
14957cd0
A
52 if ( /^$prefix\_BEGIN\((.*)\)/ ) {
53 $stub = $1;
54 print $stub . "\n";
55 }
4e4e5a6f 56 if ( /^$prefix\((.*)\)/ ) {
f9bf01c6
A
57 $stub_template .= $1 . "\n";
58 }
14957cd0
A
59 if ( /^$prefix\_END\((.*)\)/ ) {
60 $output_end .= $1 . "\n";
61 }
f9bf01c6
A
62 if ( /^DEFINE_STUB_FUNCTION\((.*), (.*)\)/ ) {
63 $stub = $stub_template;
64 $rtype = quotemeta($1);
65 $op = quotemeta($2);
66 $stub =~ s/$rtype_template/$rtype/g;
67 $stub =~ s/$op_template/$op/g;
68 $stub =~ s/\\\*/\*/g;
69 print $stub;
70 }
71}
72
14957cd0
A
73print $output_end;
74
f9bf01c6 75close(IN);