Package erjang

Examples of erjang.ESeq


            throw ERT.badarg(arg1, arg2);
       
        int depth = d.intValue();
        if (depth < 0) depth=Integer.MAX_VALUE;
       
        ESeq builder = ERT.NIL;
        long bitCount = bin.bitSize();
        if (bitCount > 8*(depth-1)) {
            // Replace tail with ellipsis:
            builder = builder.cons(EString.fromString("..."));
        } else if (bitCount % 8 > 0) {
            // Handle tail bits
            int tailBitCount = (int)(bitCount & 7);
            int tailBits = bin.intBitsAt(bitCount & (~7), tailBitCount);
            builder = builder.cons(EString.fromString(String.valueOf(tailBitCount)));
            builder = builder.cons(ESmall.make(':'));
            builder = builder.cons(EString.fromString(String.valueOf(tailBits)));
        }
        // Handle whole bytes:
        for (long bitPos=8*(Math.min(bitCount/8, depth-1)-1);
             bitPos>=0;
             bitPos-=8)
        {
            if (bitPos < bitCount-8) {
                builder = builder.cons(ESmall.make(','));
            }
            String byteAsIntString = String.valueOf(bin.intBitsAt(bitPos, 8));
            builder = builder.cons(EString.fromString(byteAsIntString));
        }
        return builder;
    }
View Full Code Here


  @BIF
  public static EObject monitor_node(EProc proc, EObject node, EObject flag, EObject opts) throws Pausable {
   
    EAtom aname = node.testAtom();
    EAtom aflag = flag.testAtom();
    ESeq sopts = opts.testSeq();
   
    if (aname == null || aflag == null || sopts == null) {
      throw ERT.badarg(node, flag);
    }
   
View Full Code Here

    // types. They should also be public static, so that calls to
    // it can be embedded directly in compiled code.

    // test argument types
    EAtom aname = name.testAtom();
    ESeq opts = options.testSeq();

    if (aname == null || opts == null) {
      // make sure to pass the original arguments to badarg, not
      // the converted ones. Java 'null' values are never allowed
      // in the erjang world except as a return value from type tests
      // and other guard BIFs.
      throw ERT.badarg(name, options);
    }

    // default configuration
    EAtom type = am_set;
    EAtom access = am_protected;
    int keypos = 1;
    boolean write_concurrency = false;
    boolean read_concurrency = false;
    EInternalPID heir_pid = null;
    EObject heir_data = null;
    boolean is_named = false;

    for (; !opts.isNil(); opts = opts.tail()) {
      EObject option = opts.head();

      EAtom atom;
      ETuple2 t2;
      ETuple3 t3;
      if ((atom = option.testAtom()) != null) {
View Full Code Here

  public static EObject insert(EProc proc, EObject tab, EObject oneOrMore) {
   
    // test arguments
    ETable table = resolve(proc, tab, true);
    ETuple one = oneOrMore.testTuple();
    ESeq more = oneOrMore.testSeq();
    if (table == null || (one == null && more == null)) {
      throw ERT.badarg(tab, oneOrMore);
    }

    if (one != null) {
View Full Code Here

    ETable table = resolve(proc, tab, false);
    if (table == null || p == null) {
      throw ERT.badarg(tab, key, pos);
    }

    ESeq ent = table.lookup(key);
    if (ent == ERT.NIL) {
      throw ERT.badarg(tab, key, pos);
    }
   
    if (table.type == am_set || table.type == am_ordered_set) {
      return get_elm(tab, key, p, ent);
    } else {
      ESeq res = ERT.NIL;
     
      for (; !ent.isNil(); ent = ent.tail()) {
        res = res.cons( get_elm(tab, key, p, ent) );
      }
      return res;
    }
  }
View Full Code Here

  public static EObject insert_new(EProc proc, EObject tab, EObject oneOrMore) {
   
    // test arguments
    ETable table = resolve(proc, tab, true);
    ETuple one = oneOrMore.testTuple();
    ESeq more = oneOrMore.testSeq();
    if (table == null || (one == null && more == null)) {
      throw ERT.badarg(tab, oneOrMore);
    }

    boolean result;
View Full Code Here

    }
  }
 
  @BIF static EInteger select_delete(EProc caller, EObject nameOrTid, EObject spec)
  {
    ESeq lspec = spec.testSeq();
    ETable table = resolve(caller, nameOrTid, true);
    if (lspec == null || table == null) throw ERT.badarg(nameOrTid, spec);
   
    EMatchSpec matcher = EMatchSpec.compile(lspec);
   
View Full Code Here

    table.delete_all_objects();
    return ERT.TRUE;
  }
 
  @BIF static public EObject match_spec_compile(EObject spec) {
    ESeq lspec = spec.testSeq();
    if (lspec == null) throw ERT.badarg(spec);
    EMatchSpec matcher = EMatchSpec.compile(lspec);
    return matcher;
  }
View Full Code Here

    }
  }
 
  @BIF static public ESeq all() {
   
    ESeq res = ERT.NIL;
   
    for (ETable table : tid_to_table.values()) {
      if (table.is_named) {
        res = res.cons(table.aname);
      } else {
        res = res.cons(table.tid);
      }
    }
   
    return res;
  }
View Full Code Here

    }
   
  }

  @BIF static public ESmall select_count(EProc caller, EObject nameOrTid, EObject matchSpec) {
    ESeq res = select(caller, nameOrTid, matchSpec);
    int result = 0;
    while (!res.isNil()) {
      if (res.head() == ERT.TRUE)
        result += 1;
      res = res.tail();
    }
    return ERT.box(result);
  }
View Full Code Here

TOP

Related Classes of erjang.ESeq

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.