Package org.allspice.structured

Examples of org.allspice.structured.FieldAttrs


            errors.add(e) ;
          }
        }
      }
      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


  public static MethodDef makeMethDef(MethodDecl mdecl,
      EvaluationContext context,FileUnitInfo fuinfo,
      Collection<Exception> errors) throws CompilerException {
    Collection<TypeName> vars = StdJavaExpressions.createParameters(fuinfo,mdecl.parameters);
    final TypeName retType = fuinfo.getFullQualified(mdecl.returnType);
    final FieldAttrs fieldAttrs = mdecl.fieldAttrs;
    Scope scope =
        fieldAttrs.visibility == Visibility.PUBLIC ? Scope.PUBLIC :
        fieldAttrs.visibility == Visibility.PROTECTED ? Scope.PROTECTED :
        fieldAttrs.visibility == Visibility.PRIVATE ? Scope.PRIVATE :
        Scope.PROTECTED ;
View Full Code Here

  }

  public static FieldDef getDef(StdJavaExpressions converter,ClassPool classPool,ClassDecl classDecl,FieldDecl fdecl,FileUnitInfo fuinfo) throws CompilerException {
    ConstObj o ;
    Expr init = fdecl.intializer ;
    final FieldAttrs fieldAttrs = fdecl.fieldAttrs;
    if (init != null && fieldAttrs.isFinal) {
      StubResolver stub = classPool.new SimpleResolver(ClassPool.getClassName(fuinfo.unit,classDecl)) ;
      EvaluationContext context = new EvaluationContext(converter,classPool,fuinfo.unit,stub) ;
      o = context.getConst(init) ;   
    }
View Full Code Here

      int i = 0 ;
      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)) ;
View Full Code Here

* @param state
* @return The object
**/
private static final FieldAttrs reduce1(PositionRange range,Parser parser,ParserState state) {
{
    return new FieldAttrs() ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FieldAttrs reduce2(PositionRange range,Parser parser,ParserState state) {
      FieldAttrs fieldattrs = (FieldAttrs)state.reductions.head.o ;
{
    return fieldattrs.setStatic(true) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FieldAttrs reduce3(PositionRange range,Parser parser,ParserState state) {
      FieldAttrs fieldattrs = (FieldAttrs)state.reductions.head.o ;
{
    return fieldattrs.setFinal(true) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FieldAttrs reduce4(PositionRange range,Parser parser,ParserState state) {
      FieldAttrs fieldattrs = (FieldAttrs)state.reductions.head.o ;
{
    return fieldattrs.setAbstract(true) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FieldAttrs reduce5(PositionRange range,Parser parser,ParserState state) {
      FieldAttrs fieldattrs = (FieldAttrs)state.reductions.head.o ;
{
    return fieldattrs.setVisibility(Visibility.PUBLIC) ;
}
}
View Full Code Here

* @param parser
* @param state
* @return The object
**/
private static final FieldAttrs reduce6(PositionRange range,Parser parser,ParserState state) {
      FieldAttrs fieldattrs = (FieldAttrs)state.reductions.head.o ;
{
    return fieldattrs.setNative(true) ;
}
}
View Full Code Here

TOP

Related Classes of org.allspice.structured.FieldAttrs

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.