1 #!/usr/local/bin/perl -w
3 # Create link and execute definitions for switch dispatch method.
4 # Copyright (c) 1998 New Generation Software (NGS) Oy
6 # Author: Markku Rossi <mtr@ngs.fi>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Library General Public License for more details.
20 # You should have received a copy of the GNU Library General Public
21 # License along with this library; if not, write to the Free
22 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 # $Source: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/kjs/src/make-switch.pl,v $
35 $target = "./c1switch.h";
36 open(CFP
, ">$target") || die "couldn't create `$target': $!\n";
38 $target = "./c2switch.h";
39 open(CFP2
, ">$target") || die "couldn't create `$target': $!\n";
41 $target = "./eswitch.h";
42 open(EFP
, ">$target") || die "couldn't create `$target': $!\n";
45 if (/operand\s+([a-zA-Z_][a-zA-Z0-9_]+)\s+([\S]+)\s+\{(.*)/) {
51 if ($flags =~ /symbol/) {
55 if ($flags =~ /jump/) {
60 printf CFP
("#line %d \"%s\"\n", $. - 1, $ARGV);
64 # Compilation phase 1.
66 print CFP
"/* operand $operand ($opcount) */\n";
67 print CFP
"case $opcount:\n";
68 print CFP
" SAVE_OP ($opcount);\n";
70 if ($operand eq "const") {
71 # Patch const offsets.
72 printf CFP
" JS_BC_READ_INT32 (cp, i);\n";
73 printf CFP
" i += consts_offset;\n";
74 printf CFP
" SAVE_INT32 (i);\n";
77 printf CFP
" JS_BC_READ_INT32 (cp, i);\n";
78 printf CFP
" i += consts_offset;\n";
79 printf CFP
" i = vm->consts[i].u.vsymbol;\n";
80 printf CFP
" SAVE_INT32 (i);\n";
82 # Handle standard arguments.
84 } elsif ($args =~ /1/) {
85 print CFP
" JS_BC_READ_INT8 (cp, i);\n";
86 print CFP
" SAVE_INT8 (i);\n";
87 } elsif ($args =~ /2/) {
88 print CFP
" JS_BC_READ_INT16 (cp, i);\n";
89 print CFP
" SAVE_INT16 (i);\n";
90 } elsif ($args =~ /4/) {
91 print CFP
" JS_BC_READ_INT32 (cp, i);\n";
92 print CFP
" SAVE_INT32 (i);\n";
94 die("$ARGV:$.: illegal argument: $args\n");
98 print CFP
" cp += $args;\n";
99 print CFP
" break;\n\n";
105 # Compilation phase 2.
108 printf CFP2
"#line %d \"%s\"\n", $. - 1, $ARGV;
110 print CFP2
"/* operand $operand ($opcount) */\n";
111 print CFP2
"case $opcount:\n";
112 print CFP2
" cpos++;\n";
114 print CFP2
" i = ARG_INT32 ();\n";
116 print CFP2
" printf(\"%s: delta=%d, cp=%d\\n\", \"$operand\", i, cp - code_start - 1);\n";
118 print CFP2
" i = reloc[cp - fixed_code + 4 + i] - &f->code[cpos + 1];\n";
120 print CFP2
" printf (\"%s: newdelta=%d\\n\", \"$operand\", i);\n";
122 print CFP2
" ARG_INT32 () = i;\n";
125 print CFP2
" cp += $args;\n";
126 print CFP2
" cpos++;\n";
128 print CFP2
" break;\n\n";
134 printf EFP
"#line %d\"%s\"\n", $. - 1, $ARGV;
136 print EFP
"/* operand $operand ($opcount) */\n";
137 print EFP
"case $opcount:\n";
140 print EFP
" break;\n\n";