| 1 19 20 package soot.javaToJimple.jj.ast; 21 22 import polyglot.ast.*; 23 import polyglot.types.*; 24 import polyglot.visit.*; 25 import polyglot.util.*; 26 import polyglot.ext.jl.ast.*; 27 import java.util.*; 28 29 public class JjArrayInit_c extends ArrayInit_c { 30 31 public JjArrayInit_c(Position pos, List elements) { 32 super(pos, elements); 33 } 34 35 public Type childExpectedType(Expr child, AscriptionVisitor av){ 36 if (elements.isEmpty()) { 37 return child.type(); 38 } 39 40 Type t = av.toType(); 41 42 if (t == null) { 44 return child.type(); 46 } 47 if (! t.isArray()) { 48 throw new InternalCompilerError("Type of array initializer must be " + 49 "an array.", position()); 50 } 51 52 t = t.toArray().base(); 53 54 for (Iterator i = elements.iterator(); i.hasNext(); ) { 55 Expr e = (Expr) i.next(); 56 57 if (e == child) { 58 return t; 59 } 60 } 61 62 return child.type(); 63 } 64 } 65 | Popular Tags |