Package erjang

Examples of erjang.ESeq


   
    ETable table = resolve(caller, nameOrTid, false);
    if (table == null) throw ERT.badarg(nameOrTid, matchSpec);
   
    EMatchSpec spec;
    ESeq seq;
    if ((matchSpec instanceof EMatchSpec)) {
      spec = (EMatchSpec) matchSpec;
    } else if ((seq=matchSpec.testSeq()) != null) {
      try {
        spec = EMatchSpec.compile(seq);
View Full Code Here


    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)) {
      spec = (EMatchSpec) matchSpec;
    } else if ((seq=matchSpec.testSeq()) != null) {
      try {
        spec = EMatchSpec.compile(seq);
View Full Code Here

   
  }

  @BIF static public EObject match_spec_run_r(EObject list, EObject matchSpec, EObject tail_arg) {
   
    ESeq res = tail_arg.testSeq();
    ESeq input = list.testSeq();
   
    if (res == null || input == null)
      throw ERT.badarg(list, matchSpec, tail_arg);

    EMatchSpec spec;
    ESeq seq;
    if ((matchSpec instanceof EMatchSpec)) {
      spec = (EMatchSpec) matchSpec;
    } else if ((seq=matchSpec.testSeq()) != null) {
      try {
        spec = EMatchSpec.compile(seq);
View Full Code Here

    ETable table = resolve(proc, tab, true);
    if (table == null || table.owner_pid() != proc.self_handle()) {
      throw ERT.badarg(tab, opts);
    }
   
    ESeq seq;
    if ((seq=opts.testSeq()) != null) {
      while (!seq.isNil()) {
        table.setopt(seq.head());
        seq = seq.tail();
      }
    } else {
      table.setopt(opts);
    }
 
View Full Code Here

  @BIF static public EObject update_element(EProc proc, EObject tab, EObject key, EObject upd) {
    ETable table = resolve(proc, tab, true);
   
    ETuple2 t_upd = ETuple2.cast(upd);
    ESeq   s_upd = upd.testSeq();
   
    if (table == null
        || (t_upd == null && s_upd == null
        || !(table.type==am_set || table.type==am_ordered_set)) {
      throw ERT.badarg(tab,key,upd);
View Full Code Here

      throw ERT.badarg();
    return o.self_handle();
  }

  ESeq info() {
    ESeq rep = ERT.NIL;
    ETable table = this;
   
    rep = rep.cons(new ETuple2(Native.am_owner, table.owner_pid()));
    rep = rep.cons(new ETuple2(Native.am_named_table, ERT.box(table.is_named)));
    rep = rep.cons(new ETuple2(Native.am_name, table.aname));
    if (table.heirPID != null)
      rep = rep.cons(new ETuple2(Native.am_heir, table.heirPID));
    else
      rep = rep.cons(new ETuple2(Native.am_heir, Native.am_none));
    rep = rep.cons(new ETuple2(Native.am_size, ERT.box(table.size())));
    rep = rep.cons(new ETuple2(Native.am_node, ERT.getLocalNode().node()));
    rep = rep.cons(new ETuple2(Native.am_type, table.type));
    rep = rep.cons(new ETuple2(Native.am_keypos, ERT.box(table.keypos1)));
    rep = rep.cons(new ETuple2(Native.am_protection, table.access));
    rep = rep.cons(new ETuple2(Native.am_fixed, ERT.box(is_fixed)));

    return rep;
  }
View Full Code Here

    }
  }

  @BIF
  public static EObject binary_to_term(EObject arg, EObject opts) {
    EBinary bin; ESeq options;
    if ((bin=arg.testBinary()) == null || (options = opts.testSeq()) == null) throw ERT.badarg(arg);
    EInputStream in = bin.getInputStream();
    if (!options.isNil()) {
      if (options.head() == am_safe) {
        in.setSafe(true);
      }
    }
    try {
      EObject val = in.read_any();
View Full Code Here

  @BIF
  public static EBinary term_to_binary(EObject obj, EObject spec) {
    int compression = 0;
    int minor = 1;
   
    ESeq opts;
    if ((opts=spec.testSeq()) == null) {
      throw ERT.badarg(obj, spec);
    }
   
    while (!opts.isNil()) {
     
      EObject val = opts.head();
      ETuple2 tup;
      if (val == am_compressed) {
        compression = 6;
      } else if ((tup=ETuple2.cast(val)) != null) {
        if (tup.elem1 == am_compressed) {
          ESmall sm;
          if ((sm=tup.elem2.testSmall()) != null) {
            compression = sm.value;
          } else {
            throw ERT.badarg(obj, spec);
          }
        } else if (tup.elem1 == am_minor_version) {
          ESmall sm;
          if ((sm=tup.elem2.testSmall()) != null) {
            minor = sm.value;
          } else {
            throw ERT.badarg(obj, spec);
          }
        }
      } else {
        throw ERT.badarg(obj, spec);
      }
     
      opts = opts.tail();
    }
   
    if (compression < 0 || compression > 9 || minor < 0 || minor > 1) {
      throw ERT.badarg(obj, spec);
    }
View Full Code Here

  }


  @BIF
  public static ETuple list_to_tuple(EObject obj) {
    ESeq seq;
    if ((seq = obj.testSeq()) == null)
      throw ERT.badarg(obj);
    return ETuple.make(seq.toArray());
  }
View Full Code Here

  @BIF
  public static EObject tuple_to_list(EObject tup) {
    ETuple t;
    if ((t=tup.testTuple()) == null) { throw ERT.badarg(tup); }

    ESeq res = ERT.NIL;
    for (int i = t.arity(); i > 0; i--) {
      EObject e = t.elm(i);
      res = res.cons(e==null?ERT.NIL:e);
    }
   
    return res;
  }
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.