Package org.objectweb.asm

Examples of org.objectweb.asm.Type


        case is_eq_exact: {
          Insn.LSS insn = (Insn.LSS) insn_;
          checkArg(current, insn.src1);
          checkArg(current, insn.src2);

          Type t1 = getType(current, insn.src1);
          Type t2 = getType(current, insn.src2);

          if (!t1.equals(t2)) {
            //TODO: for reg-vs-reg, we should really use the GLB.
            DestinationOperand reg;
            if ((reg = insn.src1.testDestination()) != null) {
              current = setType(current, reg, t2);
            }
            if ((reg = insn.src2.testDestination()) != null) {
              current = setType(current, reg, t1);
            }
          }

          return current;
        }

        case bs_start_match2: {
          Insn.LDIID insn = (Insn.LDIID) insn_;
          checkArg(current, insn.dest);
          return setType(current, insn.dest5, EMATCHSTATE_TYPE);
        }

        case bs_get_integer2: {
          Insn.LDISIID insn = (Insn.LDISIID) insn_;
          if (!EMATCHSTATE_TYPE.equals(getType(current, insn.dest))) {
            throw new Error("matching without a state");
          }

          Int bits = insn.src4.testInt();
          int unit = insn.i5;
          int flags = insn.i6;
          if (unit == 1 && flags == 0 && bits != null && (bits.value*unit) <= 32 ) {
            return setType(current, insn.dest7, ESMALL_TYPE);
          }
         
          /* DISABLED because it triggers a get_test_bif()-related bug
          if (insn.i5 <= 32) {
            return setType(current, insn.dest7, Type.INT_TYPE);
          }
          */

          return setType(current, insn.dest7, EINTEGER_TYPE);
        }

        case bs_get_binary2: {
          Insn.LDISIID insn = (Insn.LDISIID) insn_;
          if (!EMATCHSTATE_TYPE.equals(getType(current, insn.dest))) {
            throw new Error("matching without a state");
          }

          return setType(current, insn.dest7, EBINARY_TYPE);
        }


        case bs_get_float2: {
          Insn.LDISIID insn = (Insn.LDISIID) insn_;
          if (!EMATCHSTATE_TYPE.equals(getType(current, insn.dest))) {
            throw new Error("matching without a state");
          }

          return setType(current, insn.dest7, Type.DOUBLE_TYPE);
        }

        case bs_test_tail2:
        case bs_test_unit:
        case bs_skip_bits2:
        case bs_match_string:
        case bs_skip_utf8:
        case bs_skip_utf16:
        case bs_skip_utf32: {
          // These bit string matchers don't modify registers.
          Insn.LD insn = (Insn.LD) insn_;
          if (!EMATCHSTATE_TYPE.equals(getType(current, insn.dest))) {
            throw new Error("matching without a state");
          }

          return current;
        }

        case bs_get_utf8:
        case bs_get_utf16:
        case bs_get_utf32: {
          // These bit string matchers don't modify registers.
          Insn.LDIID insn = (Insn.LDIID) insn_;
          if (!EMATCHSTATE_TYPE.equals(getType(current, insn.dest))) {
            throw new Error("matching without a state");
          }
          return setType(current, insn.dest5, ESMALL_TYPE);
        }

        case is_integer:
        {
          Insn.LD insn = (Insn.LD) insn_;
          checkArg(current, insn.dest);
          if (getType(current, insn.dest) == Type.INT_TYPE
              || getType(current, insn.dest).equals(ESMALL_TYPE) ) {
            return setType(current, insn.dest, ESMALL_TYPE);
          }
        }
       
        default: { // All type tests:
          Insn.LD insn = (Insn.LD) insn_;
          checkArg(current, insn.dest);
          switch (opcode) {
          case test_arity: {
            int arity = ((Insn.LDI)insn).i;
            return setType(current, insn.dest, getTupleType(arity));
          }

          case is_function2: {
            Insn.LDS insn2 = (Insn.LDS) insn;
            checkArg(current, insn2.src);
            // TODO: Use more specific type when arity is known?
            return setType(current, insn.dest, EFUN_TYPE);
          }

          default: {
            if (insn instanceof Insn.LD) {
              Type test_type = type_tested_for((Insn.LD)insn);
              if (test_type != null)
                return setType(current, insn.dest, test_type);
            }
            throw new Error("unhandled test: " + insn_.toSymbolic());
          }
View Full Code Here


  }
 
  @Override
  public Type emit_const(MethodVisitor fa) {

    Type type = Type.getType(this.getClass());

    fa.visitTypeInsn(Opcodes.NEW, type.getInternalName());
    fa.visitInsn(Opcodes.DUP);
    fa.visitMethodInsn(Opcodes.INVOKESPECIAL, type.getInternalName(),
        "<init>", "()V");

    for (int i = 0; i < arity(); i++) {
      fa.visitInsn(Opcodes.DUP);

      if (i == 1 && arity() == 5 && elm(1) == am_Elixir_Regex) {
       
      //  System.err.println("emitting pattern /"+tos(elm(3))+"/"+tos(elm(4)));

        elm(3).emit_const(fa);
        elm(4).emit_const(fa);
        fa.visitMethodInsn(Opcodes.INVOKESTATIC, "erjang/ERT", "compile_elixir_regex",
                  "(Lerjang/EObject;Lerjang/EObject;)Lerjang/EObject;");
      } else {
        ((EObject) elm(i + 1)).emit_const(fa);
      }
     
      fa.visitFieldInsn(Opcodes.PUTFIELD, type.getInternalName(), "elem"
          + (i + 1), ETERM_TYPE.getDescriptor());
    }

    return type;
  }
View Full Code Here

    int new_stacksize = Math.min(stacksize, other.stacksize);
    if (!eqy_prefix(this, other, new_stacksize)) {
      new_y = new Type[new_stacksize];
      boolean differs_from_my_y = false;
      for (int i = 0; i < new_stacksize; i++) {
        Type t1;
        Type res = merge(t1 = this.gety(i), other.gety(i));
        new_y[new_stacksize - i - 1] = res;
        differs_from_my_y = differs_from_my_y ||
          (res!=t1 && (res==null || !res.equals(t1)));
      }
      if (!differs_from_my_y) new_y = yregs;
    }

    ExceptionHandler new_exh;
View Full Code Here

  private Type[] merge_regs(Type[] r1, Type[] r2) {
    Type[] res = new Type[Math.max(r1.length, r2.length)];
    boolean differs_from_r1 = false;
    for (int i = 0; i < res.length; i++) {
      Type t1 = get(r1, i);
      Type t2 = get(r2, i);

      res[i] = merge(t1, t2);
      differs_from_r1 = differs_from_r1 ||
          (res[i]!=t1 && (res[i]==null || !res[i].equals(t1)));
    }
View Full Code Here

  }

  private IPersistentMap merge_regs(IPersistentMap r1, IPersistentMap r2) {
    IPersistentMap out = PersistentHashMap.EMPTY;
    for (Integer r : ((Map<Integer,Type>)r1).keySet()) {
      Type t1 = (Type) r1.valAt(r);
      Type t2 = (Type) r2.valAt(r);
     
      Type m = merge(t1,t2);
      if (m != null) {
        out = out.assoc(r, m);
      }
    }
View Full Code Here

  private static final String ESEQ_DESC = Type.getDescriptor(ESeq.class);

  @Override
  public Type emit_const(MethodVisitor fa) {

    Type type = ESTRINGLIST_TYPE;

    char[] ch = new char[len];
    for (int i = 0; i < len; i++) {
      ch[i] = (char)(0xff & (int)bytes.data[off+i]);
    }
   
    fa.visitLdcInsn(new String(ch));
    tail.emit_const(fa);
    fa.visitMethodInsn(Opcodes.INVOKESTATIC, type.getInternalName(),
        "fromString", "(" + STRING_TYPE.getDescriptor() + ESEQ_DESC + ")"
            + type.getDescriptor());

    return type;
  }
View Full Code Here

  private static final Type STRING_TYPE = Type.getType(String.class);

  @Override
  public Type emit_const(MethodVisitor fa) {

    Type type = ESTRING_TYPE;

    fa.visitLdcInsn(this.stringValue());
    fa.visitMethodInsn(Opcodes.INVOKESTATIC, type.getInternalName(),
        "fromString", "(" + STRING_TYPE.getDescriptor() + ")"
            + type.getDescriptor());

    return type;
  }
View Full Code Here

  static Type ETERM_TYPE = Type.getType(EObject.class);
  static String CONSTRUCTOR_DESC = "(" + ETERM_TYPE.getDescriptor() + ETERM_TYPE.getDescriptor() + ")V";
 
  @Override
  public Type emit_const(MethodVisitor fa) {
    Type type = EPAIR_TYPE;
   
    fa.visitTypeInsn(Opcodes.NEW, type.getInternalName());
    fa.visitInsn(Opcodes.DUP);

    ((EObject)head).emit_const(fa);
    ((EObject)tail).emit_const(fa);

    fa.visitMethodInsn(Opcodes.INVOKESPECIAL, type.getInternalName(), "<init>", CONSTRUCTOR_DESC);
   
    return type;
  }
View Full Code Here

  private static final String EOBJECT_DESC = Type.getDescriptor(EObject.class);

  @Override
  public Type emit_const(MethodVisitor fa) {

    Type type = EBINLIST_TYPE;

    char[] ch = new char[len];
    for (int i = 0; i < len; i++) {
      ch[i] = (char)(0xff & (int)data[off+i]);
    }
   
    fa.visitLdcInsn(new String(ch));
    tail.emit_const(fa);
    fa.visitMethodInsn(Opcodes.INVOKESTATIC, type.getInternalName(),
        "fromString", "(" + STRING_TYPE.getDescriptor() + EOBJECT_DESC + ")"
            + type.getDescriptor());

    return type;
  }
View Full Code Here

  static Type ETERM_TYPE = Type.getType(EObject.class);
  static String CONSTRUCTOR_DESC = "(" + ETERM_TYPE.getDescriptor() + ESEQ_TYPE.getDescriptor() + ")V";
 
  @Override
  public Type emit_const(MethodVisitor fa) {
    Type type = ELIST_TYPE;
   
    fa.visitTypeInsn(Opcodes.NEW, type.getInternalName());
    fa.visitInsn(Opcodes.DUP);

    ((EObject)head).emit_const(fa);
    ((EObject)tail).emit_const(fa);

    fa.visitMethodInsn(Opcodes.INVOKESPECIAL,
        type.getInternalName(), "<init>", CONSTRUCTOR_DESC);
   
    return type;
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.Type

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.