initial import
[vuplus_webkit] / Source / JavaScriptCore / docs / make-bytecode-docs.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 open MACHINE, "<" . $ARGV[0];
6 open OUTPUT, ">" . $ARGV[1];
7
8 my @undocumented = ();
9
10 print OUTPUT "<!-- Generated from Interpreter.cpp by make-bytecode-docs.pl. -->\n";
11 print OUTPUT "<style>p code \{ font-size: 14px; \}</style>\n";
12
13 while (<MACHINE>) {
14     if (/^ *DEFINE_OPCODE/) {
15         chomp;
16         s/^ *DEFINE_OPCODE\(op_//;
17         s/\).*$//;
18         my $opcode = $_;
19         $_ = <MACHINE>;
20         chomp;
21         if (m|/\* |) {
22             my $format = $_;
23             $format =~ s|.* /\* ||;
24             my $doc = "";
25             while (<MACHINE>) {
26                 if (m|\*/|) {
27                     last;
28                 }
29                 $doc .= $_ . " ";
30             }
31
32             print OUTPUT "<h2><code>${opcode}</code></h2>\n<p><b>Format: </b><code>\n${format}\n</code></p>\n<p>\n${doc}\n</p>\n";
33         } else {
34             push @undocumented, $opcode;
35         }
36     }
37 }
38
39 close OUTPUT;
40
41 for my $undoc (@undocumented) {
42     print "UNDOCUMENTED: ${undoc}\n";
43 }