~ubuntu-branches/ubuntu/wily/proguard/wily

« back to all changes in this revision

Viewing changes to src/proguard/classfile/util/ClassUtil.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-04-10 13:58:11 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20140410135811-ddwzt2avu94rnolt
Tags: 4.11-1
* Team upload.
* New upstream release
* Removed the non-free documentation from the package (Closes: #719706)
* Removed the pre-built jars from the upstream tarball
* debian/control:
  - The package is now co-maintained with the Java Team
  - Standards-Version updated to 3.9.5 (no changes)
  - Added the Vcs-* fields
  - Added the Homepage field
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3
3
 *             of Java bytecode.
4
4
 *
5
 
 * Copyright (c) 2002-2012 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
470
470
     */
471
471
    public static int internalMethodParameterCount(String internalMethodDescriptor)
472
472
    {
473
 
        InternalTypeEnumeration internalTypeEnumeration =
474
 
            new InternalTypeEnumeration(internalMethodDescriptor);
475
 
 
476
473
        int counter = 0;
477
 
        while (internalTypeEnumeration.hasMoreTypes())
 
474
        int index   = 1;
 
475
 
 
476
        while (true)
478
477
        {
479
 
            internalTypeEnumeration.nextType();
 
478
            char c = internalMethodDescriptor.charAt(index++);
 
479
            switch (c)
 
480
            {
 
481
                case ClassConstants.INTERNAL_TYPE_ARRAY:
 
482
                {
 
483
                    // Just ignore all array characters.
 
484
                    break;
 
485
                }
 
486
                case ClassConstants.INTERNAL_TYPE_CLASS_START:
 
487
                {
 
488
                    counter++;
480
489
 
481
 
            counter++;
 
490
                    // Skip the class name.
 
491
                    index = internalMethodDescriptor.indexOf(ClassConstants.INTERNAL_TYPE_CLASS_END, index) + 1;
 
492
                    break;
 
493
                }
 
494
                default:
 
495
                {
 
496
                    counter++;
 
497
                    break;
 
498
                }
 
499
                case ClassConstants.INTERNAL_METHOD_ARGUMENTS_CLOSE:
 
500
                {
 
501
                    return counter;
 
502
                }
 
503
            }
482
504
        }
483
 
 
484
 
        return counter;
485
505
    }
486
506
 
487
507
 
535
555
    public static int internalMethodParameterSize(String  internalMethodDescriptor,
536
556
                                                  boolean isStatic)
537
557
    {
538
 
        InternalTypeEnumeration internalTypeEnumeration =
539
 
            new InternalTypeEnumeration(internalMethodDescriptor);
 
558
        int size  = isStatic ? 0 : 1;
 
559
        int index = 1;
540
560
 
541
 
        int size = isStatic ? 0 : 1;
542
 
        while (internalTypeEnumeration.hasMoreTypes())
 
561
        while (true)
543
562
        {
544
 
            String internalType = internalTypeEnumeration.nextType();
545
 
 
546
 
            size += internalTypeSize(internalType);
 
563
            char c = internalMethodDescriptor.charAt(index++);
 
564
            switch (c)
 
565
            {
 
566
                case ClassConstants.INTERNAL_TYPE_LONG:
 
567
                case ClassConstants.INTERNAL_TYPE_DOUBLE:
 
568
                {
 
569
                    size += 2;
 
570
                    break;
 
571
                }
 
572
                case ClassConstants.INTERNAL_TYPE_CLASS_START:
 
573
                {
 
574
                    size++;
 
575
 
 
576
                    // Skip the class name.
 
577
                    index = internalMethodDescriptor.indexOf(ClassConstants.INTERNAL_TYPE_CLASS_END, index) + 1;
 
578
                    break;
 
579
                }
 
580
                case ClassConstants.INTERNAL_TYPE_ARRAY:
 
581
                {
 
582
                    size++;
 
583
 
 
584
                    // Skip all array characters.
 
585
                    while ((c = internalMethodDescriptor.charAt(index++)) == ClassConstants.INTERNAL_TYPE_ARRAY) {}
 
586
 
 
587
                    if (c == ClassConstants.INTERNAL_TYPE_CLASS_START)
 
588
                    {
 
589
                        // Skip the class type.
 
590
                        index = internalMethodDescriptor.indexOf(ClassConstants.INTERNAL_TYPE_CLASS_END, index) + 1;
 
591
                    }
 
592
                    break;
 
593
                }
 
594
                default:
 
595
                {
 
596
                    size++;
 
597
                    break;
 
598
                }
 
599
                case ClassConstants.INTERNAL_METHOD_ARGUMENTS_CLOSE:
 
600
                {
 
601
                    return size;
 
602
                }
 
603
            }
547
604
        }
548
 
 
549
 
        return size;
550
605
    }
551
606
 
552
607