@Override
 public Void visit(InitializerDeclaration decl, AElement elem) {
   BlockStmt block = decl.getBlock();
   AClass clazz = (AClass) elem;
   block.accept(this, clazz.methods.vivify(decl.isStatic() ? "<clinit>" : "<init>"));
   return null;
 }
 @Override
 public Void visit(ConstructorDeclaration decl, AElement elem) {
   int i = 0;
   List<Parameter> params = decl.getParameters();
   List<AnnotationExpr> rcvrAnnos = decl.getReceiverAnnotations();
   BlockStmt body = decl.getBlock();
   StringBuilder sb = new StringBuilder("<init>(");
   AClass clazz = (AClass) elem;
   AMethod method;
   if (params != null) {
     for (Parameter param : params) {
       Type ptype = param.getType();
       sb.append(getJVML(ptype));
     }
   }
   sb.append(")V");
   method = clazz.methods.vivify(sb.toString());
   visitDecl(decl, method);
   if (params != null) {
     for (Parameter param : params) {
       AField field = method.parameters.vivify(i++);
       visitType(param.getType(), field.type);
     }
   }
   if (rcvrAnnos != null) {
     for (AnnotationExpr expr : rcvrAnnos) {
       Annotation anno = extractAnnotation(expr);
       method.receiver.tlAnnotationsHere.add(anno);
     }
   }
   return body == null ? null : body.accept(this, method);
   // return super.visit(decl, elem);
 }
Пример #3
0
 @Override
 public void visit(BlockStmt n, Object arg) {
   printer.printLn("{");
   if (n.getStmts() != null) {
     printer.indent();
     for (Statement s : n.getStmts()) {
       s.accept(this, arg);
       printer.printLn();
     }
     printer.unindent();
   }
   printer.print("}");
 }
 @Override
 public Void visit(MethodDeclaration decl, AElement elem) {
   Type type = decl.getType();
   List<Parameter> params = decl.getParameters();
   List<TypeParameter> typeParams = decl.getTypeParameters();
   List<AnnotationExpr> rcvrAnnos = decl.getReceiverAnnotations();
   BlockStmt body = decl.getBody();
   StringBuilder sb = new StringBuilder(decl.getName()).append('(');
   AClass clazz = (AClass) elem;
   AMethod method;
   if (params != null) {
     for (Parameter param : params) {
       Type ptype = param.getType();
       sb.append(getJVML(ptype));
     }
   }
   sb.append(')').append(getJVML(type));
   method = clazz.methods.vivify(sb.toString());
   visitDecl(decl, method);
   visitType(type, method.returnType);
   if (params != null) {
     int i = 0;
     for (Parameter param : params) {
       AField field = method.parameters.vivify(i++);
       visitType(param.getType(), field.type);
     }
   }
   if (rcvrAnnos != null) {
     for (AnnotationExpr expr : rcvrAnnos) {
       Annotation anno = extractAnnotation(expr);
       method.receiver.type.tlAnnotationsHere.add(anno);
     }
   }
   if (typeParams != null) {
     int i = 0;
     for (TypeParameter typeParam : typeParams) {
       List<ClassOrInterfaceType> bounds = typeParam.getTypeBound();
       if (bounds != null) {
         int j = 0;
         for (ClassOrInterfaceType bound : bounds) {
           BoundLocation loc = new BoundLocation(i, j);
           bound.accept(this, method.bounds.vivify(loc));
           ++j;
         }
       }
       ++i;
     }
   }
   return body == null ? null : body.accept(this, method);
 }