Package org.allspice.bytecode

Examples of org.allspice.bytecode.TypeName


              if (!ignoreIfPresent) {
                aliases.put(item,null) ;
              }
            }
            else {
              aliases.put(item,new TypeName(prefix+item)) ;
            }
          }
        }
        else if (items.contains(s)) {
          if (aliases.containsKey(s)) {
            if (!ignoreIfPresent) {
              aliases.put(s,null) ;
            }
          }
          else {
            aliases.put(s,new TypeName(prefix+s)) ;
          }
        }
      }
    }
View Full Code Here


    List<ClassDef> defs = new ArrayList<ClassDef>() ;
    Collection<Exception> errors = new ArrayList<Exception>() ;
    for(ClassDecl cdecl: fu.classDecl) {
      ClassDef cd ;
      FileUnitInfo fuinfo = classPool.findFileUnit(fu) ;
      TypeName cname = ClassPool.getClassName(fu,cdecl) ;
      switch(cdecl.classType) {
      case ABSTRACT:
        cd = new ClassDef(ClassDefType.ABSTRACT,fu.filename,cname,fuinfo.getFullQualified(cdecl.superClass)) ;
        break ;
      case INTERFACE:
        cd = new ClassDef(ClassDefType.INTERFACE,fu.filename,cname,fuinfo.getFullQualified(cdecl.superClass)) ;
        break ;
      default:
        cd = new ClassDef(ClassDefType.DEFAULT,fu.filename,cname,fuinfo.getFullQualified(cdecl.superClass)) ;
        break ;
      }
      VarStack fdcls = new VarStack() ;
      try {
        fdcls = StdJavaExpressions.makeFieldDecls(classPool,classPool.new SimpleResolver(cname),fdcls);
      } catch (CompilerException e) {
        errors.add(e) ;
      }
      for(String iface: cdecl.interfaces) {
        cd = cd.addInterface(fuinfo.getFullQualified(iface)) ;
      }
      for(FieldOrMethod fom: cdecl.decls) {
        if (fom instanceof FieldDecl) {
          try {
            cd = cd.addField(getDef(converter,classPool,cdecl,(FieldDecl)fom,fuinfo)) ;
          } catch (CompilerException e) {
            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) ;
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 :
View Full Code Here

   */
  public static Type makeType(TypeName type) {
    switch(TypeCode.getType(type)) {
    case ARRAY: {
      int numdim = 1 ;
      TypeName base = type.getArrayBase() ;
      while(base.isArray()) {
        numdim++ ;
        base = base.getArrayBase() ;
      }
      return new ArrayType(makeType(base),numdim) ;
    }
    case BOOLEAN: return Type.BOOLEAN ;
    case BYTE: return Type.BYTE ;
View Full Code Here

  public VarStack addLocalVar(FileUnitInfo fuinfo,Collection<? extends VarDecl> varDecls) {
    VarStack vs = this ;
    for(VarDecl varDecl: varDecls) {
      String t = varDecl.type ;
      TypeCode type = TypeCode.getType(t) ;
      TypeName fqtype = fuinfo.getFullQualified(t) ;
      vs = new VarStack(vs.nextVar + type.wordSize,vs.decls.insert(varDecl.name, new Var(vs.nextVar,fqtype))) ;
    }
    return vs ;
  }
View Full Code Here

import org.allspice.bytecode.instructions.ShiftLeft;

public class TestSHL extends MyTestCase {
  public ClassDef defadd(String ret,String type,int i1,int i2) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    Var y = new Var(i2,TypeName.INT) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new ShiftLeft(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
View Full Code Here

public class TestNewArray extends MyTestCase {
  public ClassDef defadd(String type) {
    ClassDef cd = makeClassDef() ;
    {
      MethodDef md = new MethodDef(new TypeName(type+"[]"),"getFoo") ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new Const(10),
          new New(new TypeName(type),1),
          new Return(TypeCode.ARRAY)
          ) ;
      cd = cd.addMethod(md) ;
    }
    return cd ;
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFLT extends MyTestCase {
  public ClassDef defadd(String type,int i1,int i2) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    Var y = new Var(i2,new TypeName(type)) ;
    MethodDef md = new MethodDef(TypeName.BOOLEAN,"meth",x,y) ;
    Mark one = new Mark() ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
View Full Code Here

import org.allspice.bytecode.instructions.ShiftRight;

public class TestSHR extends MyTestCase {
  public ClassDef defadd(String ret,String type,int i1,int i2) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    Var y = new Var(i2,TypeName.INT) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new ShiftRight(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFNE0 extends MyTestCase {
  public ClassDef defadd(String type,int i1) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    MethodDef md = new MethodDef(TypeName.BOOLEAN,"meth",x) ;
    Mark one = new Mark() ;
    md = md.addInstructions(
        new Load(x),
        new IfNotEquals0(TypeCode.getType(type),one),
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.TypeName

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.