Package erjang

Examples of erjang.EObject


    byte[] bytes = string.getBytes(IO.UTF8);
    ByteBuffer buf = ByteBuffer.wrap(bytes);

    // driver_output(bb);

    EObject out;

    if (task.send_binary_data()) {
      out = EBinary.make(buf);
    } else {
      out = EString.make(buf);
View Full Code Here


      constants.put(module_md5, "module_md5");
    }

    for (Map.Entry<EObject, String> ent : constants.entrySet()) {

      EObject term = ent.getKey();
      Type type = getConstantType(term);

      ETuple tup;
      if (((tup=term.testTuple()) != null || term.testCons() != null
          && term != ERT.NIL
          && !type.equals(ESTRING_TYPE)
          && !( tup != null && tup.arity()==5 && tup.elm(1) == ETuple.am_Elixir_Regex)
          ) {
        EBinary bin = ErlConvert.term_to_binary(term, EList.make(ErlConvert.am_compressed));
        bin.emit_const(mv);
       
        mv.visitMethodInsn(INVOKESTATIC,
            Type.getType(ErlConvert.class).getInternalName(),
            "binary_to_term",
            EUtil.getSignature(1, false));
       
        mv.visitTypeInsn(CHECKCAST, type.getInternalName());
       
      } else {   
        term.emit_const(mv);
      }
     
      mv.visitFieldInsn(Opcodes.PUTSTATIC, self_type.getInternalName(),
          ent.getValue(), type
              .getDescriptor());
View Full Code Here

      code.add((char)0xFFFF);
      return pos;
    }

    protected int encodeLiteral(Operands.Literal lit) {
      EObject value = lit.literalValue();
      Integer index = const_map.get(value);
      if (index == null) {
        index = const_map.size();
        consts.add(value);
        const_map.put(value, index);
View Full Code Here

    }

    protected int encodeValueJumpTable(Operands.SelectList jumpTable) {
      final ValueJumpTable table = new ValueJumpTable();
      for (int i=0; i<jumpTable.size(); i++) {
        final EObject value = ((Operands.Literal)jumpTable.getValue(i)).literalValue();
        int label = jumpTable.getLabel(i).nr;
        table.put(value, -12347);
        backpatches.add(new Backpatch(label) {
          public String toString() {return "Backpatch<value jump table "+label+">";}
          public void patch(int labelOffset) {
View Full Code Here

    EInternalPort iport;
    EInternalPID ipid;
   
    if ((iport=arg_port.testInternalPort()) == null) {
      EAtom port_name = arg_port.testAtom();
      EObject resolved;
      if (port_name != null
        && (resolved=ERT.whereis(port_name)) != ERT.am_undefined
        && (iport=resolved.testInternalPort()) != null) {
        // ok //
      } else {
        throw ERT.badarg(arg_port, arg_pid);
      }
    }

    if ((ipid=arg_pid.testInternalPID()) == null) {
      EAtom pid_name = arg_pid.testAtom();
      EObject resolved;
      if (pid_name != null
        && (resolved=ERT.whereis(pid_name)) != ERT.am_undefined
        && (ipid=resolved.testInternalPID()) != null) {
        // ok //
      } else {
        throw ERT.badarg(arg_port, arg_pid);
      }
    }
View Full Code Here

  @BIF
  static public EObject port_close(EProc proc, EObject port) throws Pausable {
    EPort p;
    if ((p = port.testPort()) == null) {

      EObject obj = ERT.whereis(port);

      if (obj == ERT.am_undefined || ((p = obj.testPort()) == null)) {
        throw ERT.badarg(port);
      }
    }

    if (!p.isOpen()) {
View Full Code Here

  @BIF
  static public EObject port_info(EProc proc, EObject a1, EObject a2) {
    EPort p = a1.testPort();
    EAtom spec = a2.testAtom();
    if (p==null || spec==null) throw ERT.badarg();
    EObject info = p.port_info(spec);
    //log.finer(""+proc.self_handle()+"::port_info ("+a1+") => "+info);
    return info;
  }
View Full Code Here

  private static EPort id_or_name2port(EObject port) {
    EPort p = port.testPort();
    if (p != null) return p;
     
    EObject p2 = ERT.whereis(port);
   
    // p2 is ERT.am_undefined if not found
   
    return p2.testPort();
  }
View Full Code Here

   
    if (key == null || nth == null | list == null)
        throw ERT.badarg(key, nth_arg, list_arg);

    while (!list.isNil()) {
      EObject elm = list.head();
      ETuple tup = elm.testTuple();

      // test that it is a tuple of the right size
      if (tup != null && tup.arity() >= nth.value) {       
        EObject val = tup.elm(nth.value);
        if (val.equals(key)) { return ERT.TRUE; }
      }
     
      list = list.tail();
    }
View Full Code Here

   
    if (key == null || nth == null | list == null)
        throw ERT.badarg(key, nth_arg, list_arg);

    while (!list.isNil()) {
      EObject elm = list.head();
      ETuple tup = elm.testTuple();

      // test that it is a tuple of the right size
      if (tup != null && tup.arity() >= nth.value) {       
        EObject val = tup.elm(nth.value);
        if (val.equals(key)) { return tup; }
      }
     
      list = list.tail();
    }
View Full Code Here

TOP

Related Classes of erjang.EObject

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.