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

« back to all changes in this revision

Viewing changes to src/proguard/classfile/attribute/LineNumberTableAttribute.java

  • Committer: Package Import Robot
  • Author(s): komal Sukhani
  • Date: 2015-08-31 14:45:54 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20150831144554-v4gb9hzo8xldfky9
Tags: 5.2.1-1
* Team upload
* New upstream release
* Add new patches
  - correct_properties_file_path
  - enable_building_of_gradle_task
* Add gradle package in build depends
* d/control: Switch Vcs-Browser field to cgit

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-2014 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2015 Eric Lafortune @ GuardSquare
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
62
62
     */
63
63
    public int getLineNumber(int pc)
64
64
    {
65
 
        for (int index = u2lineNumberTableLength-1 ; index >= 0 ; index--)
 
65
        LineNumberInfo info = getLineNumberInfo(pc);
 
66
 
 
67
        return info == null ? 0 : info.u2lineNumber;
 
68
    }
 
69
 
 
70
 
 
71
    /**
 
72
     * Returns the source corresponding to the given byte code program
 
73
     * counter.
 
74
     */
 
75
    public String getSource(int pc)
 
76
    {
 
77
        LineNumberInfo info = getLineNumberInfo(pc);
 
78
 
 
79
        return info == null ? null : info.getSource();
 
80
    }
 
81
 
 
82
 
 
83
    /**
 
84
     * Returns the line number info corresponding to the given byte code
 
85
     * program counter.
 
86
     */
 
87
    public LineNumberInfo getLineNumberInfo(int pc)
 
88
    {
 
89
        for (int index = u2lineNumberTableLength-1; index >= 0; index--)
66
90
        {
67
91
            LineNumberInfo info = lineNumberTable[index];
68
92
            if (pc >= info.u2startPC)
69
93
            {
70
 
                return info.u2lineNumber;
 
94
                return info;
71
95
            }
72
96
        }
73
97
 
74
98
        return u2lineNumberTableLength > 0 ?
75
 
            lineNumberTable[0].u2lineNumber :
76
 
            0;
 
99
            lineNumberTable[0] :
 
100
            null;
77
101
    }
78
102
 
79
103
 
80
104
    /**
81
 
     * Returns the lowest line number, or 0 if there aren't any line numbers.
 
105
     * Returns the lowest line number with the default null source,
 
106
     * or 0 if there aren't any such line numbers.
82
107
     */
83
108
    public int getLowestLineNumber()
84
109
    {
85
 
        if (u2lineNumberTableLength == 0)
86
 
        {
87
 
            return 0;
88
 
        }
89
 
 
90
110
        int lowestLineNumber = Integer.MAX_VALUE;
91
111
 
92
112
        for (int index = 0; index < u2lineNumberTableLength; index++)
93
113
        {
94
 
            int lineNumber = lineNumberTable[index].u2lineNumber;
95
 
            if (lineNumber < lowestLineNumber)
 
114
            LineNumberInfo info = lineNumberTable[index];
 
115
            if (info.getSource() == null)
96
116
            {
97
 
                lowestLineNumber = lineNumber;
 
117
                int lineNumber = info.u2lineNumber;
 
118
                if (lineNumber < lowestLineNumber)
 
119
                {
 
120
                    lowestLineNumber = lineNumber;
 
121
                }
98
122
            }
99
123
        }
100
124
 
101
 
        return lowestLineNumber;
 
125
        return lowestLineNumber == Integer.MAX_VALUE ? 0 : lowestLineNumber;
102
126
    }
103
127
 
104
128
 
105
129
    /**
106
 
     * Returns the highest line number, or 0 if there aren't any line numbers.
 
130
     * Returns the highest line number with the default null source,
 
131
     * or 0 if there aren't any such line numbers.
107
132
     */
108
133
    public int getHighestLineNumber()
109
134
    {
110
 
        if (u2lineNumberTableLength == 0)
111
 
        {
112
 
            return 0;
113
 
        }
114
 
 
115
 
        int highestLineNumber = Integer.MIN_VALUE;
 
135
        int highestLineNumber = 0;
116
136
 
117
137
        for (int index = 0; index < u2lineNumberTableLength; index++)
118
138
        {
119
 
            int lineNumber = lineNumberTable[index].u2lineNumber;
120
 
            if (lineNumber > highestLineNumber)
 
139
            LineNumberInfo info = lineNumberTable[index];
 
140
            if (info.getSource() == null)
121
141
            {
122
 
                highestLineNumber = lineNumber;
 
142
                int lineNumber = info.u2lineNumber;
 
143
                if (lineNumber > highestLineNumber)
 
144
                {
 
145
                    highestLineNumber = lineNumber;
 
146
                }
123
147
            }
124
148
        }
125
149