Coverage Report - com.sun.tools.javafx.comp.JavafxPrepForBackEnd
 
Classes in this File Line Coverage Branch Coverage Complexity
JavafxPrepForBackEnd
79%
184/232
62%
5/8
0
 
 1  
 /*
 2  
  * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
 3  
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  
  *
 5  
  * This code is free software; you can redistribute it and/or modify it
 6  
  * under the terms of the GNU General Public License version 2 only, as
 7  
  * published by the Free Software Foundation.  Sun designates this
 8  
  * particular file as subject to the "Classpath" exception as provided
 9  
  * by Sun in the LICENSE file that accompanied this code.
 10  
  *
 11  
  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  
  * version 2 for more details (a copy is included in the LICENSE file that
 15  
  * accompanied this code).
 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 22  
  * CA 95054 USA or visit www.sun.com if you need additional information or
 23  
  * have any questions.
 24  
  */
 25  
 
 26  
 package com.sun.tools.javafx.comp;
 27  
 
 28  
 import com.sun.tools.javac.tree.*;
 29  
 import com.sun.tools.javac.tree.JCTree.*;
 30  
 import com.sun.tools.javac.util.Context;
 31  
 import com.sun.tools.javafx.tree.JFXBlockExpression;
 32  
 import java.util.HashSet;
 33  
 import java.util.Set;
 34  
 
 35  
 /**
 36  
  * Remove symbol and type information.
 37  
  * 
 38  
  * Already converted to JCTree nodes
 39  
  * 
 40  
  * @author Robert Field
 41  
  */
 42  12
 public class JavafxPrepForBackEnd extends TreeScanner {
 43  
     
 44  399
     private Set<JCTree> seen = new HashSet<JCTree>();
 45  399
     private String sourceName = "";
 46  
     
 47  12
     protected static final Context.Key<JavafxPrepForBackEnd> prepForBackEndKey =
 48  
         new Context.Key<JavafxPrepForBackEnd>();
 49  
 
 50  
     public static JavafxPrepForBackEnd instance(Context context) {
 51  399
         JavafxPrepForBackEnd instance = context.get(prepForBackEndKey);
 52  399
         if (instance == null)
 53  399
             instance = new JavafxPrepForBackEnd(context);
 54  399
         return instance;
 55  
     }
 56  
 
 57  399
     JavafxPrepForBackEnd(Context context) { 
 58  399
     }
 59  
     
 60  
     public void prep(JavafxEnv<JavafxAttrContext> attrEnv) {
 61  340
         scan(attrEnv.toplevel);
 62  340
     }
 63  
     
 64  
     private void assertUnique(JCTree that) {
 65  353487
         boolean added = seen.add(that);
 66  353487
         if (!added) {
 67  
             //System.err.println("Node " + that + " already encountered -- unclean " + that.getClass() + " tree in " + sourceName);
 68  
         }
 69  353487
         assert added : "Node " + that + " already encountered -- unclean " + that.getClass() + " tree in " + sourceName;
 70  353487
     }
 71  
 
 72  
     @Override
 73  
     public void visitTopLevel(JCCompilationUnit that) {
 74  340
         super.visitTopLevel(that);
 75  340
         sourceName = that.sourcefile.getName();
 76  340
         assertUnique(that);
 77  340
         that.type = null;
 78  340
         that.packge = null;
 79  340
         that.starImportScope = null;
 80  340
         that.namedImportScope = null;
 81  340
     }
 82  
     
 83  
     @Override
 84  
     public void visitImport(JCImport that) {
 85  421
         super.visitImport(that);
 86  421
         assertUnique(that);
 87  421
         that.type = null;
 88  421
     }
 89  
     
 90  
     @Override
 91  
     public void visitClassDef(JCClassDecl that) {
 92  1772
         super.visitClassDef(that);
 93  1772
         assertUnique(that);
 94  1772
         that.type = null;
 95  1772
         that.sym = null;
 96  1772
     }
 97  
     
 98  
     @Override
 99  
     public void visitMethodDef(JCMethodDecl that) {
 100  9636
         super.visitMethodDef(that);
 101  9636
         assertUnique(that);
 102  9636
         that.type = null;
 103  9636
         that.sym = null;
 104  9636
     }
 105  
     
 106  
     @Override
 107  
     public void visitVarDef(JCVariableDecl that) {
 108  11171
         super.visitVarDef(that);
 109  11171
         assertUnique(that);
 110  11171
         that.type = null;
 111  11171
         that.sym = null;
 112  11171
     }
 113  
     
 114  
     @Override
 115  
     public void visitSkip(JCSkip that) {
 116  0
         super.visitSkip(that);
 117  0
         assertUnique(that);
 118  0
         that.type = null;
 119  0
     }
 120  
     
 121  
     @Override
 122  
     public void visitBlock(JCBlock that) {
 123  10020
         super.visitBlock(that);
 124  10020
         assertUnique(that);
 125  10020
         that.type = null;
 126  10020
     }
 127  
     
 128  
     @Override
 129  
     public void visitDoLoop(JCDoWhileLoop that) {
 130  0
         super.visitDoLoop(that);
 131  0
         assertUnique(that);
 132  0
         that.type = null;
 133  0
     }
 134  
     
 135  
     @Override
 136  
     public void visitWhileLoop(JCWhileLoop that) {
 137  11
         super.visitWhileLoop(that);
 138  11
         assertUnique(that);
 139  11
         that.type = null;
 140  11
     }
 141  
     
 142  
     @Override
 143  
     public void visitForLoop(JCForLoop that) {
 144  0
         super.visitForLoop(that);
 145  0
         assertUnique(that);
 146  0
         that.type = null;
 147  0
     }
 148  
     
 149  
     @Override
 150  
     public void visitForeachLoop(JCEnhancedForLoop that) {
 151  171
         super.visitForeachLoop(that);
 152  171
         assertUnique(that);
 153  171
         that.type = null;
 154  171
     }
 155  
     
 156  
     @Override
 157  
     public void visitLabelled(JCLabeledStatement that) {
 158  0
         super.visitLabelled(that);
 159  0
         assertUnique(that);
 160  0
         that.type = null;
 161  0
     }
 162  
     
 163  
     @Override
 164  
     public void visitSwitch(JCSwitch that) {
 165  0
         super.visitSwitch(that);
 166  0
         assertUnique(that);
 167  0
         that.type = null;
 168  0
     }
 169  
     
 170  
     @Override
 171  
     public void visitCase(JCCase that) {
 172  0
         super.visitCase(that);
 173  0
         assertUnique(that);
 174  0
         that.type = null;
 175  0
     }
 176  
     
 177  
     @Override
 178  
     public void visitSynchronized(JCSynchronized that) {
 179  0
          super.visitSynchronized(that);
 180  0
         assertUnique(that);
 181  0
         that.type = null;
 182  0
     }
 183  
     
 184  
     @Override
 185  
     public void visitTry(JCTry that) {
 186  24
         super.visitTry(that);
 187  24
         assertUnique(that);
 188  24
         that.type = null;
 189  24
     }
 190  
     
 191  
     @Override
 192  
     public void visitCatch(JCCatch that) {
 193  35
          super.visitCatch(that);
 194  35
         assertUnique(that);
 195  35
         that.type = null;
 196  35
     }
 197  
     
 198  
     @Override
 199  
     public void visitConditional(JCConditional that) {
 200  902
         super.visitConditional(that);
 201  902
         assertUnique(that);
 202  902
         that.type = null;
 203  902
     }
 204  
     
 205  
     @Override
 206  
     public void visitIf(JCIf that) {
 207  3183
         super.visitIf(that);
 208  3183
         assertUnique(that);
 209  3183
         that.type = null;
 210  3183
     }
 211  
     
 212  
     @Override
 213  
     public void visitExec(JCExpressionStatement that) {
 214  15403
          super.visitExec(that);
 215  15403
         assertUnique(that);
 216  15403
         that.type = null;
 217  15403
     }
 218  
     
 219  
     @Override
 220  
     public void visitBreak(JCBreak that) {
 221  5
          super.visitBreak(that);
 222  5
         assertUnique(that);
 223  5
         that.type = null;
 224  5
     }
 225  
     
 226  
     @Override
 227  
     public void visitContinue(JCContinue that) {
 228  3
         super.visitContinue(that);
 229  3
         assertUnique(that);
 230  3
         that.type = null;
 231  3
     }
 232  
     
 233  
     @Override
 234  
     public void visitReturn(JCReturn that) {
 235  2740
         super.visitReturn(that);
 236  2740
         assertUnique(that);
 237  2740
         that.type = null;
 238  2740
     }
 239  
     
 240  
     @Override
 241  
     public void visitThrow(JCThrow that) {
 242  24
         super.visitThrow(that);
 243  24
         assertUnique(that);
 244  24
         that.type = null;
 245  24
     }
 246  
     
 247  
     @Override
 248  
     public void visitAssert(JCAssert that) {
 249  0
         super.visitAssert(that);
 250  0
         assertUnique(that);
 251  0
         that.type = null;
 252  0
     }
 253  
     
 254  
     @Override
 255  
     public void visitApply(JCMethodInvocation that) {
 256  27986
         super.visitApply(that);
 257  27986
         assertUnique(that);
 258  27986
         that.type = null;
 259  27986
         that.varargsElement = null;
 260  27986
     }
 261  
     
 262  
     @Override
 263  
     public void visitNewClass(JCNewClass that) {
 264  1709
         super.visitNewClass(that);
 265  1709
         assertUnique(that);
 266  1709
         that.type = null;
 267  1709
         that.constructor = null;
 268  1709
         that.varargsElement = null;
 269  1709
     }
 270  
     
 271  
     @Override
 272  
     public void visitNewArray(JCNewArray that) {
 273  766
          super.visitNewArray(that);
 274  766
         assertUnique(that);
 275  766
         that.type = null;
 276  766
     }
 277  
     
 278  
     @Override
 279  
     public void visitParens(JCParens that) {
 280  19
         super.visitParens(that);
 281  19
         assertUnique(that);
 282  19
         that.type = null;
 283  19
     }
 284  
     
 285  
     @Override
 286  
     public void visitAssign(JCAssign that) {
 287  1301
         super.visitAssign(that);
 288  1301
         assertUnique(that);
 289  1301
         that.type = null;
 290  1301
     }
 291  
     
 292  
     @Override
 293  
     public void visitAssignop(JCAssignOp that) {
 294  17
         super.visitAssignop(that);
 295  17
         assertUnique(that);
 296  17
         that.type = null;
 297  17
         that.operator = null;
 298  17
     }
 299  
     
 300  
     @Override
 301  
     public void visitUnary(JCUnary that) {
 302  322
         super.visitUnary(that);
 303  322
         assertUnique(that);
 304  322
         that.type = null;
 305  322
         that.operator = null;
 306  322
     }
 307  
     
 308  
     @Override
 309  
     public void visitBinary(JCBinary that) {
 310  3839
         super.visitBinary(that);
 311  3839
         assertUnique(that);
 312  3839
         that.type = null;
 313  3839
         that.operator = null;
 314  3839
     }
 315  
     
 316  
     @Override
 317  
     public void visitTypeCast(JCTypeCast that) {
 318  1712
         super.visitTypeCast(that);
 319  1712
         assertUnique(that);
 320  1712
         that.type = null;
 321  1712
     }
 322  
     
 323  
     @Override
 324  
     public void visitTypeTest(JCInstanceOf that) {
 325  35
         super.visitTypeTest(that);
 326  35
         assertUnique(that);
 327  35
         that.type = null;
 328  35
     }
 329  
     
 330  
     @Override
 331  
     public void visitIndexed(JCArrayAccess that) {
 332  0
          super.visitIndexed(that);
 333  0
         assertUnique(that);
 334  0
         that.type = null;
 335  0
     }
 336  
     
 337  
     @Override
 338  
     public void visitSelect(JCFieldAccess that) {
 339  136054
         super.visitSelect(that);
 340  136054
         assertUnique(that);
 341  136054
         that.type = null;
 342  136054
         that.sym = null;
 343  136054
     }
 344  
     
 345  
     @Override
 346  
     public void visitIdent(JCIdent that) {
 347  68045
         super.visitIdent(that);
 348  68045
         assertUnique(that);
 349  68045
         that.type = null;
 350  68045
         that.sym = null;
 351  68045
     }
 352  
     
 353  
     @Override
 354  
     public void visitLiteral(JCLiteral that) {
 355  12550
         super.visitLiteral(that);
 356  12550
         assertUnique(that);
 357  12550
         that.type = null;
 358  12550
     }
 359  
     
 360  
     @Override
 361  
     public void visitTypeIdent(JCPrimitiveTypeTree that) {
 362  9132
         super.visitTypeIdent(that);
 363  9132
         assertUnique(that);
 364  9132
         that.type = null;
 365  9132
     }
 366  
     
 367  
     @Override
 368  
     public void visitTypeArray(JCArrayTypeTree that) {
 369  494
         super.visitTypeArray(that);
 370  494
         assertUnique(that);
 371  494
         that.type = null;
 372  494
     }
 373  
     
 374  
     @Override
 375  
     public void visitTypeApply(JCTypeApply that) {
 376  4826
         super.visitTypeApply(that);
 377  4826
         assertUnique(that);
 378  4826
         that.type = null;
 379  4826
     }
 380  
     
 381  
     @Override
 382  
     public void visitTypeParameter(JCTypeParameter that) {
 383  0
         super.visitTypeParameter(that);
 384  0
         assertUnique(that);
 385  0
         that.type = null;
 386  0
     }
 387  
     
 388  
     @Override
 389  
     public void visitWildcard(JCWildcard that) {
 390  1174
         super.visitWildcard(that);
 391  1174
         assertUnique(that);
 392  1174
         that.type = null;
 393  1174
     }
 394  
     
 395  
     @Override
 396  
     public void visitTypeBoundKind(TypeBoundKind that) {
 397  1174
          super.visitTypeBoundKind(that);
 398  1174
         assertUnique(that);
 399  1174
         that.type = null;
 400  1174
     }
 401  
     
 402  
     @Override
 403  
     public void visitAnnotation(JCAnnotation that) {
 404  2694
         super.visitAnnotation(that);
 405  2694
         assertUnique(that);
 406  2694
         that.type = null;
 407  2694
     }
 408  
     
 409  
     @Override
 410  
     public void visitModifiers(JCModifiers that) {
 411  22579
         super.visitModifiers(that);
 412  22579
         assertUnique(that);
 413  22579
         that.type = null;
 414  22579
     }
 415  
     
 416  
     @Override
 417  
     public void visitErroneous(JCErroneous that) {
 418  0
         super.visitErroneous(that);
 419  0
         assertUnique(that);
 420  0
         that.type = null;
 421  0
     }
 422  
     
 423  
     @Override
 424  
     public void visitLetExpr(LetExpr that) {
 425  0
         super.visitLetExpr(that);
 426  0
         assertUnique(that);
 427  0
         that.type = null;
 428  0
     }
 429  
 
 430  
     public void visitBlockExpression(JFXBlockExpression that) {
 431  1198
         assertUnique(that);
 432  1198
         scan(that.stats);
 433  1198
         scan(that.value);
 434  1198
         that.type = null;
 435  1198
     }
 436  
 }