Package org.allspice.bytecode

Examples of org.allspice.bytecode.MethodRef


public class TestNew extends MyTestCase {
  public ClassDef defadd() {
    ClassDef cd = makeClassDef() ;
    {
      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")),
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

    }
  }
  private static final class InvokeSpecialConverter implements
      InstConverter<InvokeSpecial> {
    public void convertInst(InvokeSpecial t, InstructionListContext ilc) {
      MethodRef mref = t.method;
      Type ret_type = TypeDefConverter.makeType(mref.returnType) ;
      Type[] args = makeArgList(mref.parameters);
      String ref = mref.clazz.toString();
      ilc.add(ilc.getInstructionFactory().createInvoke(ref, mref.name, ret_type, args, Constants.INVOKESPECIAL)) ;
    }
View Full Code Here

    }
  }
  private static final class InvokeVirtualConverter implements
      InstConverter<InvokeVirtual> {
    public void convertInst(InvokeVirtual t, InstructionListContext ilc) {
      MethodRef mref = t.method;
      Type ret_type = TypeDefConverter.makeType(mref.returnType) ;
      Type[] args = makeArgList(mref.parameters);
      String ref = mref.clazz.toString();
      ilc.add(ilc.getInstructionFactory().createInvoke(ref, mref.name, ret_type, args, Constants.INVOKEVIRTUAL)) ;
    }
View Full Code Here

    }
  }
  private static final class InvokeStaticConverter implements
      InstConverter<InvokeStatic> {
    public void convertInst(InvokeStatic t, InstructionListContext ilc) {
      MethodRef mref = t.method;
      Type ret_type = TypeDefConverter.makeType(mref.returnType) ;
      Type[] args = makeArgList(mref.parameters);
      String ref = mref.clazz.toString();
      ilc.add(ilc.getInstructionFactory().createInvoke(ref, mref.name, ret_type, args, Constants.INVOKESTATIC)) ;
    }
View Full Code Here

    }
  }
  private static final class InvokeInterfaceConverter implements
      InstConverter<InvokeInterface> {
    public void convertInst(InvokeInterface t, InstructionListContext ilc) {
      MethodRef mref = t.method;
      Type ret_type = TypeDefConverter.makeType(mref.returnType) ;
      Type[] args = makeArgList(mref.parameters);
      String ref = mref.clazz.toString();
      ilc.add(ilc.getInstructionFactory().createInvoke(ref, mref.name, ret_type, args, Constants.INVOKEINTERFACE)) ;
    }
View Full Code Here

        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) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRING,"toString"))) ;
        l.add(new Store(v)) ;
      }
      else {
        ConstObj o = context.getConst(inc) ;
        if (o != null && o.o instanceof Number) {
View Full Code Here

        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) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRINGBUILDER,"append",TypeName.OBJECT))) ;
        l.add(new InvokeVirtual(new MethodRef(TypeName.STRINGBUILDER,TypeName.STRING,"toString"))) ;
        l.add(new Store(v)) ;
        return v ;
      }
      else {
        ConstObj o = context.getConst(inc) ;
View Full Code Here

  }
  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)
View Full Code Here

public class TestThrow extends MyTestCase {
  public ClassDef defadd() {
    ClassDef cd = makeClassDef() ;
    {
      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")),
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.