Permalink
Browse files

Implement new BIFs for R15

- erlang:dt_prepend_vm_tag_data/1
- erlang:posixtime_to_universaltime/1
- erlang:check_old_code/1
  • Loading branch information...
krestenkrab committed Jun 5, 2012
1 parent 0978e4a commit e7487d6008415f6f0a689fa204f5f526f9b4b7b9
@@ -2016,4 +2016,9 @@ public static EObject dt_restore_tag(EObject o) {
return o;
}
+ @BIF
+ public static EObject dt_prepend_vm_tag_data(EObject o) {
+ return o;
+ }
+
}
@@ -22,9 +22,12 @@
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
import erjang.BIF;
import erjang.EAtom;
+import erjang.EBig;
import erjang.EBinary;
import erjang.EBitString;
import erjang.ECons;
@@ -41,6 +44,7 @@
import erjang.ETuple;
import erjang.ERef;
import erjang.ETuple2;
+import erjang.ETuple3;
import erjang.ErlangError;
import erjang.NotImplemented;
import erjang.driver.IO;
@@ -389,4 +393,33 @@ public static EBinary atom_to_binary(EObject obj, EObject enc) {
return new EBinary(data);
}
+ @BIF
+ public static ETuple2 posixtime_to_universaltime(EObject time)
+ {
+ long millis;
+ ESmall small = time.testSmall();
+ EBig big = time.testBig();
+
+ if (small != null) {
+ millis = small.intValue();
+ } else if (big != null) {
+ millis = big.longValue();
+ } else {
+ throw ERT.badarg();
+ }
+
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeInMillis(millis);
+
+ int year = c.get(Calendar.YEAR);
+ int month = c.get(Calendar.MONTH) - Calendar.JANUARY + 1;
+ int day_of_month = c.get(Calendar.DAY_OF_MONTH);
+
+ int hour_of_day = c.get(Calendar.HOUR_OF_DAY);
+ int minute_of_hour = c.get(Calendar.MINUTE);
+ int seconds = c.get(Calendar.SECOND);
+
+ return new ETuple2( ETuple.make( ERT.box(year), ERT.box(month), ERT.box(day_of_month) ),
+ ETuple.make( ERT.box(hour_of_day), ERT.box(minute_of_hour), ERT.box(seconds) ));
+ }
}
@@ -677,6 +677,18 @@ public static EObject suspend_process(EObject a1, EObject a2) {
throw new NotImplemented();
}
+ @BIF
+ public static EAtom check_old_code(EObject mod_arg) {
+
+ EAtom mod = mod_arg.testAtom();
+
+ if (mod == null) { throw ERT.badarg(mod_arg); }
+
+ log.log(Level.FINE, "check_old_code not implemented (" + mod + ")");
+
+ return ERT.FALSE;
+ }
+
@BIF
public static EAtom check_process_code(EObject pid_arg, EObject mod_arg) {
EPID pid = pid_arg.testPID();

0 comments on commit e7487d6

Please sign in to comment.