< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java

Print this page

 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.tools.javac.jvm;
 27 
 28 import java.util.*;
 29 
 30 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 31 import com.sun.tools.javac.tree.*;
 32 import com.sun.tools.javac.util.*;
 33 import com.sun.tools.javac.util.List;
 34 import com.sun.tools.javac.tree.JCTree.*;
 35 import com.sun.tools.javac.tree.EndPosTable;
 36 import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
 37 
 38 /** This class contains the CharacterRangeTable for some method
 39  *  and the hashtable for mapping trees or lists of trees to their
 40  *  ending positions.
 41  *
 42  *  <p><b>This is NOT part of any supported API.
 43  *  If you write code that depends on this, you do so at your own risk.
 44  *  This code and its internal interfaces are subject to change or
 45  *  deletion without notice.</b>
 46  */
 47 public class CRTable
 48 implements CRTFlags {
 49 
 50     private final boolean crtDebug = false;
 51 
 52     /** The list of CRTable entries.
 53      */
 54     private ListBuffer<CRTEntry> entries = new ListBuffer<>();
 55 
 56     /** The hashtable for source positions.

265         public void visitBlock(JCBlock tree) {
266             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
267             csp(tree.stats);    // doesn't compare because block's ending position is defined
268             result = sr;
269         }
270 
271         public void visitDoLoop(JCDoWhileLoop tree) {
272             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
273             sr.mergeWith(csp(tree.body));
274             sr.mergeWith(csp(tree.cond));
275             result = sr;
276         }
277 
278         public void visitWhileLoop(JCWhileLoop tree) {
279             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
280             sr.mergeWith(csp(tree.cond));
281             sr.mergeWith(csp(tree.body));
282             result = sr;
283         }
284 







285         public void visitForLoop(JCForLoop tree) {
286             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
287             sr.mergeWith(csp(tree.init));
288             sr.mergeWith(csp(tree.cond));
289             sr.mergeWith(csp(tree.step));
290             sr.mergeWith(csp(tree.body));
291             result = sr;
292         }
293 
294         public void visitForeachLoop(JCEnhancedForLoop tree) {
295             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
296             sr.mergeWith(csp(tree.var));
297             sr.mergeWith(csp(tree.expr));
298             sr.mergeWith(csp(tree.body));
299             result = sr;
300         }
301 
302         public void visitLabelled(JCLabeledStatement tree) {
303             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
304             sr.mergeWith(csp(tree.body));

346             sr.mergeWith(cspCatchers(tree.catchers));
347             sr.mergeWith(csp(tree.finalizer));
348             result = sr;
349         }
350 
351         public void visitCatch(JCCatch tree) {
352             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
353             sr.mergeWith(csp(tree.param));
354             sr.mergeWith(csp(tree.body));
355             result = sr;
356         }
357 
358         public void visitConditional(JCConditional tree) {
359             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
360             sr.mergeWith(csp(tree.cond));
361             sr.mergeWith(csp(tree.truepart));
362             sr.mergeWith(csp(tree.falsepart));
363             result = sr;
364         }
365 







366         public void visitIf(JCIf tree) {
367             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
368             sr.mergeWith(csp(tree.cond));
369             sr.mergeWith(csp(tree.thenpart));
370             sr.mergeWith(csp(tree.elsepart));
371             result = sr;
372         }
373 
374         public void visitExec(JCExpressionStatement tree) {
375             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
376             sr.mergeWith(csp(tree.expr));
377             result = sr;
378         }
379 
380         public void visitBreak(JCBreak tree) {
381             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
382             result = sr;
383         }
384 
385         public void visitYield(JCYield tree) {

 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.tools.javac.jvm;
 27 
 28 import java.util.*;
 29 
 30 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 31 import com.sun.tools.javac.tree.*;
 32 import com.sun.tools.javac.util.*;
 33 import com.sun.tools.javac.util.List;
 34 import com.sun.tools.javac.tree.JCTree.*;
 35 import com.sun.tools.javac.tree.EndPosTable;

 36 
 37 /** This class contains the CharacterRangeTable for some method
 38  *  and the hashtable for mapping trees or lists of trees to their
 39  *  ending positions.
 40  *
 41  *  <p><b>This is NOT part of any supported API.
 42  *  If you write code that depends on this, you do so at your own risk.
 43  *  This code and its internal interfaces are subject to change or
 44  *  deletion without notice.</b>
 45  */
 46 public class CRTable
 47 implements CRTFlags {
 48 
 49     private final boolean crtDebug = false;
 50 
 51     /** The list of CRTable entries.
 52      */
 53     private ListBuffer<CRTEntry> entries = new ListBuffer<>();
 54 
 55     /** The hashtable for source positions.

264         public void visitBlock(JCBlock tree) {
265             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
266             csp(tree.stats);    // doesn't compare because block's ending position is defined
267             result = sr;
268         }
269 
270         public void visitDoLoop(JCDoWhileLoop tree) {
271             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
272             sr.mergeWith(csp(tree.body));
273             sr.mergeWith(csp(tree.cond));
274             result = sr;
275         }
276 
277         public void visitWhileLoop(JCWhileLoop tree) {
278             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
279             sr.mergeWith(csp(tree.cond));
280             sr.mergeWith(csp(tree.body));
281             result = sr;
282         }
283 
284         public void visitWithField(JCWithField tree) {
285             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
286             sr.mergeWith(csp(tree.field));
287             sr.mergeWith(csp(tree.value));
288             result = sr;
289         }
290 
291         public void visitForLoop(JCForLoop tree) {
292             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
293             sr.mergeWith(csp(tree.init));
294             sr.mergeWith(csp(tree.cond));
295             sr.mergeWith(csp(tree.step));
296             sr.mergeWith(csp(tree.body));
297             result = sr;
298         }
299 
300         public void visitForeachLoop(JCEnhancedForLoop tree) {
301             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
302             sr.mergeWith(csp(tree.var));
303             sr.mergeWith(csp(tree.expr));
304             sr.mergeWith(csp(tree.body));
305             result = sr;
306         }
307 
308         public void visitLabelled(JCLabeledStatement tree) {
309             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
310             sr.mergeWith(csp(tree.body));

352             sr.mergeWith(cspCatchers(tree.catchers));
353             sr.mergeWith(csp(tree.finalizer));
354             result = sr;
355         }
356 
357         public void visitCatch(JCCatch tree) {
358             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
359             sr.mergeWith(csp(tree.param));
360             sr.mergeWith(csp(tree.body));
361             result = sr;
362         }
363 
364         public void visitConditional(JCConditional tree) {
365             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
366             sr.mergeWith(csp(tree.cond));
367             sr.mergeWith(csp(tree.truepart));
368             sr.mergeWith(csp(tree.falsepart));
369             result = sr;
370         }
371 
372         @Override
373         public void visitDefaultValue(JCDefaultValue tree) {
374             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
375             sr.mergeWith(csp(tree.clazz));
376             result = sr;
377         }
378 
379         public void visitIf(JCIf tree) {
380             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
381             sr.mergeWith(csp(tree.cond));
382             sr.mergeWith(csp(tree.thenpart));
383             sr.mergeWith(csp(tree.elsepart));
384             result = sr;
385         }
386 
387         public void visitExec(JCExpressionStatement tree) {
388             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
389             sr.mergeWith(csp(tree.expr));
390             result = sr;
391         }
392 
393         public void visitBreak(JCBreak tree) {
394             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
395             result = sr;
396         }
397 
398         public void visitYield(JCYield tree) {
< prev index next >