Examples of InstructionFactory


Examples of alt.jiapi.reflect.InstructionFactory

        // No API to set SourceFile!

        JiapiMethod method = c.addMethod(Modifier.PUBLIC, "<init>", emptySig);
        InstructionList il = method.getInstructionList();
        InstructionFactory iFactory = il.getInstructionFactory();
        il.add(iFactory.aload(0));
        il.add(iFactory.invoke(0, "java/lang/Object", "<init>", emptySig));
        il.add(iFactory.returnMethod(method));

        method = c.addMethod(Modifier.PUBLIC | Modifier.STATIC, "main", mainSig);
        il = method.getInstructionList();
        iFactory = il.getInstructionFactory();
        il.add(iFactory.getField(Modifier.STATIC,
                "java/lang/System",
                "out",
                "Ljava/io/PrintStream;"));
        il.add(iFactory.pushConstant("Hello world!"));
        il.add(iFactory.invoke(0, "java/io/PrintStream", "println", printlnSig));
        il.add(iFactory.returnMethod(method));

        return c.getByteCode();
    }
View Full Code Here

Examples of com.sun.org.apache.bcel.internal.generic.InstructionFactory

    String super_class_name = classDef.superClass.toString();
    String[] interfaces = getInterfaceArray(classDef);
    int access_flags = getClassAccessFlags(classDef);
    ClassGen classGen = new ClassGen(class_name,super_class_name,classDef.fileName,
        access_flags, interfaces);
    instructionFactory = new InstructionFactory(classGen) ;
    classGen.setMajor(50) ;
    classGen.setMinor(0) ;
  }
View Full Code Here

Examples of org.apache.bcel.generic.InstructionFactory

    JavaClass clazz;
    Field loggerAttribute;
    public void init(JavaClass clazz, Field logger, ConstantPoolGen cp) {
        this.clazz = clazz;
        this.loggerAttribute = logger;
        this.instFact = new InstructionFactory(cp);
    }
View Full Code Here

Examples of org.apache.bcel.generic.InstructionFactory

        InstructionList il = new InstructionList();

        MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID,
                Type.NO_ARGS, null, "<init>", stubClassName, il, cp);

        InstructionFactory fac = new InstructionFactory(stubClass, cp);

        // call super-constructor
        il.append(InstructionFactory.createThis());
        il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>",
                Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));

        // push "this"
        il.append(InstructionFactory.createThis());

        // get static initializer
        il.append(fac.createGetStatic(stubClassName,
                initializerField.getName(), initializerField.getType()));

        emitInvoke(il, fac, getStubHandlerRef);

        // checkCast
        il.append(fac.createCast(Type.OBJECT, handlerField.getType()));

        // put handlerField
        il.append(new PUTFIELD(cp.addFieldref(stubClassName, handlerField
                .getName(), handlerField.getSignature())));
View Full Code Here

Examples of org.apache.bcel.generic.InstructionFactory

        Type[] args = new Type[] { handlerField.getType() };

        MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, args,
                null, "<init>", stubClassName, il, cp);

        InstructionFactory fac = new InstructionFactory(stubClass, cp);

        // call super-constructor
        il.append(InstructionFactory.createThis());
        il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>",
                Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));

        // push this again...
        il.append(InstructionFactory.createThis());
View Full Code Here

Examples of org.apache.bcel.generic.InstructionFactory

        }
        String handlerGetName = stub_methods[0].getName();

        ConstantPoolGen cp = clazz.getConstantPool();
        InstructionList il = new InstructionList();
        InstructionFactory fac = new InstructionFactory(clazz, cp);

        Type methodReturnType = translate(Object.class);
        Type[] methodArgTypes = new Type[0];

        MethodGen mg = new MethodGen(
                Constants.ACC_FINAL | Constants.ACC_PUBLIC, methodReturnType,
                methodArgTypes, null, // arg names
                handlerGetName, clazz.getClassName(), il, cp);

        mg.addAttribute(new Synthetic(cp.addUtf8("Synthetic"), 0, null, cp
                .getConstantPool()));

        //
        // construct method body
        //

        il.append(InstructionFactory.createThis());

        il.append(fac.createGetField(clazz.getClassName(), handlerField
                .getName(), handlerField.getType()));

        emitReturn(il, methodReturnType);

        //
View Full Code Here

Examples of org.apache.bcel.generic.InstructionFactory

        InstructionList il;

        cp = clazz.getConstantPool();
        il = new InstructionList();

        InstructionFactory fac = new InstructionFactory(clazz, cp);

        Type methodReturnType = translate(method.getReturnType());
        Type[] methodArgTypes = translate(method.getParameterTypes());

        MethodGen mg = new MethodGen(
                Constants.ACC_FINAL | Constants.ACC_PUBLIC, methodReturnType,
                methodArgTypes, null, // arg names
                method.getName(), clazz.getClassName(), il, cp);

        mg.addAttribute(new Synthetic(cp.addUtf8("Synthetic"), 0, null, cp
                .getConstantPool()));

        Class[] throwsException = method.getExceptionTypes();
        for (int i = 0; i < throwsException.length; i++) {
            mg.addException(throwsException[i].getName());
        }

        //
        // BODY
        //

        il.append(InstructionFactory.createThis());

        il.append(fac.createGetField(clazz.getClassName(), handlerField
                .getName(), handlerField.getType()));

        // push "this" as invoke's first argument
        il.append(InstructionFactory.createThis());

        // load data value
        if (dataField.isStatic()) {
            il.append(fac.createGetStatic(clazz.getClassName(), dataField
                    .getName(), dataField.getType()));
        } else {
            il.append(InstructionFactory.createThis());
            il.append(fac.createGetField(clazz.getClassName(), dataField
                    .getName(), dataField.getType()));
        }

        il.append(new PUSH(cp, methodArgTypes.length));
        il.append((Instruction) fac.createNewArray(Type.OBJECT, (short) 1));

        int index = 1;
        for (int i = 0; i < methodArgTypes.length; i++) {
            // dup array ref
            il.append(InstructionConstants.DUP);
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.InstructionFactory

    // If we are nonExpressionKind, we don't expect arguments on the stack
    // so this is moot. If our argVars happen to be null, then we know that
    // no ShadowMunger has squirrelled away our arguments, so they're still
    // on the stack.
    InstructionFactory fact = getFactory();
    if (getKind().argsOnStack() && argVars != null) {

      // Special case first (pr46298). If we are an exception handler and the instruction
      // just after the shadow is a POP then we should remove the pop. The code
      // above which generated the store instruction has already cleared the stack.
      // We also don't generate any code for the arguments in this case as it would be
      // an incorrect aload.
      if (getKind() == ExceptionHandler && range.getEnd().getNext().getInstruction().equals(InstructionConstants.POP)) {
        // easier than deleting it ...
        range.getEnd().getNext().setInstruction(InstructionConstants.NOP);
      } else {
        range.insert(BcelRenderer.renderExprs(fact, world, argVars), Range.InsideBefore);
        if (targetVar != null) {
          range.insert(BcelRenderer.renderExpr(fact, world, targetVar), Range.InsideBefore);
        }
        if (getKind() == ConstructorCall) {
          if (!world.isJoinpointArrayConstructionEnabled() || !this.getSignature().getDeclaringType().isArray()) {
            range.insert(InstructionFactory.createDup(1), Range.InsideBefore);
            range.insert(fact.createNew((ObjectType) BcelWorld.makeBcelType(getSignature().getDeclaringType())),
                Range.InsideBefore);
          }
        }
      }
    }
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.InstructionFactory

      if (lazyTjpConsumers == 1) {
        return; // special case only one lazyTjpUser
      }

      InstructionFactory fact = getFactory();
      InstructionList il = new InstructionList();
      il.append(InstructionConstants.ACONST_NULL);
      il.append(thisJoinPointVar.createStore(fact));
      range.insert(il, Range.OutsideBefore);
    } else {
      appliedLazyTjpOptimization = false;
      InstructionFactory fact = getFactory();
      InstructionList il = createThisJoinPoint();
      il.append(thisJoinPointVar.createStore(fact));
      range.insert(il, Range.OutsideBefore);
    }
  }
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.InstructionFactory

    return true;
  }

  InstructionList loadThisJoinPoint() {
    InstructionFactory fact = getFactory();
    InstructionList il = new InstructionList();

    if (isThisJoinPointLazy) {
      // If we're lazy, build the join point right here.
      il.append(createThisJoinPoint());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.