Squeak Class Documentation category index | class index  
 
LargeIntegersPlugin
  category: VMConstruction-Plugins
  superclass: TestInterpreterPlugin
  subclasses:

LargeIntegersPlugin provides functions for speeding up LargeInteger arithmetics.

Inst vars:
andOpIndex C constant
orOpIndex C constant
xorOpIndex C constant
Used like an enum, in ST one would use symbols instead.

Class vars:
none


Evaluations
-------------

Try

LargeIntegersTest getModuleName.

If it is nil, you probably have an older LargeInteger module or none at all; it works for version number 'v1.1' or higher.


History
--------

v1.2

- fix: >>anyBitOfBytes: aBytesOop from: start to: stopArg

v1.1

- >>primGetModuleName for checking the version of the plugin;

- >>primDigitBitShiftMagnitude and >>primAnyBitFrom:to: for supporting - not installing! - unification of shift semantics of negative Integers;

v1.0

- speeds up digitDiv:neg: at about 20%.
In >>cCoreDigitDivDiv:len:rem:len:quo:len: the 'nibble' arithmetic is removed.

instance methods
  C core
  cByteOp:short:len:long:len:into:
cBytesLshift:from:len:to:len:
cCoreBytesRshiftCount:n:m:f:bytes:from:len:to:len:
cCoreDigitDivDiv:len:rem:len:quo:len:
cDigitAdd:len:with:len:into:
cDigitCompare:with:len:
cDigitMultiply:len:with:len:into:
cDigitSub:len:with:len:into:

  C core util
  cBytesCopyFrom:to:len:
cBytesHighBit:len:
cBytesReplace:from:to:with:startingAt:
cCopyIntVal:toBytes:
cDigitLengthOfCSI:
cDigitOfCSI:at:
cHighBit:

  Integer primitives
  primAnyBitFrom:to:
primDigitAdd:
primDigitBitAnd:
primDigitBitOr:
primDigitBitShiftMagnitude:
primDigitBitXor:
primDigitCompare:
primDigitDiv:negative:
primDigitMultiply:negative:
primDigitSubtract:
primNormalizeNegative
primNormalizePositive

  ST initialize
  initialize

  control & support primitives
  primAsLargeInteger:
primCheckIfCModuleExists
primGetModuleName

  debugging
  assert:
debugCode:
think

  development primitives
  primDigit:bitShift:
primDigitAdd:with:
primDigitBitLogic:with:op:
primDigitCompare:with:
primDigitDiv:with:negative:
primDigitMultiply:with:negative:
primDigitSubtract:with:
primNormalize:

  obsolete
  primDigitBitShift:

  oop functions
  bytes:Lshift:
bytes:Rshift:bytes:lookfirst:
digitAddLarge:with:
digitBitLogic:with:opIndex:
digitCompareLarge:with:
digitDivLarge:with:negative:
digitMultiplyLarge:with:negative:
digitSubLarge:with:
normalize:
normalizeNegative:
normalizePositive:

  oop util
  bytes:growTo:
bytesOrInt:growTo:
createLargeFromSmallInteger:

  util
  anyBitOfBytes:from:to:
byteSizeOfBytes:
digitLength:
digitOf:at:
digitOfBytes:at:
highBitOfBytes:
negative:
unsafeByteOf:at:

class methods
  instance creation
  new

  translation
  declareCVarsIn:
moduleName
moduleNameAndVersion
version

instance methods
  C core top  
 

cByteOp:short:len:long:len:into:

pByteRes len = longLen.


 

cBytesLshift:from:len:to:len:

C indexed!


 

cCoreBytesRshiftCount:n:m:f:bytes:from:len:to:len:


 

cCoreDigitDivDiv:len:rem:len:quo:len:


 

cDigitAdd:len:with:len:into:

pByteRes len = longLen; returns over..


 

cDigitCompare:with:len:

Precondition: pFirst len = pSecond len.


 

cDigitMultiply:len:with:len:into:

pByteRes len = longLen * shortLen


 

cDigitSub:len:with:len:into:


  C core util top  
 

cBytesCopyFrom:to:len:


 

cBytesHighBit:len:

Answer the index (in bits) of the high order bit of the receiver, or zero if the
receiver is zero. This method is allowed (and needed) for
LargeNegativeIntegers as well, since Squeak's LargeIntegers are
sign/magnitude.


 

cBytesReplace:from:to:with:startingAt:

C indexed!


 

cCopyIntVal:toBytes:


 

cDigitLengthOfCSI:

Answer the number of indexable fields of a CSmallInteger. This value is
the same as the largest legal subscript.


 

cDigitOfCSI:at:

Answer the value of an indexable field in the receiver.
LargePositiveInteger uses bytes of base two number, and each is a
'digit' base 256.


 

cHighBit:

Answer the index of the high order bit of the argument, or zero if the
argument is zero.


  Integer primitives top  
 

primAnyBitFrom:to:


 

primDigitAdd:


 

primDigitBitAnd:

Bit logic here is only implemented for positive integers or Zero; if rec
or arg is negative, it fails.


 

primDigitBitOr:

Bit logic here is only implemented for positive integers or Zero; if rec
or arg is negative, it fails.


 

primDigitBitShiftMagnitude:


 

primDigitBitXor:

Bit logic here is only implemented for positive integers or Zero; if rec
or arg is negative, it fails.


 

primDigitCompare:


 

primDigitDiv:negative:

Answer the result of dividing firstInteger by secondInteger. Fail if
parameters are not integers or secondInteger is zero.


 

primDigitMultiply:negative:


 

primDigitSubtract:


 

primNormalizeNegative


 

primNormalizePositive


  ST initialize top  
 

initialize

Initializes ST constants; C's are set by class>>declareCVarsIn:.


  control & support primitives top  
 

primAsLargeInteger:

Converts a SmallInteger into a - non normalized! - LargeInteger;
aLargeInteger will be returned unchanged.


 

primCheckIfCModuleExists

If calling this primitive fails, then C module does not exist. Do not check for forced fail, because we want to know if module exists during forced fail, too.


 

primGetModuleName

If calling this primitive fails, then C module does not exist.


  debugging top  
 

assert:

Throw an assertion error if aBlock does not evaluates to true.


 

debugCode:


 

think

Flag for marking methods for later thinking.


  development primitives top  
 

primDigit:bitShift:


 

primDigitAdd:with:


 

primDigitBitLogic:with:op:

Bit logic here is only implemented for positive integers or Zero; if any arg is negative, it fails.


 

primDigitCompare:with:


 

primDigitDiv:with:negative:

Answer the result of dividing firstInteger by secondInteger. Fail if
parameters are not integers or secondInteger is zero.


 

primDigitMultiply:with:negative:


 

primDigitSubtract:with:


 

primNormalize:

Parameter specification #(Integer) doesn't convert!


  obsolete top  
 

primDigitBitShift:


  oop functions top  
 

bytes:Lshift:

Attention: this method invalidates all oop's! Only newBytes is valid at
return.


 

bytes:Rshift:bytes:lookfirst:

Attention: this method invalidates all oop's! Only newBytes is valid at
return.


 

digitAddLarge:with:

Does not need to normalize!


 

digitBitLogic:with:opIndex:

Bit logic here is only implemented for positive integers or Zero; if rec
or arg is negative, it fails.


 

digitCompareLarge:with:

Compare the magnitude of firstInteger with that of secondInteger.
Return a code of 1, 0, -1 for firstInteger >, = , < secondInteger


 

digitDivLarge:with:negative:

Does not normalize.


 

digitMultiplyLarge:with:negative:

Normalizes.


 

digitSubLarge:with:

Normalizes.


 

normalize:

Check for leading zeroes and return shortened copy if so.


 

normalizeNegative:

Check for leading zeroes and return shortened copy if so


 

normalizePositive:

Check for leading zeroes and return shortened copy if so


  oop util top  
 

bytes:growTo:

Attention: this method invalidates all oop's! Only newBytes is valid at
return.


 

bytesOrInt:growTo:

Attention: this method invalidates all oop's! Only newBytes is valid at
return.


 

createLargeFromSmallInteger:

anOop has to be a SmallInteger!


  util top  
 

anyBitOfBytes:from:to:

Argument has to be aBytesOop!


 

byteSizeOfBytes:

Precondition: bytesOop is not anInteger and a bytes object.


 

digitLength:


 

digitOf:at:


 

digitOfBytes:at:

Argument has to be aLargeInteger!


 

highBitOfBytes:


 

negative:


 

unsafeByteOf:at:

Argument bytesOop must not be aSmallInteger!


class methods
  instance creation top  
 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


  translation top  
 

declareCVarsIn:

Note: This method must be implemented by all subclasses to declare variables.


 

moduleName

Answer the receiver's module name that is used for the plugin's C code.


 

moduleNameAndVersion

Answer the receiver's module name and version info that is used for the plugin's C code. The default is to append the code generation date, but any useful text is ok (keep it short)


 

version

Answer the receiver's version info as String.