Package erjang.beam.repr.Operands

Examples of erjang.beam.repr.Operands.Label


      case jump:
      case fcheckerror:
      case recv_mark:
      case recv_set:
      {
        Label lbl = readLabel();
        return new Insn.L(opcode, lbl);
      }

      case put:
      case badmatch:
      case case_end:
      case try_case_end:
      {
        SourceOperand src = readSource();
        return new Insn.S(opcode, src);
      }

      case init:
      case bs_context_to_binary:
      {
        DestinationOperand dest = readDestination();
        return new Insn.D(opcode, dest);
      }

      case make_fun2:
      {
        int fun_ref = readCodeInteger();
        return new Insn.F(opcode, fun_ref, anonFun(fun_ref));
      }

      case try_end:
      case catch_end:
      case try_case:
      {
        YReg y = readYReg();
        return new Insn.Y(opcode, y);
      }

      case bs_put_string:
      {
        ByteString bin = readBytestringRef();
        return new Insn.By(opcode, bin);
      }

      //---------- 2-ary ----------
      case allocate:
      case allocate_zero:
      case trim:
      case apply_last:
      {
        int i1 = readCodeInteger();
        int i2 = readCodeInteger();
        return new Insn.II(opcode, i1, i2);
      }

      case test_heap:
      {
        AllocList al = readAllocList();
        int i2 = readCodeInteger();
        return new Insn.WI(opcode, al, i2);
      }

      case call:
      case call_only:
      {
        int i1 = readCodeInteger();
        Label label = readLabel();
        return new Insn.IL(opcode, i1, label,
                   functionAtLabel(label.nr));
      }

      case call_ext:
      case call_ext_only:
      {
        int i1 = readCodeInteger();
        int ext_fun_ref = readCodeInteger();
        return new Insn.IE(opcode, i1, extFun(ext_fun_ref));
      }

      case bs_save2:
      case bs_restore2:
      {
        DestinationOperand dest = readDestination();

        int i2;
        if ((peekTag() & 0x7) == ATOM4_TAG) {
          if (readAtom().getEAtom() != START_ATOM)
            throw new IOException("integer or 'start' expected");
          i2 = -1;
        } else i2 = readCodeInteger();
        return new Insn.DI(opcode, dest, i2, true);
      }

      case move:
      case fmove:
      case fconv:
      {
        SourceOperand src = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.SD(opcode, src, dest);
      }

      case put_tuple:
      {
        int i1 = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.ID(opcode, i1, dest);
      }

      case loop_rec:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        return new Insn.LD(opcode, label, dest);
      }

      case K_try:
      case K_catch:
      {
        YReg y = readYReg();
        Label label = readLabel();
        return new Insn.YL(opcode, y, label);
      }

      case is_integer:
      case is_float:
      case is_number:
      case is_atom:
      case is_pid:
      case is_reference:
      case is_port:
      case is_nil:
      case is_binary:
      case is_list:
      case is_nonempty_list:
      case is_tuple:
      case is_function:
      case is_boolean:
      case is_bitstr:
      {
        Label label = readLabel();
        DestinationOperand src = readDestination();
        return new Insn.LD(opcode, label, src, true);
      }

      case wait_timeout:
      {
        Label label = readLabel();
        SourceOperand src = readSource();
        return new Insn.LS(opcode, label, src, false);
      }

      case raise:
      {
        SourceOperand src1 = readSource();
        SourceOperand src2 = readSource();
        return new Insn.SS(opcode, src1, src2);
      }

      case put_string:
      {
        ByteString bin = readBytestringRef();
        DestinationOperand dest = readDestination();
        return new Insn.ByD(opcode, bin, dest);
      }

      //---------- 3-ary ----------
      case allocate_heap:
      case allocate_heap_zero:
      {
        int i1 = readCodeInteger();
        AllocList al = readAllocList();
        int i3 = readCodeInteger();
        return new Insn.IWI(opcode, i1, al, i3);
      }

      case func_info:
      {
        Atom mod = readAtom();
        Atom fun = readAtom();
        int arity = readCodeInteger();
        return new Insn.AAI(opcode, mod,fun,arity);
      }

      case call_ext_last:
      {
        int arity = readCodeInteger();
        int ext_fun_ref = readCodeInteger();
        int dealloc = readCodeInteger();
        return new Insn.IEI(opcode, arity, extFun(ext_fun_ref), dealloc);
      }

      case put_list:
      {
        SourceOperand src1 = readSource();
        SourceOperand src2 = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.SSD(opcode, src1, src2, dest);
      }

      case get_tuple_element:
      {
        SourceOperand src = readSource();
        int i = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.SID(opcode, src, i, dest);
      }

      case set_tuple_element:
      {
        SourceOperand src = readSource();
        DestinationOperand dest = readDestination();
        int i = readCodeInteger();
        return new Insn.SDI(opcode, src, dest, i);
      }

      case get_list:
      {
        SourceOperand src = readSource();
        DestinationOperand dest1 = readDestination();
        DestinationOperand dest2 = readDestination();
        return new Insn.SDD(opcode, src, dest1, dest2);
      }

      case test_arity:
      case bs_test_tail2:
      case bs_test_unit:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        int i1 = readCodeInteger();
        return new Insn.LDI(opcode, label, dest, i1, true);
      }

      case is_lt:
      case is_ge:
      case is_eq:
      case is_ne:
      case is_eq_exact:
      case is_ne_exact:
      {
        Label label = readLabel();
        SourceOperand src1 = readSource();
        SourceOperand src2 = readSource();
        return new Insn.LSS(opcode, label, src1, src2, true);
      }

      case is_function2:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        SourceOperand src = readSource();
        return new Insn.LDS(opcode, label, dest, src, true);
      }

      case fnegate:
      case bs_utf8_size:
      case bs_utf16_size:
      {
        Label label = readLabel();
        SourceOperand src = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.LSD(opcode, label, src, dest);
      }

      case call_last:
      {
        int i1 = readCodeInteger();
        Label label = readLabel();
        int i3 = readCodeInteger();
        return new Insn.ILI(opcode, i1, label, i3,
                  functionAtLabel(label.nr));
      }

      case fadd:
      case fsub:
      case fmul:
      case fdiv:
      {
        Label label = readLabel();
        SourceOperand src1 = readSource();
        SourceOperand src2 = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.LSSD(opcode, label, src1, src2, dest, true);
      }

      case bs_add:
      {
        Label label = readLabel();
        SourceOperand src1 = readSource();
        SourceOperand src2 = readSource();
        int i3 = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.LSSID(opcode, label, src1, src2, i3, dest);
      }

      case bs_skip_utf8:
      case bs_skip_utf16:
      case bs_skip_utf32:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        return new Insn.LDII(opcode, label, dest, i3, i4);
      }

      case bs_match_string:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        BitString bin = readBitstringRef();
        return new Insn.LDBi(opcode, label, dest, bin);
      }

      case bs_put_utf8:
      case bs_put_utf16:
      case bs_put_utf32:
      {
        Label label = readLabel();
        int i2 = readCodeInteger();
        SourceOperand src = readSource();
        return new Insn.LIS(opcode, label, i2, src, true);
      }

      case bs_start_match2:
      case bs_get_utf8:
      case bs_get_utf16:
      case bs_get_utf32:
      {
        Label label = readLabel();
        DestinationOperand dest1 = readDestination();
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        DestinationOperand dest2 = readDestination();
        return new Insn.LDIID(opcode, label, dest1, i3, i4, dest2,
                    opcode != BeamOpcode.bs_start_match2);
      }

      case bs_put_integer:
      case bs_put_float:
      case bs_put_binary:
      {
        Label label = readLabel();
        SourceOperand src2 = readSource();
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        SourceOperand src5 = readSource();
        return new Insn.LSIIS(opcode, label, src2, i3, i4, src5, true);
      }

      case bs_init2:
      case bs_init_bits:
      {
        Label label = readOptionalLabel();
        SourceOperand src2;
        if ((peekTag() & 0x7) == CODEINT4_TAG) {
          int i2 = readCodeInteger();
          src2 = new Operands.Int(i2);
        } else {
          src2 = readSource();
        }
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        int i5 = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.LSIIID(opcode, label, src2, i3, i4, i5, dest, true);
      }

      case bs_skip_bits2:
      {
        Label label = readLabel();
        DestinationOperand dest = readDestination();
        SourceOperand src = readSource();
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        return new Insn.LDSII(opcode, label, dest, src, i3, i4);
      }

      case bs_get_integer2:
      case bs_get_float2:
      case bs_get_binary2:
      {
        Label label = readLabel();
        DestinationOperand dest2 = readDestination();
        int i3 = readCodeInteger();
        SourceOperand src4 = readSource();
        int i5 = readCodeInteger();
        int i6 = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.LDISIID(opcode, label, dest2, i3, src4, i5, i6, dest);
      }

      case bs_append: // LSIIISIS
      {
        Label label = readLabel();
        SourceOperand src2 = readSource();
        int i3 = readCodeInteger();
        int i4 = readCodeInteger();
        int i5 = readCodeInteger();
        SourceOperand src6 = readSource();
        int i7 = readCodeInteger();
        DestinationOperand dest8 = readDestination();
        return new Insn.BSAppend(opcode, label, src2, i3, i4, i5, src6, i7, dest8);
      }

      case bs_private_append: // LSISID
      {
        Label label = readLabel();
        SourceOperand src2 = readSource();
        int i3 = readCodeInteger();
        SourceOperand src4 = readSource();
        int i5 = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.BSPrivateAppend(opcode, label, src2, i3, src4, i5, dest);
      }

      case select_val:
      case select_tuple_arity:
      {
        SourceOperand src = readSource();
        Label defaultLbl = readLabel();
        SelectList jumpTable = readSelectList();
        return new Insn.Select(opcode, src, defaultLbl, jumpTable);
      }

      //---------- BIFs ----------
      case bif0: {
        Label optLabel = readOptionalLabel();
        int ext_fun_ref = readCodeInteger();
        DestinationOperand dest = readDestination();
        return new Insn.Bif(opcode, optLabel, extFun(ext_fun_ref), dest);
      }
      case bif1: {
        Label optLabel = readOptionalLabel();
        int ext_fun_ref = readCodeInteger();
        SourceOperand arg = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.Bif(opcode, optLabel, extFun(ext_fun_ref), arg, dest);
      }
      case bif2: {
        Label optLabel = readOptionalLabel();
        int ext_fun_ref = readCodeInteger();
        SourceOperand arg1 = readSource();
        SourceOperand arg2 = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.Bif(opcode, optLabel, extFun(ext_fun_ref), arg1, arg2, dest);
      }

      case gc_bif1: {
        Label optLabel = readOptionalLabel();
        int save = readCodeInteger();
        int ext_fun_ref = readCodeInteger();
        SourceOperand arg = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.GcBif(opcode, optLabel, extFun(ext_fun_ref), save, arg, dest);
      }
      case gc_bif2: {
        Label optLabel = readOptionalLabel();
        int save = readCodeInteger();
        int ext_fun_ref = readCodeInteger();
        SourceOperand arg1 = readSource();
        SourceOperand arg2 = readSource();
        DestinationOperand dest = readDestination();
        return new Insn.GcBif(opcode, optLabel, extFun(ext_fun_ref), save, arg1, arg2, dest);
      }
      case gc_bif3: {
        Label optLabel = readOptionalLabel();
        int save = readCodeInteger();
        int ext_fun_ref = readCodeInteger();
        SourceOperand arg1 = readSource();
        SourceOperand arg2 = readSource();
        SourceOperand arg3 = readSource();
View Full Code Here


    }
    case LABEL4_TAG:
    case LABEL12_TAG:
    {
      int nr = readSmallIntValue(d1);
      return new Label(nr);
    }
    case EXTENDED_TAG:
    {
      int moretag = d1>>4;
      switch (moretag) {
View Full Code Here

      this.src2 = src2;
    }
    public ETuple toSymbolic() {
      if (opcode == BeamOpcode.raise)
        return ETuple.make(opcode.symbol,
                   new Label(0).toSymbolic(),
                   EList.make(src1.toSymbolic(),
                        src2.toSymbolic()),
                   XReg.get(0).toSymbolic());
      else
        return ETuple.make(opcode.symbol,
View Full Code Here

  public void visitCompile(EAtom att, EObject value) {
  }

  @Override
  public void visitExport(EAtom fun, int arity, int entry) {
    Label label = new Label(entry);
    FunInfo fi = get(label);
    fi.exported = true;
  }
View Full Code Here

  }
 
  @Override
  public void declareFunction(EAtom fun, int arity, int startLabel) {
    Label label = new Label(startLabel);
    get(fun,arity,label);
  }
View Full Code Here

   
    if (log.isLoggable(Level.FINE)) {
      log.fine("== analyzing "+ModuleAnalyzer.this.name+":"+name+"/"+arity);
    }

    Label start = new Label(startLabel);
    final FunInfo self = get(name, arity, start);

    return new FunctionVisitor() {

      @Override
      public BlockVisitor visitLabeledBlock(int label) {

        return new BlockVisitor() {

          @Override
          public void visitInsn(Insn insn) {

            BeamOpcode op;
            switch (op = insn.opcode()) {

            case on_load:
              self.call_on_load = true;
              break;

            case send: {
              if (log.isLoggable(Level.FINE) && !self.is_pausable) {
                log.fine("pausable: send");
              }
             
              self.is_pausable = true;
              break;
            }
           
            case call: {
              Insn.IL cl = (Insn.IL) insn;
              FunInfo target = get(cl.label);
             
              BuiltInFunction bif =
                BIFUtil.getMethod(target.name.module,
                  target.name.function, target.name.arity, false, false);

              if (bif == null) {             
                target.addCaller(self);
                target.is_called_locally_in_nontail_position = true;
              }
              break;
            }

            case call_last: {
              ILI cl = (Insn.ILI) insn;
              boolean is_self_call = cl.label.nr == startLabel; 
              self.may_return_tail_marker |= !is_self_call;
              FunInfo target = get(cl.label);
             
              BuiltInFunction bif =
                BIFUtil.getMethod(target.name.module,
                  target.name.function, target.name.arity, false, false);

              if (bif == null) {             
                target.addTailCaller(self);
                target.is_called_locally_in_tail_position |= !is_self_call;
              }
              break;
            }

            case call_only: {
              IL cl = (Insn.IL) insn;
              boolean is_self_call = cl.label.nr == startLabel;
              self.may_return_tail_marker |= !is_self_call;
              FunInfo target = get(cl.label);
              BuiltInFunction bif =                
                BIFUtil.getMethod(target.name.module,
                  target.name.function, target.name.arity, false, false);

              if (bif == null) {             
                target.addTailCaller(self);
                target.is_called_locally_in_tail_position |= !is_self_call;
              }
              break;
            }
           
            case make_fun2: {
              Insn.F fi = (Insn.F) insn;
              Label anon = new Label(fi.anon_fun.label);
              get(anon).is_anon_fun = true;
              break;
            }

            case apply_last:
View Full Code Here

TOP

Related Classes of erjang.beam.repr.Operands.Label

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.