package jazz.lang; /////////////////////////////////////////////////////////////////////////////// // // Infinite precision periodic 2-adic numbers // /////////////////////////////////////////////////////////////////////////////// public native class per extends rat implements BooleanAlgebra { // Slice of bits from "i" to "j" (exclusive) public native slice(i: int, j: int): int = "%slice"; // "i"-th bit of the 2-adic representation of the periodic number public native bit(i: int): int = "%bit"; // Length of the prefix of the 2-adic representation of the periodic number public native prefixLength(): int = "%prefixLength"; // Length of the period of the 2-adic representation of the periodic number public native periodLength(): int = "%periodLength"; } /////////////////////////////////////////////////////////////////////////////// // // Implementation // /////////////////////////////////////////////////////////////////////////////// native final Builtin.(&)(x@per, y@per) = "%binary_and"; native final Builtin.(|)(x@per, y@per) = "%binary_or"; native final Builtin.(^)(x@per, y@per) = "%binary_xor"; native final Builtin.(~)(x@per) = "%binary_not"; native final Builtin.cond(x@per, y@per, z@per) = "%mux";