Package org.allspice.bytecode

Examples of org.allspice.bytecode.TypeName


import org.allspice.bytecode.instructions.Return;

public class TestIncrement extends MyTestCase {
  public ClassDef defadd(String type,Number inc) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(1,new TypeName(type)) ;
    MethodDef md = new MethodDef(new TypeName(type),"meth",x) ;
    md = md.addInstructions(
        new Increment(x,inc),
        new Load(x),
        new Return(TypeCode.getType(type))
        ) ;
View Full Code Here


    }
  }
  private static final class NewArrayConverter implements ExprCompiler<NewArrayExpr> {
    public void compile(TypeName forwardType, NewArrayExpr t, EvaluationContext context, InstList result) throws CompilerException {
      final Collection<? extends Expr> size = t.dimensions;
      final TypeName type = context.fullyQualified(t.type).makeArray(size.size());
      if (t.init != null) {
        makeInit(context, t.init, type,result) ;
      }
      else {
        createNewArray(context, size, type,result);
View Full Code Here

    public void compile(TypeName vtype, ArrayOfExpr t, EvaluationContext context, InstList l) throws CompilerException {
      Collection<Expr> arrinit = t.arr ;
      if (!vtype.isArray()) {
        throw new InvalidInitializer() ;
      }
      TypeName baseType = vtype.getArrayBase() ;
      createNewArray(context,Arrays.asList(new ConstExpr(Integer.valueOf(arrinit.size()),null)),vtype,l) ;
      int i = 0 ;
      for(Expr arrval: arrinit) {
        l.add(new Dup(TypeCode.VOID,TypeCode.getType(vtype))) ;
        l.add(new Const(Integer.valueOf(i))) ;
View Full Code Here

          switch(u) {
          case BOOLEAN:
          case VOID:
          case ARRAY:
            if (t != u) {
              return context.makeTypeRef(new TypeName("Object[]"));
            }
            break ;
          case OBJECT:
            return context.makeTypeRef(new TypeName("Object[]"));
          case BYTE:
          case SHORT:
          case LONG:
          case DOUBLE:
          case FLOAT:
          case CHAR:
          case INT:
            if (t == TypeCode.BOOLEAN || t == TypeCode.VOID || t == TypeCode.ARRAY) {
              return context.makeTypeRef(new TypeName("Object[]"));
            }
            t = condTable.get(new TypePair(t,u)) ;
            break ;
          }
        }
      }
      if (t == null) {
        return context.makeTypeRef(new TypeName("Object[]"));
      }
      TypeName tn = TypeName.valueOf(t) ;
      return context.makeTypeRef(tn.makeArray());
    }
View Full Code Here

        InstList l) throws CompilerException {
      throw new NoLValAvailable() ;
    }
    public boolean isInstanceOf(ArrayOfExpr t, TypeName type, EvaluationContext context) throws CompilerException {
      if (type.isArray()) {
        TypeName base = type.getArrayBase() ;
        for(Expr e: t.arr) {
          if (!context.isInstanceOf(base, e)) {
            return false ;
          }
        }
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFGT 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

      Var x = new Var(0,TypeName.OBJECT) ;
      MethodDef md = new MethodDef(TypeName.BOOLEAN,"getFoo",x) ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new Load(x),
          new InstanceOf(new TypeName(type)),
          new Return(TypeCode.BOOLEAN)
          ) ;
      cd = cd.addMethod(md) ;
    }
    return cd ;
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestNegate extends MyTestCase {
  public ClassDef defadd(String ret,String type) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(1,new TypeName(type)) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x) ;
    md = md.addInstructions(
        new Load(x),
        new Negate(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
        ) ;
View Full Code Here

public abstract class MyTestCase extends TestCase {
  public ClassDef makeClassDef() {
    return makeClass() ;
  }
  public ClassDef makeClass() {
    ClassDef cd = new ClassDef(ClassDefType.DEFAULT,null,new TypeName("TestClass"),TypeName.OBJECT) ;
    {
      MethodDef md = new MethodDef(TypeName.VOID,"<init>") ;
      MethodRef mref = new MethodRef(
          cd.superClass,TypeName.VOID,"<init>") ;
      md = md.addInstructions(
          new Load(new Var(0,new TypeName("TestClass"))),
          new InvokeSpecial(mref),
          new Return(TypeCode.VOID)
      ) ;
      cd = cd.addMethod(md) ;
    }
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFLE 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

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.