|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AnonymousInnerAllocation.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 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 edu.rice.cs.plt.tuple.Option; | |
| 34 | ||
| 35 | import koala.dynamicjava.tree.visitor.*; | |
| 36 | ||
| 37 | /** | |
| 38 | * This class represents the anonymous allocation nodes that extend an inner class. | |
| 39 | * Nodes are derived from syntax like "a.makeOuter().new Foo(x, y+3, z.method()) { void bar() {} }" | |
| 40 | * | |
| 41 | * @author Stephane Hillion | |
| 42 | * @version 1.0 - 1999/05/25 | |
| 43 | */ | |
| 44 | ||
| 45 | public class AnonymousInnerAllocation extends InnerAllocation { | |
| 46 | ||
| 47 | /** | |
| 48 | * The members property name | |
| 49 | */ | |
| 50 | public final static String MEMBERS = "members"; | |
| 51 | ||
| 52 | /** | |
| 53 | * The members of the anonymous class | |
| 54 | */ | |
| 55 | private List<Node> members; | |
| 56 | ||
| 57 | /** | |
| 58 | * Initializes the expression | |
| 59 | * @param exp the outer object | |
| 60 | * @param targs constructor type arguments | |
| 61 | * @param cn the inner class name | |
| 62 | * @param ctargs class type arguments | |
| 63 | * @param args the arguments of the constructor. Can be null. | |
| 64 | * @param memb the members of the class | |
| 65 | */ | |
| 66 | 0 | public AnonymousInnerAllocation(Expression exp, Option<List<TypeName>> targs, String cn, |
| 67 | Option<List<TypeName>> ctargs, List<? extends Expression> args, List<Node> memb) { | |
| 68 | 0 | this(exp, targs, cn, ctargs, args, memb, SourceInfo.NONE); |
| 69 | } | |
| 70 | ||
| 71 | /** | |
| 72 | * Initializes the expression | |
| 73 | * @param exp the outer object | |
| 74 | * @param targs constructor type arguments | |
| 75 | * @param cn the inner class name | |
| 76 | * @param ctargs class type arguments | |
| 77 | * @param args the arguments of the constructor. Can be null. | |
| 78 | * @param memb the members of the class | |
| 79 | */ | |
| 80 | 0 | public AnonymousInnerAllocation(Expression exp, Option<List<TypeName>> targs, String cn, |
| 81 | Option<List<TypeName>> ctargs, List<? extends Expression> args, List<Node> memb, | |
| 82 | SourceInfo si) { | |
| 83 | 0 | super(exp, targs, cn, ctargs, args, si); |
| 84 | 0 | if (memb == null) throw new IllegalArgumentException("memb == null"); |
| 85 | 0 | members = memb; |
| 86 | } | |
| 87 | ||
| 88 | /** Returns the members of the anonymous class */ | |
| 89 | 0 | public List<Node> getMembers() { return members; } |
| 90 | ||
| 91 | /** | |
| 92 | * Sets the members of the anonymous class | |
| 93 | * @exception IllegalArgumentException if l is null | |
| 94 | */ | |
| 95 | 0 | public void setMembers(List<Node> l) { |
| 96 | 0 | if (l == null) throw new IllegalArgumentException("l == null"); |
| 97 | 0 | members = l; |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Allows a visitor to traverse the tree | |
| 102 | * @param visitor the visitor to accept | |
| 103 | */ | |
| 104 | 0 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 105 | 0 | return visitor.visit(this); |
| 106 | } | |
| 107 | /** | |
| 108 | * Implementation of toString for use in unit testing | |
| 109 | */ | |
| 110 | 0 | public String toString() { |
| 111 | 0 | return "("+getClass().getName()+": "+getTypeArgs()+" "+getClassName()+" "+getClassTypeArgs()+" "+getExpression()+ |
| 112 | " "+getArguments()+" "+getMembers()+")"; | |
| 113 | } | |
| 114 | } |
|
||||||||||