Package erjang

Examples of erjang.ETuple


    return ERT.TRUE;
  }
 
  @BIF
  static public ETuple setelement(EObject a1, EObject a2, EObject term) {
    ETuple t = a2.testTuple();
    ESmall i = a1.testSmall();
    if (t == null || i == null) throw ERT.badarg(a1,a2,term);
    return t.setelement(i.value, term);
  }
View Full Code Here


  }

  @BIF(type = Type.GUARD, name = "element")
  static public EObject element$g(EObject idx, EObject tup) {
    ESmall i = idx.testSmall();
    ETuple t = tup.testTuple();
    if (i == null || t == null) {
      return null;
    }
    if (i.value > t.arity())
      return null;

    return t.elm(i.value);
  }
View Full Code Here

  }

  @BIF
  static public EObject element(EObject idx, EObject tup) {
    ESmall i = idx.testSmall();
    ETuple t = tup.testTuple();
    if (i == null || t == null || i.value < 1 || i.value > t.arity()) {
      throw ERT.badarg(idx, tup);
    }

    return t.elm(i.asInt());
  }
View Full Code Here

    throw ERT.badarg(sidx, tup);
  }

  @BIF
  static public EObject element(int idx, EObject obj) {
    ETuple tup;
    if ((tup = obj.testTuple()) != null && tup.arity() >= idx) {
      return tup.elm(idx);
    }
    throw ERT.badarg(new ESmall(idx), obj);
  }
View Full Code Here

  // what are these supposed to do? Get the size of a tuple_

  @BIF
  public static final ESmall size(EObject o) {
    ETuple t;
    if ((t = o.testTuple()) == null)
    {
      EBinary b;
      if ((b = o.testBinary()) == null)
        throw ERT.badarg(o);
     
      return ERT.box(b.byteSize());
    }
    return ERT.box(t.arity());
  }
View Full Code Here

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

  @BIF(type = Type.GUARD, name = "size")
  public static final ESmall size$g(EObject o) {
    ETuple t;
    if ((t = o.testTuple()) != null)
      return ERT.box(t.arity());

    EBinary b;
    if ((b = o.testBinary()) != null)
      return ERT.box(b.byteSize());
   
View Full Code Here

  }

    @BIF(type=Type.GUARD, name="is_record")
            public static EAtom is_record$g(EObject term, EObject tag) {
                EAtom atag = tag.testAtom();
                ETuple tup = term.testTuple();
                boolean ok = ( (atag != null) && (tup != null)
                                && (tup.arity() > 0)
                                && (tup.elm(1) == atag) );
                if (ok) return ERT.TRUE;
                else return null;
  }
View Full Code Here

  }

    @BIF(type=Type.GUARD, name="is_record")
            public static EAtom is_record$g(EObject term, EObject tag, EObject size) {
                EAtom atag = tag.testAtom();
                ETuple tup = term.testTuple();
                ESmall siz = size.testSmall();
                boolean ok = ( (atag != null) && (tup != null) && (siz != null)
                                && (tup.arity() == siz.value)
                                && (tup.elm(1) == atag) );
                if (ok) return ERT.TRUE;
                else return null;
  }
View Full Code Here

 
  @BIF
  public static ETuple make_tuple(EObject arity, EObject initial) {
    ESmall sm = arity.testSmall();
    if (sm == null || sm.value < 0) throw ERT.badarg(arity, initial);
    ETuple et = ETuple.make(sm.value);
    for (int i = 1; i <= sm.value; i++) {
      et.set(i, initial);
    }
    return et;
  }
View Full Code Here

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

  @BIF
  public static ESmall tuple_size(EObject tup) {
    ETuple t;
    if ((t = tup.testTuple()) == null)
      throw ERT.badarg(tup);
    return ERT.box(t.arity());
  }
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.