Module: dfmc-modeling 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 /// The emulator does all its arithmetic using Lisp bignums which provide /// arbitrary precision and, consequently, avoid all problems w.r.t. losing the /// high-order bits of folded constants. /// Only needed because its referenced by make-raw-literal() define function target-machine-word-mask () => (mask :: ) -1 end function target-machine-word-mask; /// Extracts the operand to a primitive as an /// taking care to mask the value of the operand to the size of a /// on the target system. define inline-only function extract-mw-operand-unsigned (rx :: <&raw-machine-word>) => (x :: ) select (rx by instance?) <&raw-integer> => ^raw-object-value(rx); <&raw-byte-character> => // No need to mask as s are always positive and "small" ... as(, ^raw-object-value(rx)); <&raw-machine-word> => let x = ^raw-object-value(rx); select (x by instance?) => x; => // No need to mask as s are always positive and "small" ... as(, x); => //---*** DO THESE HAPPEN IN THE EMULATOR???? error("Huh?") end end end function extract-mw-operand-unsigned; /// Extracts the operand to a primitive as an /// while ensuring that the operand's sign is properly extended. define inline-only function extract-mw-operand-signed (rx :: <&raw-machine-word>) => (x :: ) select (rx by instance?) <&raw-integer> => ^raw-object-value(rx); <&raw-byte-character> => as(, ^raw-object-value(rx)); <&raw-machine-word> => let x = ^raw-object-value(rx); select (x by instance?) => x; => // No need to mask as s are always positive and "small" ... as(, x); => //---*** DO THESE HAPPEN IN THE EMULATOR???? error("Huh?") end end end function extract-mw-operand-signed; /// Identical to make-raw-literal but checks that the value will actually /// fit into a on the target system for use by folders for /// primitives which are supposed to signal overflow. define inline-only function make-raw-literal-with-overflow (object :: ) => (literal :: <&raw-machine-word>) //---*** NOTE: I'm not absolutely sure that this is correct ... make-raw-literal(object) end function make-raw-literal-with-overflow;