Examples of ETuple2


Examples of erjang.ETuple2

  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

Examples of erjang.ETuple2

        return;
      }
     
    }
   
    ETuple2 tup2 = ETuple2.cast(head);
    if (tup2 != null) {
     
      if (tup2.elem1 == Native.am_protection) {
        EObject mode = tup2.elem2;
        if (mode == Native.am_private
View Full Code Here

Examples of erjang.ETuple2

      ETuple t = fun.testTuple();
      if (t == null) {
        throw ERT.badfun(fun);
      }
 
      ETuple2 t2 = ETuple2.cast(t);
      if (t2 == null) {
        throw ERT.badarg(fun,args);
      }
     
      EAtom mn = t2.elem1.testAtom();
View Full Code Here

Examples of erjang.ETuple2

  @BIF
 
  static public ESeq get_module_info(EObject mod) {
    // TODO: get all the attributes from the beam code
    ESeq res = ERT.NIL;
    res = res.cons(new ETuple2(ERT.am_compile,
           get_module_info(mod, ERT.am_compile)));

    res = res.cons(new ETuple2(ERT.am_attributes,
           get_module_info(mod, ERT.am_attributes)));

    res = res.cons(new ETuple2(ERT.am_exports,
           get_module_info(mod, ERT.am_exports)));

    return res;
  }
View Full Code Here

Examples of erjang.ETuple2

    } else if (spec == am_reductions) {
      long current_reds = proc.get_reductions();
      long since_last = current_reds - last_reductions;
      last_reductions = current_reds;
     
      return new ETuple2(ERT.box(current_reds),ERT.box(since_last));     

    } else if (spec == am_exact_reductions) {
     
      long current_reds = 0L;
      for (EProc p : EProc.all_tasks.values()) {
        current_reds += p.get_reductions();
      }
      long since_last = current_reds - last_exact_reductions;
      last_exact_reductions = current_reds;
     
      return new ETuple2(ERT.box(current_reds),ERT.box(since_last));     

    } else if (spec == am_runtime) {
     
      ThreadMXBean b = ManagementFactory.getThreadMXBean();
      long[] ts = b.getAllThreadIds();
      long current_runtime = 0;
      for (int i = 0; i < ts.length; i++) {
        long thread_time = b.getThreadCpuTime(ts[i]);
        if (thread_time != -1) { // it died in the mean time...
          current_runtime += thread_time;
        }
      }
      long since_last = (current_runtime - last_runtime) / 1000000;
      last_runtime = current_runtime;
     
      return new ETuple2(ERT.box(current_runtime / 1000000),ERT.box(since_last))
     
    } else if (spec == am_garbage_collection) {
     
      List<GarbageCollectorMXBean> b = ManagementFactory.getGarbageCollectorMXBeans();
View Full Code Here

Examples of erjang.ETuple2

    EString str = path.testString();
    if (str == null) { throw ERT.badarg(path, info); }
   
    NIF nif = NIF.load(str.stringValue() + ".so", info);
    if (nif == null) {
      return new ETuple2(ERT.am_error,
            new ETuple2(am_load_failed, ERT.am_undefined)
          );
    } else {
      return ERT.am_ok;
    }
  }
View Full Code Here

Examples of erjang.ETuple2

      throw ERT.badarg(mod, bin);

    try {
      EModule module = EModuleLoader.load_module(mod.getName(), bin);
      if (module.has_on_load()) {
        return new ETuple2(ERT.am_error, am_on_load);
      } else {
        return new ETuple2(ERT.am_module, mod);
      }
    } catch (ErlangException e) {
      log.log(Level.FINE, "cannot load module", e);
      return new ETuple2(ERT.am_error, e.reason());
    } catch (ThreadDeath e) {
      throw e;
    } catch (Throwable e) {
      ErlangError ee = new ErlangError(ERT.am_badfile, e, mod, bin);
      ETuple2 result = new ETuple2(ERT.am_error, ee.reason());
     
      log.log(Level.SEVERE, "cannot load module "+mod, e);
     
      return result;
    }
View Full Code Here

Examples of erjang.ETuple2

    ETuple3 time = new ETuple3();
    time.set(1, ERT.box(c.get(Calendar.HOUR_OF_DAY)));
    time.set(2, ERT.box(c.get(Calendar.MINUTE)));
    time.set(3, ERT.box(c.get(Calendar.SECOND)));
   
    return new ETuple2(date, time);
  }
View Full Code Here

Examples of erjang.ETuple2

    ETuple3 time = new ETuple3();
    time.set(1, ERT.box(c.get(Calendar.HOUR_OF_DAY)));
    time.set(2, ERT.box(c.get(Calendar.MINUTE)));
    time.set(3, ERT.box(c.get(Calendar.SECOND)));
   
    return new ETuple2(date, time);
  }
View Full Code Here

Examples of erjang.ETuple2

  }
 
  @BIF
  static public EObject localtime_to_universaltime(EObject a1, EObject a2)
  {
    ETuple2 dt;
    if ((dt=ETuple2.cast(a1)) != null) {
      ETuple3 date;
      ETuple3 time;
      ESmall year;
      ESmall month;
      ESmall day;
      ESmall hour;
      ESmall minute;
      ESmall sec;
      if (   (date=ETuple3.cast( dt.elem1 )) != null
        && (year = date.elem1.testSmall()) != null
        && (month = date.elem2.testSmall()) != null
        && (day = date.elem3.testSmall()) != null
       
        && (time=ETuple3.cast( dt.elem2 )) != null
        && (hour = time.elem1.testSmall()) != null
        && (minute = time.elem2.testSmall()) != null
        && (sec = time.elem3.testSmall()) != null
       
      ) {

        Calendar in_date = GregorianCalendar.getInstance();
        in_date.set(Calendar.YEAR, year.value);
        in_date.set(Calendar.MONTH, month.value-1+Calendar.JANUARY);
        in_date.set(Calendar.DAY_OF_MONTH, day.value);
       
        in_date.set(Calendar.HOUR_OF_DAY, hour.value);
        in_date.set(Calendar.MINUTE, minute.value);
        in_date.set(Calendar.SECOND, sec.value);
       
        Calendar out_date = GregorianCalendar.getInstance(UTC_TIME_ZONE);
        out_date.setTimeInMillis(in_date.getTimeInMillis());
       
        ETuple3 date2 = new ETuple3();
        date2.set(1, ERT.box(out_date.get(Calendar.YEAR)));
        date2.set(2, ERT.box(out_date.get(Calendar.MONTH)-Calendar.JANUARY+1));
        date2.set(3, ERT.box(out_date.get(Calendar.DAY_OF_MONTH)));
       
        ETuple3 time2 = new ETuple3();
        time2.set(1, ERT.box(out_date.get(Calendar.HOUR_OF_DAY)));
        time2.set(2, ERT.box(out_date.get(Calendar.MINUTE)));
        time2.set(3, ERT.box(out_date.get(Calendar.SECOND)));
       
        return new ETuple2(date2, time2);   
      }
    }

    throw ERT.badarg(a1, a2);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.