Module: common-dylan-internals Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND ////////////////////////////////////////////////////////////////////////////// // u%< define sealed generic u%< (x :: , y :: ) => result :: ; define inline method u%< (x :: , y :: ) => result :: ; machine-word-unsigned-less-than?(x, y); end method; define inline method u%< (x :: , y :: ) => result :: ; machine-word-unsigned-less-than? (x, coerce-abstract-integer-to-machine-word(y)); end method; define inline method u%< (x :: , y :: ) => result :: ; machine-word-unsigned-less-than? (coerce-abstract-integer-to-machine-word(x), y); end method; define inline method u%< (x :: , y :: ) => result :: ; machine-word-unsigned-less-than? (coerce-abstract-integer-to-machine-word(x), coerce-abstract-integer-to-machine-word(y)); end method; ////////////////////////////////////////////////////////////////////////////// // u%+ (x :: , y :: ) // => (sum :: , carry :: ) // // u%- (x :: , y :: ) // => (diff :: , borrow :: ) // // u%* (x :: , y :: ) // => (low :: , high :: ) // // u%divide (dividend :: , divisor :: ) // => (quotient :: , remainder :: ) define macro unsigned-arithmetic-definer { define unsigned-arithmetic ?:name ?lowlevel:name } => { define sealed generic ?name (x :: , y :: ) => (v1 :: , v2 :: ); define inline method ?name (x :: , y :: ) => (v1 :: , v2 :: ); ?lowlevel(x, y); end method; define inline method ?name (x :: , y :: ) => (v1 :: , v2 :: ); ?lowlevel(x, coerce-abstract-integer-to-machine-word(y)); end method; define inline method ?name (x :: , y :: ) => (v1 :: , v2 :: ); ?lowlevel(coerce-abstract-integer-to-machine-word(x), y) end method; define inline method ?name (x :: , y :: ) => (v1 :: , v2 :: ); ?lowlevel(coerce-abstract-integer-to-machine-word(x), coerce-abstract-integer-to-machine-word(y)); end method; } end; define unsigned-arithmetic u%+ machine-word-unsigned-add-with-carry; define unsigned-arithmetic u%- machine-word-unsigned-subtract-with-borrow; define unsigned-arithmetic u%* machine-word-unsigned-multiply; define unsigned-arithmetic u%divide machine-word-unsigned-divide; ////////////////////////////////////////////////////////////////////////////// // u%rotate-left (m :: , count :: ) // => result :: // // u%rotate-right (m :: , count :: ) // => result :: // // u%shift-left (m :: , count :: ) // => result :: // // u%shift-right (m :: , count :: ) // => result :: define macro unsigned-shift-definer { define unsigned-shift ?:name ?lowlevel:name } => { define sealed generic ?name (m :: , count :: ) => result :: ; define inline method ?name (m :: , count :: ) => result :: ; check-shift-quantity(count); ?lowlevel(m, count); end method; define inline method ?name (m :: , count :: ) => result :: ; check-shift-quantity(count); ?lowlevel(coerce-abstract-integer-to-machine-word(m), count); end method; } end macro; define unsigned-shift u%rotate-left machine-word-unsigned-rotate-left; define unsigned-shift u%rotate-right machine-word-unsigned-rotate-right; define unsigned-shift u%shift-left machine-word-unsigned-shift-left; define unsigned-shift u%shift-right machine-word-unsigned-shift-right;