Package erjang

Examples of erjang.ETuple


    return ERT.box(t.arity());
  }

  @BIF(type = Type.GUARD, name = "tuple_size")
  public static ESmall tuple_size_guard(EObject tup) {
    ETuple t;
    if ((t = tup.testTuple()) == null)
      return null;
    return ERT.box(t.arity());
  }
View Full Code Here


    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,
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

    int index = idx.value;

    while (!src.isNil()) {
      EObject elm = src.head();
     
      ETuple tup;
      if ((tup = elm.testTuple()) != null) {
        if (tup.arity() >= index) {
          if (tup.elm(index).equals(k)) {
            return new ETuple2(ERT.am_value, tup);
          }
        }
      }
     
View Full Code Here

 
  @BIF
  public static EObject delete_element(EObject idx0, EObject tup0)
  {
    ESmall idx = idx0.testSmall();
    ETuple tup = tup0.testTuple();
    if (idx == null || tup == null || idx.value < 1 || idx.value > tup.arity())
      throw ERT.badarg(idx0, tup0);
   
    EObject[] vals = new EObject[tup.arity()-1];
    int target = 0;
    for (int i = 0; i < tup.arity(); i++) {
      if ((i+1) != idx.value) {
        vals[target++] = tup.elm(i+1);
      }
    }
   
    return ETuple.make(vals);
  }
View Full Code Here

  @BIF
  public static EObject
  insert_element(EObject idx0, EObject tup0, EObject term)
  {
    ESmall idx = idx0.testSmall();
    ETuple tup = tup0.testTuple();
    if (idx == null || tup == null || idx.value < 1 || idx.value > tup.arity()+1)
      throw ERT.badarg(idx0, tup0);
   
    EObject[] vals = new EObject[tup.arity()+1];
    int target = 0;
    for (int i = 0; i < tup.arity(); i++) {
      if ((i+1) == idx.value) {
        vals[target++] = term;
      }
     
      vals[target++] = tup.elm(i+1);
    }
   
    return ETuple.make(vals);
  }
View Full Code Here

  @BIF
  static EPort open_port(EProc proc, EObject portName, EObject portSetting)
      throws Pausable {

    ETuple t;
    if ((t = portName.testTuple()) == null)
      throw ERT.badarg(portName, portSetting);

    ETask<? extends EPort> task = null;
View Full Code Here

TOP

Related Classes of erjang.ETuple

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.