Package org.allspice.structured

Examples of org.allspice.structured.MethodDecl


        FieldDecl fdec = (FieldDecl)fom ;
        StubResolver fldstub = new SimpleResolver(finfo.getFullQualified(fdec.type)) ;
        stub = stub.addField(new FieldStub(fdec.name,enclosing,fldstub,fdec.fieldAttrs.isStatic,false,fdec.intializer));
      }
      else if (fom instanceof MethodDecl) {
        MethodDecl mdec = (MethodDecl)fom ;
        FIFO<StubResolver> types = new FIFO<StubResolver>() ;
        for(VarDecl vd: mdec.parameters) {
          types = types.insert(new SimpleResolver(finfo.getFullQualified(vd.type))) ;
        }
        boolean isStatic = false ;
View Full Code Here


      boolean foundInit = false ;
      FieldAttrs fa = new FieldAttrs().setVisibility(Visibility.PUBLIC).setStatic(true) ;
      ImmutableCollection<Statement> body = new FIFO<Statement>() ;
      for(FieldOrMethod fom: cdecl.decls) {
        if (fom instanceof MethodDecl) {
          MethodDecl mdd = (MethodDecl)fom ;
          if (mdd.name.equals("<clinit>")) {
            body = body.insertAll(mdd.body) ;
            continue ;
          }
          try {
            MethodDef def = getDef(converter,classPool,cdecl,mdd,fuinfo,fdcls,errors);
            if (def.name.equals("<init>")) {
              foundInit = true ;
            }
            cd = cd.addMethod(def) ;
          } catch (CompilerException e) {
            errors.add(e) ;
          }
        }
        else if (fom instanceof FieldDecl) {
          FieldDecl fdecl = (FieldDecl)fom ;
          if (fdecl.fieldAttrs.isStatic && fdecl.intializer != null) {
            SetValueExpr se = new SetValueExpr(new FieldVarExpr(cname.toString(),fdecl.name,null),fdecl.intializer,null) ;
            body = body.insert(new ExprStatement(se,null)) ;         
          }
        }
      }
      MethodDecl clinit = new MethodDecl(fa,"void","<clinit>",new FIFO<VarDecl>(),new FIFO<String>(),body) ;
      if (!foundInit && cdecl.classType != ClassType.INTERFACE) {
        FieldAttrs ifa = new FieldAttrs().setVisibility(Visibility.PUBLIC) ;
        MethodDecl mdd = new MethodDecl(ifa,"void","<init>",new FIFO<VarDecl>(),new FIFO<String>(),new FIFO<Statement>()) ;
        try {
          cd = cd.addMethod(getDef(converter,classPool,cdecl,mdd,fuinfo,fdcls,errors)) ;
        } catch (CompilerException e) {
          errors.add(e) ;
        }
View Full Code Here

**/
private static final ImmutableCollection<FieldOrMethod> reduce30(PositionRange range,Parser parser,ParserState state) {
      ImmutableCollection<Statement> compoundstatement = (ImmutableCollection<Statement>)state.reductions.head.o ;
{
  FieldAttrs fa = new FieldAttrs().setStatic(true) ;
  MethodDecl decl = new MethodDecl(fa,"void","<clinit>",new FIFO<VarDecl>(), new FIFO<String>(), compoundstatement) ;
  return new FIFO<FieldOrMethod>(decl) ;
}
}
View Full Code Here

      String ID = (String)state.reductions.tail.tail.tail.tail.tail.head.o ;
      ImmutableCollection<VarDecl> parameterlist_opt = (ImmutableCollection<VarDecl>)state.reductions.tail.tail.tail.head.o ;
      ImmutableCollection<String> throws_opt = (ImmutableCollection<String>)state.reductions.tail.head.o ;
      ImmutableCollection<Statement> compoundstatement = (ImmutableCollection<Statement>)state.reductions.head.o ;
{
  MethodDecl decl = new MethodDecl(fieldattrs,"void","<init>",parameterlist_opt, throws_opt, compoundstatement,ID) ;
  return new FIFO<FieldOrMethod>(decl) ;
}
}
View Full Code Here

      String ID = (String)state.reductions.tail.tail.tail.tail.tail.head.o ;
      ImmutableCollection<VarDecl> parameterlist_opt = (ImmutableCollection<VarDecl>)state.reductions.tail.tail.tail.head.o ;
      ImmutableCollection<String> throws_opt = (ImmutableCollection<String>)state.reductions.tail.head.o ;
      ImmutableCollection<Statement> compoundstatement = (ImmutableCollection<Statement>)state.reductions.head.o ;
{
  MethodDecl methodDecl = new MethodDecl(fieldattrs,type,ID,parameterlist_opt, throws_opt,compoundstatement);
  return new FIFO<FieldOrMethod>(methodDecl) ;
}
}
View Full Code Here

      String type = (String)state.reductions.tail.tail.tail.tail.tail.tail.head.o ;
      String ID = (String)state.reductions.tail.tail.tail.tail.tail.head.o ;
      ImmutableCollection<VarDecl> parameterlist_opt = (ImmutableCollection<VarDecl>)state.reductions.tail.tail.tail.head.o ;
      ImmutableCollection<String> throws_opt = (ImmutableCollection<String>)state.reductions.tail.head.o ;
{
  MethodDecl methodDecl = new MethodDecl(fieldattrs.setAbstract(true),type,ID,parameterlist_opt, throws_opt, new FIFO<Statement>());
  return new FIFO<FieldOrMethod>(methodDecl) ;
}
}
View Full Code Here

      for(Class<?> arg: meth.getParameterTypes()) {
        vars = vars.insert(new VarDecl(getName(arg),"arg"+i)) ;
        i++ ;
      }
      FieldAttrs fa = new FieldAttrs().setVisibility(Visibility.PUBLIC) ;
      meths = meths.insert(new MethodDecl(fa,returnType,name,vars, new FIFO<String>(),new FIFO<Statement>(stats))) ;
    }
    ClassDecl cd = new ClassDecl(Visibility.PUBLIC,ClassType.DEFAULT,"NewClass","java.lang.Object",new FIFO<String>(iface.getName()),meths) ;
    FileUnit fu = new FileUnit().addClassDecl(cd).setPackageName("org.allspice.structuredtobc.test") ;
    ClassLoader loader = ClassConverter.createLoader(StdJavaExpressions.INSTANCE,new FIFO<FileUnit>(fu)) ;
    Class<?> cl = loader.loadClass(ClassPool.getClassName(fu,cd).toString()) ;
View Full Code Here

TOP

Related Classes of org.allspice.structured.MethodDecl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.