|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ConstructorCall.java | 75% | 69.2% | 60% | 66.7% |
|
||||||||||||||
| 1 | /* | |
| 2 | * DynamicJava - Copyright (C) 1999-2001 | |
| 3 | * | |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 | * copy of this software and associated documentation files | |
| 6 | * (the "Software"), to deal in the Software without restriction, including | |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, | |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 | * persons to whom the Software is furnished to do so, subject to the | |
| 10 | * following conditions: | |
| 11 | * The above copyright notice and this permission notice shall be included | |
| 12 | * in all copies or substantial portions of the Software. | |
| 13 | * | |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 17 | * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 20 | * DEALINGS IN THE SOFTWARE. | |
| 21 | * | |
| 22 | * Except as contained in this notice, the name of Dyade shall not be | |
| 23 | * used in advertising or otherwise to promote the sale, use or other | |
| 24 | * dealings in this Software without prior written authorization from | |
| 25 | * Dyade. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | package koala.dynamicjava.tree; | |
| 30 | ||
| 31 | import java.util.*; | |
| 32 | ||
| 33 | import koala.dynamicjava.tree.visitor.*; | |
| 34 | ||
| 35 | /** | |
| 36 | * This class represents the constructor call nodes of the syntax tree | |
| 37 | * | |
| 38 | * @author Stephane Hillion | |
| 39 | * @version 1.0 - 1999/04/24 | |
| 40 | */ | |
| 41 | ||
| 42 | public class ConstructorCall extends PrimaryExpression implements ExpressionContainer, StatementExpression { | |
| 43 | /** | |
| 44 | * The prefix expression | |
| 45 | */ | |
| 46 | private Expression expression; | |
| 47 | ||
| 48 | /** | |
| 49 | * The arguments | |
| 50 | */ | |
| 51 | private List<Expression> arguments; | |
| 52 | ||
| 53 | /** | |
| 54 | * Whether this invocation is 'super' or 'this' | |
| 55 | */ | |
| 56 | private boolean superCall; | |
| 57 | ||
| 58 | /** | |
| 59 | * Creates a new node | |
| 60 | * @param exp the prefix expression | |
| 61 | * @param args the arguments. null if there are no argument. | |
| 62 | * @param sup whether this invocation is 'super' or 'this' | |
| 63 | */ | |
| 64 | 23 | public ConstructorCall(Expression exp, List<? extends Expression> args, boolean sup) { |
| 65 | 23 | this(exp, args, sup, SourceInfo.NONE); |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Creates a new node | |
| 70 | * @param exp the prefix expression | |
| 71 | * @param args the arguments. null if there are no argument. | |
| 72 | * @param sup whether this invocation is 'super' or 'this' | |
| 73 | */ | |
| 74 | 69 | public ConstructorCall(Expression exp, List<? extends Expression> args, boolean sup, |
| 75 | SourceInfo si) { | |
| 76 | 69 | super(si); |
| 77 | ||
| 78 | 69 | expression = exp; |
| 79 | 69 | arguments = (args == null) ? new ArrayList<Expression>(0) : new ArrayList<Expression>(args); |
| 80 | 69 | superCall = sup; |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * Returns the prefix expression if one, or null otherwise | |
| 85 | */ | |
| 86 | 76 | public Expression getExpression() { |
| 87 | 76 | return expression; |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * Sets the prefix expression | |
| 92 | */ | |
| 93 | 0 | public void setExpression(Expression e) { |
| 94 | 0 | expression = e; |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * Returns the arguments | |
| 99 | */ | |
| 100 | 86 | public List<Expression> getArguments() { |
| 101 | 86 | return arguments; |
| 102 | } | |
| 103 | ||
| 104 | /** | |
| 105 | * Sets the arguments | |
| 106 | */ | |
| 107 | 69 | public void setArguments(List<? extends Expression> l) { |
| 108 | 69 | arguments = (l == null) ? new ArrayList<Expression>(0) : new ArrayList<Expression>(l); |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Returns true is this invocation is a 'super' or a 'this' invocation | |
| 113 | */ | |
| 114 | 76 | public boolean isSuper() { |
| 115 | 76 | return superCall; |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * Sets the super property | |
| 120 | */ | |
| 121 | 0 | public void setSuper(boolean b) { |
| 122 | 0 | superCall = b; |
| 123 | } | |
| 124 | ||
| 125 | /** | |
| 126 | * Allows a visitor to traverse the tree | |
| 127 | * @param visitor the visitor to accept | |
| 128 | */ | |
| 129 | 0 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 130 | 0 | return visitor.visit(this); |
| 131 | } | |
| 132 | /** | |
| 133 | * Implementation of toString for use in unit testing | |
| 134 | */ | |
| 135 | 0 | public String toString() { |
| 136 | 0 | return "("+getClass().getName()+": "+getExpression()+" "+getArguments()+" "+isSuper()+")"; |
| 137 | } | |
| 138 | } |
|
||||||||||