Package org.allspice.bytecode

Examples of org.allspice.bytecode.MethodRef


  public static MethodRef createMethodRef(MethodStub stub) {
    FIFO<TypeName> types = new FIFO<TypeName>() ;
    for(StubResolver r: stub.types) {
      types = types.insert(r.getTypeName()) ;
    }
    return new MethodRef(stub.cl.getTypeName(),stub.returnType.getTypeName(),stub.nm,types) ;
  }
View Full Code Here


    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>") ;
    }
    MethodRef mref = createMethodRef(fd) ;
    for(Expr e: args) {
      context.compile(null,e, l) ;
    }
    l.add(new InvokeSpecial(mref)) ;
  }
View Full Code Here

    l.add(new New(baseType,size.size())) ;
  }

  public static void createCall(EvaluationContext context, Expr decl, final Collection<Expr> args,InstList l) throws CompilerException, UndefinedMethod {
    MethodInvocation fd = createMethDef(context,args,decl) ;
    MethodRef mref = createMethodRef(fd.stub) ;
    if (fd.stub.isStatic) {
      createStaticCall(context,args,mref.parameters,new InvokeStatic(mref),l) ;
    }
    else {
      if (fd.stub.isPrivate || fd.isSuper || mref.name.equals("<init>")) {
View Full Code Here

      // constructor called <init>
      // must call superclass's <init>
      // Returns nothing
      MethodDef md = new MethodDef(TypeName.VOID,"<init>").addInstructions(
          new Load(new Var(0,new TypeName("TestClass"))),
          new InvokeSpecial(new MethodRef(cd.superClass,TypeName.VOID,"<init>")),
          new Return(TypeCode.VOID)
      ) ;
      // Watch it!  ClassDef is immutable
      cd = cd.addMethod(md) ;
    }
View Full Code Here

      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) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRING,"toString"))) ;
      }
      else {
        super.compile(forwardType, t, context, l) ;
      }
    }
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.MethodRef

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.