1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.FlowCheckerPass; 28 import org.aspectj.compiler.base.JavaCompiler; 29 import org.aspectj.compiler.base.CodeWriter; 30 import java.io.IOException ; 31 32 import java.util.*; 33 34 import org.aspectj.compiler.base.bcg.CodeBuilder; 35 import org.aspectj.compiler.base.bcg.Label; 36 37 42 43 public class Exprs extends Expr { 44 45 public Type discoverType() { 46 return getTypeManager().voidType; 47 } 48 49 public Exprs(SourceLocation source, int n) { 50 this(source,new Expr[n]); 51 } 52 53 public void unparse(CodeWriter writer) throws IOException { 54 writer.writeChildrenWithCommas(this); 55 } 56 57 60 void cgValues(CodeBuilder cb, Formals fs) { 61 for (int i = 0, len = size; i < len; i++) { 62 children[i].cgValue(cb, fs.get(i).getType()); 63 } 64 } 65 void cgEffects(CodeBuilder cb) { 66 for (int i = 0, len = size; i < len; i++) { 67 children[i].cgEffect(cb); 68 } 69 } 70 71 protected int size; 73 public Expr[] children; 74 75 public Exprs(SourceLocation location, Expr[] _children) { 76 super(location); 77 for(int i=0; i<_children.length; i++) { 78 if (_children[i] != null) _children[i].setParent(this); 79 } 80 children = _children; 81 size = _children.length; 82 } 83 84 public Exprs(SourceLocation location) { 85 this(location, new Expr[] {}); 86 } 87 88 public Exprs(SourceLocation location, Expr child1) { 89 this(location, new Expr[] {child1}); 90 } 91 92 public Exprs(SourceLocation location, Expr child1, Expr child2) { 93 this(location, new Expr[] {child1, child2}); 94 } 95 96 public Exprs(SourceLocation location, Expr child1, Expr child2, Expr child3) { 97 this(location, new Expr[] {child1, child2, child3}); 98 } 99 100 public ASTObject copyWalk(CopyWalker walker) { 101 final int N = size; 102 Expr[] copiedChildren = new Expr[N]; 103 int newIndex = 0; 104 for(int oldIndex=0; oldIndex<N; oldIndex++) { 105 Expr newChild = (Expr)walker.process(children[oldIndex]); 106 if (newChild != null) copiedChildren[newIndex++] = newChild; 107 } 108 Exprs ret = new Exprs(getSourceLocation(),copiedChildren); 109 ret.size = newIndex; 110 ret.setSource(this); 111 return ret; 112 } 113 114 public ASTObject getChildAt(int childIndex) { return get(childIndex); } 115 public void setChildAt(int childIndex, ASTObject child) { set(childIndex, (Expr)child); } 116 public String getChildNameAt(int childIndex) { return "expr"+childIndex; } 117 118 public int getChildCount() { return size; } 119 public int size() { return size; } 120 121 public Expr get(int index) { 122 if (index >= size) throw new ArrayIndexOutOfBoundsException (); 123 return children[index]; 124 } 125 126 public void set(int index, Expr child) { 127 if (index >= size) throw new ArrayIndexOutOfBoundsException (); 128 children[index] = child; 129 child.setParent(this); 130 } 131 132 public void resize(int newSize) { 133 if (newSize > children.length) { 134 Expr[] newChildren = new Expr[children.length*2 + 1]; 135 System.arraycopy(children, 0, newChildren, 0, children.length); 136 children = newChildren; 137 } 138 size = newSize; 139 } 140 141 public void addAll(Exprs collection) { 142 addAll(size, collection); 143 } 144 145 public void addAll(int index, Exprs collection) { 146 for(int i=0; i<collection.size(); i++) { 147 add(index+i, collection.get(i)); 148 } 149 } 150 151 public void add(Expr child) { 152 add(size, child); 153 } 154 155 public void add(int index, Expr child) { 156 if (child == null) return; 157 158 if (index < 0 || index > size) throw new ArrayIndexOutOfBoundsException (); 159 160 resize(size+1); 161 162 for(int moveIndex = size-1; moveIndex > index; moveIndex--) { 163 children[moveIndex] = children[moveIndex-1]; 164 } 165 166 children[index] = child; 167 child.setParent(this); 168 } 169 170 public void remove(int index) { 171 if (index < 0 || index > size) throw new ArrayIndexOutOfBoundsException (); 172 173 size -= 1; 174 175 for(int moveIndex = index; moveIndex < size; moveIndex++) { 176 children[moveIndex] = children[moveIndex+1]; 177 } 178 } 179 180 public String getDefaultDisplayName() { 181 return "Exprs()"; 182 } 183 184 } 186 | Popular Tags |