Ignore:
Timestamp:
2017-09-17T15:47:18+02:00 (9 years ago)
Author:
Don-vip
Message:

update to JAPICC 2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/japicc/modules/Internals/APIDump.pm

    r11682 r12872  
    135135       
    136136        my $ClassName = getFilename($ClassPath);
    137         if($ClassName=~/\$\d/) {
     137        if($ClassName=~/\$\d/ or $ClassName eq "module-info") {
    138138            next;
    139139        }
     140       
    140141        $ClassPath = cutPrefix($ClassPath, $ExtractPath); # javap decompiler accepts relative paths only
    141142       
     
    220221}
    221222
    222 sub simpleDecl($)
     223sub simpleDecl($$)
    223224{
    224     my $Line = $_[0];
     225    my ($Line, $LVer) = @_;
    225226   
    226227    my %B = ( "<"=>0, ">"=>0 );
     
    287288    {
    288289        if($Line=~s/([A-Za-z\d\?]+) extends \Q$R\E/$1/) {
    289             $Tmpl{$1} = $R;
     290            $Tmpl{$1} = registerType($R, $LVer);
    290291        }
    291292    }
     
    317318    close(IN);
    318319   
    319     my (%TypeAttr, $CurrentMethod, $CurrentPackage, $CurrentClass) = ();
     320    my (%TypeAttr, $CurrentMethod, $CurrentPackage, $CurrentClass, $CurrentClass_Short) = ();
    320321    my ($InParamTable, $InVarTypeTable, $InExceptionTable, $InCode) = (0, 0, 0, 0);
    321322   
     
    488489          # <KEYIN extends java.lang.Object ...
    489490            if($LINE=~/<[A-Z\d\?]+ /i) {
    490                 ($LINE, $TmplP) = simpleDecl($LINE);
     491                ($LINE, $TmplP) = simpleDecl($LINE, $LVer);
    491492            }
    492493        }
     
    628629            }
    629630            $MethodAttr{"Class"} = registerType($TypeAttr{"Name"}, $LVer);
    630             if($MethodAttr{"ShortName"}=~/\A(|(.+)\.)\Q$CurrentClass\E\Z/)
     631            if($MethodAttr{"ShortName"}=~/\A(|(.+)\.)(\Q$CurrentClass\E|\Q$CurrentClass_Short\E)\Z/)
    631632            {
    632633                if($2)
     
    688689            and $LINE_N=~/(Signature|descriptor):\s*(.+?)\s*\Z/i)
    689690            { # create run-time unique name ( java/io/PrintStream.println (Ljava/lang/String;)V )
     691                my $SignParams = $2;
     692               
     693                # Generic classes
     694                my $ShortClass = $CurrentClass;
     695                $ShortClass=~s/<.*>//g;
     696               
    690697                if($MethodAttr{"Constructor"}) {
    691                     $CurrentMethod = $CurrentClass.".\"<init>\":".$2;
     698                    $CurrentMethod = $ShortClass.".\"<init>\":".$SignParams;
    692699                }
    693700                else {
    694                     $CurrentMethod = $CurrentClass.".".$MethodAttr{"ShortName"}.":".$2;
     701                    $CurrentMethod = $ShortClass.".".$MethodAttr{"ShortName"}.":".$SignParams;
    695702                }
    696703                if(my $PackageName = getSFormat($CurrentPackage)) {
     
    832839                $CurrentPackage = "";
    833840            }
     841           
    834842            if($CurrentClass=~s/#/./g)
    835843            { # javax.swing.text.GlyphView.GlyphPainter <=> GlyphView$GlyphPainter
    836844                $TypeAttr{"Name"}=~s/#/./g;
    837845            }
     846           
     847            $CurrentClass_Short = $CurrentClass;
     848            if(index($CurrentClass_Short, "<")!=-1) {
     849                $CurrentClass_Short=~s/<.+>//g;
     850            }
     851           
    838852            if($LINE=~/(\A|\s+)(public|protected|private)\s+/) {
    839853                $TypeAttr{"Access"} = $2;
     
    885899                $TypeAttr{"Static"} = 1;
    886900            }
     901           
     902            if($TmplP) {
     903                $TypeAttr{"GenericParam"} = $TmplP;
     904            }
    887905        }
    888906        elsif(index($LINE, "Deprecated: true")!=-1
     
    919937    chdir($In::Opt{"OrigDir"});
    920938   
     939    if(my $Err = $?>>8) {
     940        exitStatus("Error", "failed to run javap");
     941    }
     942   
    921943    if(not $NonEmpty) {
    922944        exitStatus("Error", "internal error in parser");
     
    961983            $TypeInfo{$LVer}{$Tid}{"BaseType"} = $BaseTypeId;
    962984            $TypeInfo{$LVer}{$Tid}{"Type"} = "array";
     985        }
     986    }
     987    elsif($TName=~/(.+)\.\.\.\Z/)
     988    {
     989        if(my $BaseTypeId = registerType($1, $LVer))
     990        {
     991            $TypeInfo{$LVer}{$Tid}{"BaseType"} = $BaseTypeId;
     992            $TypeInfo{$LVer}{$Tid}{"Type"} = "variable-arity";
    963993        }
    964994    }
Note: See TracChangeset for help on using the changeset viewer.