Package erjang

Examples of erjang.ECons


      throw ERT.badarg();
    }

    // [] | [ConditionExpression, ...]
    ECons cons = expr.testCons();
    if (cons != null && !cons.isNil()) {
      // nil falls thru to the ConstantExpr below

      return new ConsConstruct(cons, ctx);
    }
View Full Code Here


  }

  private static Pattern compile_Match(EObject head, ParseContext ctx) {
    EAtom am;
    ECons cons;
    ETuple tuple;

    // is it '_'
    if (head == am_ANY) {
      return (AnyPattern.INSTANCE);
View Full Code Here

    }
   
    ETuple2 tup;
    if (type == am_allocated_areas) {

      ECons res = ERT.NIL;

      List<MemoryPoolMXBean> bean2 = ManagementFactory
          .getMemoryPoolMXBeans();

      if (bean2 == null) {

        MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
        if (bean != null) {

          MemoryUsage mu = bean.getHeapMemoryUsage();
          res = res.cons(ETuple.make(am_heap, ERT.box(mu.getCommitted()),
              ERT.box(mu.getUsed())));

          mu = bean.getNonHeapMemoryUsage();
          res = res.cons(ETuple.make(am_non_heap, ERT.box(mu
              .getCommitted()), ERT.box(mu.getUsed())));

        }
       
        return res;
      }
     
      for (MemoryPoolMXBean mb : bean2) {
       
        String name = mb.getName();
        MemoryUsage mu = mb.getUsage();
        if (mu == null) continue;
       
        String name2 = (mb.getType()==MemoryType.HEAP ? "heap:" : "non_heap:" ) + name;
       
        res = res.cons(ETuple.make(EAtom.intern(name2), ERT.box(mu
            .getCommitted()), ERT.box(mu.getUsed())));

       
      }
     
View Full Code Here

  /** os:getenv() -> [string()] */
  @BIF
  public static EObject getenv() {
    Map<String,String> env = System.getenv();

    ECons res = ERT.NIL;
    for (Map.Entry<String,String> entry : env.entrySet()) {
      String s = entry.getKey() + "=" + entry.getValue();
      res = res.cons(EString.fromString(s));
    }
    return res;
  }
View Full Code Here

  public static EBitString iolist_to_binary(EObject list) {
    EBitString bin = list.testBitString();
    if (bin != null)
      return bin;

    ECons iol = list.testCons();
    if (iol == null)
      throw ERT.badarg(list);

    if (iol.isNil()) {
      return EBinary.EMPTY;
    }
   
    BARR barr = new BARR();
View Full Code Here

    return barr.asBinary();
  }

  private static void collectList(EObject list, ECons iol, OutputStream barr) throws IOException {
    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);
        barr.write(sm.value);
      } else if ((bi = hd.testBinary()) != null) {
View Full Code Here

   * @param list io list containing terms to write
   * @param out output stream
   * @throws IOException in case of io errors
   */
  public static void collectList(EObject list, OutputStream out) throws IOException {
    ECons iol = list.testCons();
    if (iol == null)
      throw ERT.badarg(list);

    if (iol.isNil()) {
      return;
    }

    collectList(list, iol, out);
  }
View Full Code Here

    EString es;
    if ((es = val.testString()) != null) {
      return es.asBitString();
    }

    ECons cons = val.testCons();
    if (cons == null) throw ERT.badarg(val);
    List<ByteBuffer> out = new ArrayList<ByteBuffer>();
    if (!cons.collectIOList(out)) {
      throw ERT.badarg(val);
    }

    if (out.size() == 1) {
      ByteBuffer b = out.get(0);
View Full Code Here

    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();
    }
View Full Code Here

  }

  @BIF
 
  static public EPID list_to_pid(EObject obj) {
    ECons list;
    if ((list = obj.testCons()) != null) {
      ESeq s = EString.make(list);
      return ERT.loopkup_pid(s);
    }
    throw ERT.badarg(obj);
View Full Code Here

TOP

Related Classes of erjang.ECons

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.