@BIF public static EObject hibernate(EProc self, EObject a1, EObject a2, EObject a3) { EAtom m = a1.testAtom(); EAtom f = a2.testAtom(); ESeq a = a3.testSeq(); if (m == null || f == null || a == null) { throw ERT.badarg(a1, a2, a3); } int arity = a.length(); EFun target = EModuleManager.resolve(new FunID(m, f, arity)); if (target == null) { throw new ErlangUndefined(m, f, new ESmall(arity)); } self.tail = target; a = a.reverse(); switch (arity) { default: throw new NotImplemented("hibernate w/" + arity + " args"); case 7: self.arg6 = a.head(); a = a.tail(); case 6: self.arg5 = a.head(); a = a.tail(); case 5: self.arg4 = a.head(); a = a.tail(); case 4: self.arg3 = a.head(); a = a.tail(); case 3: self.arg2 = a.head(); a = a.tail(); case 2: self.arg1 = a.head(); a = a.tail(); case 1: self.arg0 = a.head(); // a = a.tail(); case 0: } throw ErjangHibernateException.INSTANCE; }
@BIF static EAtom module_loaded(EObject mod) { EAtom m; if ((m = mod.testAtom()) == null) throw ERT.badarg(mod); return EModuleManager.module_loaded(m) ? ERT.TRUE : ERT.FALSE; }