Package erjang

Examples of erjang.ESmall


  }

  @BIF
  public static EInteger list_to_integer(EObject obj, EObject radix) {
    EString seq;
    ESmall rdx;
    if ((seq = obj.testString()) == null
        || ((rdx = radix.testSmall()) == null))
      throw ERT.badarg(obj, radix);

    // remove leading +
View Full Code Here


  }

  @BIF
  public static EInteger binary_to_integer(EObject obj, EObject radix) {
    EBinary bin;
    ESmall rdx;
    if ((bin = obj.testBinary()) == null || (rdx = radix.testSmall()) == null)
      throw ERT.badarg(obj, radix);

    // remove leading +
    int off = 0;
View Full Code Here

  }

  @BIF
  public static EString binary_to_list(EObject obj, EObject start, EObject stop) {
    EBinary bin = obj.testBinary();
    ESmall s = start.testSmall();
    ESmall e = stop.testSmall();
    if (bin == null || s==null || e==null)
      throw ERT.badarg(obj,start,stop);

    int idx0start = s.value-1;
    int len = e.value-s.value+1;
View Full Code Here

    EObject tail;
    ECons cons;
    for (tail=iol; (cons = tail.testNonEmptyList()) != null; tail = cons.tail()) {
      EObject hd = cons.head();

      ESmall sm;
      EBinary bi;
      ECons co;
      if ((sm = hd.testSmall()) != null) {
        if (sm.value < 0 || sm.value > 255)
          throw ERT.badarg(list);
View Full Code Here

  }
 

  @BIF static public EObject slot(EProc caller, EObject nameOrTid, EObject i) {
    ETable table = resolve(caller, nameOrTid, false);
    ESmall pos;
    if ((pos=i.testSmall())==null || table == null)
      throw ERT.badarg(nameOrTid, i);

    if (pos.value == 0) {
     
View Full Code Here

  }

  @BIF static public EObject select(EProc caller, EObject nameOrTid, EObject matchSpec, EObject limit) {

    ETable table = resolve(caller, nameOrTid, false);
    ESmall lim = limit.testSmall();
    if (table == null || lim == null || lim.value < 1) throw ERT.badarg(nameOrTid, matchSpec, limit);
   
    EMatchSpec spec;
    ESeq seq;
    if ((matchSpec instanceof EMatchSpec)) {
View Full Code Here

          return rec.elm(idx);
         
        } else if ((one=upd.testTuple()) != null) {
         
          if (one.arity() == 2) {
            ESmall eidx = one.elm(1).testSmall();
            incr = one.elm(2).testInteger();
            if (eidx == null || eidx.value > rec.arity() || incr == null) return null;
            int idx = eidx.value;
           
            rec = update(rec, idx, incr);
            if (rec == null) return null;
            map = map.assoc(get_key(rec), rec);
           
            set(map);
            return rec.elm(idx);

          } else if (one.arity() == 4){
           
            ESmall eidx = one.elm(1).testSmall();
            incr = one.elm(2).testInteger();
            EInteger threshold = one.elm(3).testInteger();
            EInteger setvalue = one.elm(4).testInteger();
            if (eidx == null || eidx.value > rec.arity() || incr == null
                || threshold == null || setvalue == null) return null;
View Full Code Here

        ETuple rep = null;
       
        for (ESeq next = upd ; !next.isNil() ; next = next.tail()) {
          ETuple2 update = ETuple2.cast(next.head());
          if (update == null) return null;
          ESmall idx1 = update.elem1.testSmall();
          if (idx1 == null
              || idx1.value < 1
              || idx1.value > rec.arity()
              || idx1.value == keypos1) return null;
         
View Full Code Here

  @BIF
  static ESmall iolist_size(EObject val) {

    EBinary bin;
    if ((bin=val.testBinary()) != null) {
      return new ESmall(bin.byteSize());
    }
   
    EString str;
    if ((str=val.testString()) != null) {
      return new ESmall(str.length());
    }
   
   
    ECons seq;
    if ((seq = val.testCons()) == null) {
      throw ERT.badarg(val);
    }
   
    ArrayList<ByteBuffer> al = new ArrayList<ByteBuffer>();
    seq.collectIOList(al);

    int size = 0;
    for (int i = 0; i < al.size(); i++) {
      size += al.get(i).remaining();
    }
   
    return new ESmall(size);
  }
View Full Code Here

  }
 
  @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

TOP

Related Classes of erjang.ESmall

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.