Package org.allspice.bytecode.instructions

Examples of org.allspice.bytecode.instructions.New


      MethodRef mref = new MethodRef(
          new TypeName("TestClass"),TypeName.VOID,"<init>") ;
      MethodDef md = new MethodDef(new TypeName("TestClass"),"getFoo") ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new New(new TypeName("TestClass")),
          new org.allspice.bytecode.instructions.Dup(TypeCode.VOID,TypeCode.OBJECT),
          new InvokeSpecial(mref),
          new Return(TypeCode.OBJECT)
          ) ;
      cd = cd.addMethod(md) ;
View Full Code Here


    {
      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

      if (type.getTypeName().equals(TypeName.STRING)) {
        LValue v = context.compileLValue(var, l);
        l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
        l.add(new Load(v)) ;
        convert(context,type, TypeName.OBJECT, l) ;
        l.add(new New(TypeName.STRINGBUILDER)) ;
        l.add(new Dup(TypeCode.VOID,TypeCode.OBJECT)) ;
        l.add(new InvokeSpecial(new MethodRef(TypeName.STRINGBUILDER,TypeName.VOID,"<init>"))) ;
        l.add(new Swap()) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        StdJavaExpressions.createConvert(context, inc, TypeName.OBJECT,l) ;
View Full Code Here

        LValue v = context.compileLValue(var, l);
        l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
        l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
        l.add(new Load(v)) ;
        convert(context,type, TypeName.OBJECT, l) ;
        l.add(new New(TypeName.STRINGBUILDER)) ;
        l.add(new Dup(TypeCode.VOID,TypeCode.OBJECT)) ;
        l.add(new InvokeSpecial(new MethodRef(TypeName.STRINGBUILDER,TypeName.VOID,"<init>"))) ;
        l.add(new Swap()) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        StdJavaExpressions.createConvert(context, inc, TypeName.OBJECT,l) ;
View Full Code Here

      MethodRef mref = new MethodRef(
          new TypeName("java.lang.RuntimeException"),TypeName.VOID,"<init>") ;
      MethodDef md = new MethodDef(TypeName.VOID,"getFoo") ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new New(new TypeName("java.lang.RuntimeException")),
          new org.allspice.bytecode.instructions.Dup(TypeCode.VOID,TypeCode.OBJECT),
          new InvokeSpecial(mref),
          new Throw()
          ) ;
      cd = cd.addMethod(md) ;
View Full Code Here

    public void compile(TypeName forwardType, PlusExpr t, EvaluationContext context, InstList l) throws CompilerException {
      final Expr lhs = t.lhs;
      final Expr rhs = t.rhs;
      StubResolver type = getType(t,context) ;
      if (type.getTypeName().equals(TypeName.STRING)) {
        l.add(new New(TypeName.STRINGBUILDER)) ;
        l.add(new Dup(TypeCode.VOID,TypeCode.OBJECT)) ;
        l.add(new InvokeSpecial(new MethodRef(TypeName.STRINGBUILDER,TypeName.VOID,"<init>"))) ;
        context.compile(TypeName.OBJECT, lhs, l) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        context.compile(TypeName.OBJECT, rhs, l) ;
View Full Code Here

    return vs ;
  }

  public static void createNew(EvaluationContext context, final String type, final Collection<Expr> args, InstList l) throws CompilerException {
    TypeName fqtype = context.fullyQualified(type) ;
    l.add(new New(fqtype)) ;
    l.add(new Dup(TypeCode.VOID,TypeCode.getType(type))) ;
    MethodStub fd = context.getMethod(context.makeTypeRef(fqtype), "<init>", args) ;
    if (fd == null) {
      throw new UndefinedMethod("<init>") ;
    }
View Full Code Here

      if (!baseType.toString().endsWith("[]")) {
        throw new InvalidArray() ;
      }
      baseType = baseType.getArrayBase() ;
    }
    l.add(new New(baseType,size.size())) ;
  }
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.instructions.New

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.