blob: f0fcb53b03f52e1100bb91c4d8b286f34479b46e [file] [log] [blame]
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +00001#! /usr/bin/perl -w
2#
3# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
eric@webkit.orge8e340f2010-02-15 18:04:54 +00004# Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +00005#
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;
eric@webkit.orge8e340f2010-02-15 18:04:54 +000022use File::Basename;
23use Getopt::Long;
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000024
paroga@webkit.org7d853f52011-01-21 04:58:20 +000025my $usage = basename($0) . " --prefix prefix file";
eric@webkit.orge8e340f2010-02-15 18:04:54 +000026
27my $rtype_template = quotemeta("#rtype#");
eric@webkit.orge8e340f2010-02-15 18:04:54 +000028my $op_template = quotemeta("#op#");
29
eric@webkit.org671c4252010-02-19 19:30:55 +000030my $prefix;
eric@webkit.orge8e340f2010-02-15 18:04:54 +000031my $file;
32
33my $getOptionsResult = GetOptions(
paroga@webkit.org7d853f52011-01-21 04:58:20 +000034 'prefix=s' => \$prefix
eric@webkit.orge8e340f2010-02-15 18:04:54 +000035);
36
37$file = $ARGV[0];
38
eric@webkit.org671c4252010-02-19 19:30:55 +000039die "$usage\n" unless ($prefix and $file);
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000040
41my $stub_template = "";
commit-queue@webkit.orgd0188102010-06-25 07:30:12 +000042my $output_end = "";
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000043my $stub = "";
44
45my $rtype = "";
46my $op = "";
47
mitz@apple.com6cf57f02011-10-26 16:30:50 +000048print STDERR "Creating JIT stubs for $file \n";
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000049open(IN, $file) or die "No such file $file";
50
51while ( $_ = <IN> ) {
commit-queue@webkit.orgd0188102010-06-25 07:30:12 +000052 if ( /^$prefix\_BEGIN\((.*)\)/ ) {
53 $stub = $1;
commit-queue@webkit.orgd0188102010-06-25 07:30:12 +000054 print $stub . "\n";
55 }
eric@webkit.org671c4252010-02-19 19:30:55 +000056 if ( /^$prefix\((.*)\)/ ) {
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000057 $stub_template .= $1 . "\n";
58 }
commit-queue@webkit.orgd0188102010-06-25 07:30:12 +000059 if ( /^$prefix\_END\((.*)\)/ ) {
60 $output_end .= $1 . "\n";
61 }
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000062 if ( /^DEFINE_STUB_FUNCTION\((.*), (.*)\)/ ) {
63 $stub = $stub_template;
64 $rtype = quotemeta($1);
65 $op = quotemeta($2);
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000066 $stub =~ s/$rtype_template/$rtype/g;
67 $stub =~ s/$op_template/$op/g;
68 $stub =~ s/\\\*/\*/g;
69 print $stub;
70 }
71}
72
commit-queue@webkit.orgd0188102010-06-25 07:30:12 +000073print $output_end;
74
laszlo.1.gombos@nokia.com32fb4ae2010-01-08 05:47:21 +000075close(IN);