Coverage Report - com.sun.tools.javafx.tree.JFXFunctionDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
JFXFunctionDefinition
83%
24/29
12%
1/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.tree;
 27  
 
 28  
 import com.sun.javafx.api.tree.JavaFXTree.JavaFXKind;
 29  
 import com.sun.javafx.api.tree.JavaFXTreeVisitor;
 30  
 import com.sun.javafx.api.tree.FunctionDefinitionTree;
 31  
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
 32  
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
 33  
 import com.sun.tools.javac.util.List;
 34  
 import com.sun.tools.javac.util.Name;
 35  
 import com.sun.tools.javac.tree.Pretty;
 36  
 import com.sun.tools.javac.tree.JCTree.*;
 37  
 import com.sun.tools.javafx.code.JavafxFlags;
 38  
 
 39  
 /**
 40  
  * A function definition.
 41  
  */
 42  16
 public class JFXFunctionDefinition extends JFXStatement implements FunctionDefinitionTree {
 43  
     public final JCModifiers mods;
 44  
     public final Name name;
 45  
     public final JFXFunctionValue operation;
 46  
     public MethodSymbol sym;
 47  
 
 48  
     public JFXFunctionDefinition(
 49  
             JCModifiers mods, 
 50  
             Name name,
 51  174
             JFXFunctionValue operation) {
 52  174
         this.mods = mods;
 53  174
         this.name = name;
 54  174
         this.operation = operation;
 55  174
     }
 56  
 
 57  
     protected JFXFunctionDefinition(
 58  
             JCModifiers mods, 
 59  
             Name name, 
 60  
             JFXType rettype, 
 61  
             List<JFXVar> funParams, 
 62  1073
             JFXBlockExpression bodyExpression) {
 63  1073
         this.mods = mods;
 64  1073
         this.name = name;
 65  1073
         this.operation = new JFXFunctionValue(rettype, funParams, bodyExpression);
 66  1073
     }
 67  
     
 68  
     public JFXBlockExpression getBodyExpression() {
 69  2769
         return operation.getBodyExpression();
 70  
     }
 71  2813
     public JCModifiers getModifiers() { return mods; }
 72  0
     public boolean isBound() { return (mods.flags & JavafxFlags.BOUND) != 0; }
 73  345
     public Name getName() { return name; }
 74  3549
     public JFXType getJFXReturnType() { return operation.rettype; }
 75  3681
     public List<JFXVar> getParameters() { return operation.funParams; }
 76  
     public JFXFunctionValue getFunctionValue() {
 77  1068
         return operation;
 78  
     }
 79  
 
 80  
     public void accept(JavafxVisitor v) {
 81  7485
         v.visitFunctionDefinition(this);
 82  7482
     }
 83  
 
 84  
     @Override
 85  
     public void accept(Visitor v) {
 86  7485
         if (v instanceof JavafxVisitor) {
 87  7485
             this.accept((JavafxVisitor)v);
 88  0
         } else if (v instanceof Pretty) {
 89  0
             JavafxPretty.visitFunctionDefinition((Pretty) v, this);
 90  
         } else {
 91  0
             assert false;
 92  
         }
 93  7482
     }
 94  
 
 95  
     @Override
 96  
     public int getTag() {
 97  14737
         return JavafxTag.FUNCTION_DEF;
 98  
     }
 99  
 
 100  
     public JavaFXKind getJavaFXKind() {
 101  0
         return JavaFXKind.FUNCTION_DEFINITION;
 102  
     }
 103  
 
 104  
     public <R, D> R accept(JavaFXTreeVisitor<R, D> visitor, D data) {
 105  3
         return visitor.visitFunctionDefinition(this, data);
 106  
     }
 107  
 }