1 package soot.javaToJimple; 2 3 import java.util.*; 4 5 public class AnonConstructorFinder extends polyglot.visit.ContextVisitor { 6 7 public AnonConstructorFinder(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf) { 8 super(job, ts, nf); 9 } 10 11 public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n){ 12 if (n instanceof polyglot.ast.New && ((polyglot.ast.New)n).anonType() != null){ 13 try { 14 List argTypes = new ArrayList(); 15 for (Iterator it = ((polyglot.ast.New)n).arguments().iterator(); it.hasNext(); ){ 16 argTypes.add(((polyglot.ast.Expr)it.next()).type()); 17 } 18 polyglot.types.ConstructorInstance ci = typeSystem().findConstructor(((polyglot.ast.New)n).anonType().superType().toClass(), argTypes, ((polyglot.ast.New)n).anonType().superType().toClass()); 19 InitialResolver.v().addToAnonConstructorMap((polyglot.ast.New)n, ci); 20 } 21 catch(polyglot.types.SemanticException e){ 22 System.out.println(e.getMessage()); 23 e.printStackTrace(); 24 } 25 } 26 return this; 27 } 28 29 } 30 | Popular Tags |