'From Cuis 1.0 of 6 March 2009 [latest update: #5989] on 24 March 2009 at 3:06:36 pm'!

!BitBltSimulation methodsFor: 'combination rules' stamp: 'jmv 3/24/2009 15:00'!
partitionedMul: word1 with: word2 nBits: nBits nPartitions: nParts
	"Multiply word1 with word2 as nParts partitions of nBits each.
	This is useful for packed pixels, or packed colors.
	Bug in loop version when non-white background"

	| sMask product result dMask |
	sMask _ maskTable at: nBits.  "partition mask starts at the right"
	dMask _  sMask << nBits.
	result _ (((word1 bitAnd: sMask)+1) * ((word2 bitAnd: sMask)+1) - 1 
				bitAnd: dMask) >> nBits.	"optimized first step"
	product _ (((word1>>nBits bitAnd: sMask)+1) * ((word2>>nBits bitAnd: sMask)+1) - 1 bitAnd: dMask).
	result _ result bitOr: (product bitAnd: dMask).
	product _ (((word1>>(2*nBits) bitAnd: sMask)+1) * ((word2>>(2*nBits) bitAnd: sMask)+1) - 1 bitAnd: dMask).
	result _ result bitOr: (product bitAnd: dMask) << nBits.
	^ result


"
	| sMask product result dMask |
	sMask _ maskTable at: nBits.  'partition mask starts at the right'
	dMask _  sMask << nBits.
	result _ (((word1 bitAnd: sMask)+1) * ((word2 bitAnd: sMask)+1) - 1 
				bitAnd: dMask) >> nBits.	'optimized first step'
	nBits to: nBits * (nParts-1) by: nBits do: [:ofs |
		product _ (((word1>>ofs bitAnd: sMask)+1) * ((word2>>ofs bitAnd: sMask)+1) - 1 bitAnd: dMask).
		result _ result bitOr: (product bitAnd: dMask) << (ofs-nBits)].
	^ result
"! !


!ChangeList class methodsFor: 'initialize-release' stamp: 'jmv 3/24/2009 14:58'!
initialize

	FileList registerFileReader: self! !


!ByteArray methodsFor: '*FFI' stamp: 'jmv 3/24/2009 14:57'!
pointerAt: byteOffset put: value
	"Store a pointer object at the given byte address"
	
	value isExternalAddress ifFalse:[ ^self error:'Only external addresses can be stored' ].
	1 to: 4 do: [ :i |
		self unsignedByteAt: byteOffset+i-1 put: (value basicAt: i)].
	^value! !

!ByteArray methodsFor: '*FFI' stamp: 'jmv 3/24/2009 14:57'!
structAt: byteOffset length: length
	"Return a structure of the given length starting at the indicated byte offset."
	
	| value |
	value _ ByteArray new: length.
	1 to: length do: [:i |
		value unsignedByteAt: i put: (self unsignedByteAt: byteOffset+i-1)].
	^value! !


!FileContentsBrowser class methodsFor: 'class initialization' stamp: 'jmv 3/24/2009 15:04'!
initialize

	FileList registerFileReader: self! !


!FileStream class methodsFor: 'initialize-release' stamp: 'jmv 3/24/2009 14:58'!
initialize

	FileList registerFileReader: self! !

!FileStream class methodsFor: 'file reader services' stamp: 'jmv 3/24/2009 14:58'!
isSourceFileSuffix: suffix

	^(suffix = 'st') | (suffix = 'cs') | (suffix = '*')! !


!Form class methodsFor: 'mode constants' stamp: 'jmv 3/24/2009 14:59'!
rgbMul
	"Answer the integer denoting 'Multiply each color component, their values regarded as fractions of 1' rule."

	^ 37! !

!Form class methodsFor: 'initialize-release' stamp: 'jmv 3/24/2009 14:59'!
initialize

	FileList registerFileReader: self! !

!Form class methodsFor: 'fileIn/Out' stamp: 'jmv 3/24/2009 15:00'!
openAsBackground: fullName
	"Set an image as a background image.  Support Squeak's common file format 
	(GIF, JPG, PNG, 'Form stoteOn: (run coded)' and BMP)"

	(self fromFileNamed: fullName) setAsBackground! !


!MethodNode methodsFor: '*VMMaker-C translation' stamp: 'jmv 3/24/2009 15:04'!
asTranslationMethodOfClass: aClass
 
	^ aClass new
		setSelector: selectorOrFalse
		args: arguments
		locals: encoder tempsAndBlockArgs
		block: block
		primitive: primitive;
		comment: comment! !


!TMethod methodsFor: 'accessing' stamp: 'jmv 3/24/2009 15:02'!
comment: aComment

	comment _ aComment! !

!TMethod methodsFor: 'C code generation' stamp: 'jmv 3/24/2009 15:02'!
emitCCodeOn: aStream generator: aCodeGen
	"Emit C code for this method onto the given stream. All calls to inlined methods should already have been expanded."

	"place method comment before function"
	self emitCCommentOn: aStream.

	self emitCHeaderOn: aStream generator: aCodeGen.
	parseTree emitCCodeOn: aStream level: 1 generator: aCodeGen.
	aStream nextPutAll: '}'; cr! !

!TMethod methodsFor: 'C code generation' stamp: 'jmv 3/24/2009 15:02'!
emitCCommentOn: aStream
	"Emit the transferred Smalltalk comments as C comments."

	comment ifNotNil: [
		aStream cr; cr.
		1 to: comment size do: [:index | 
			aStream 
				nextPutAll: '/*'; tab;
				nextPutAll: (comment at: index);
				nextPutAll: ' */';
				cr]]! !


!TParseNode methodsFor: 'emit comments' stamp: 'jmv 3/24/2009 15:03'!
comment: aComment

	comment _ aComment! !

!TParseNode methodsFor: 'emit comments' stamp: 'jmv 3/24/2009 15:03'!
emitCCommentOn: aStream level: level
	"Emit the transferred Smalltalk comments as C comments."

	comment ifNotNil: [
		comment isString ifTrue: [ ^self ].	"safety catch"
		aStream cr.
		1 to: comment size do: [ :index | 
			aStream 
				tab: level;
				nextPutAll: '/* ';
				nextPutAll: (comment at: index);
				nextPutAll: ' */';
				cr].
		aStream cr]! !


!TStmtListNode methodsFor: 'as yet unclassified' stamp: 'jmv 3/24/2009 15:03'!
emitCCodeOn: aStream level: level generator: aCodeGen

	statements do: [:s |
		s emitCCommentOn: aStream level: level.
		aStream tab: level.
		s emitCCodeOn: aStream level: level generator: aCodeGen.
		((self endsWithCloseBracket: aStream) or: [s isComment])
			ifFalse: [ aStream nextPut: $; ].
		aStream cr ]! !


!ThirtyTwoBitRegister methodsFor: 'accessing' stamp: 'jmv 3/24/2009 14:53'!
byte1: b1 byte2: b2 byte3: b3 byte4: b4

	hi _ (b1 bitShift: 8) + b2.
	low _ (b3 bitShift: 8) + b4! !


!ThirtyTwoBitRegister class methodsFor: 'instance creation' stamp: 'jmv 3/24/2009 14:55'!
byte1: hi1 byte2: hi2 byte3: low1 byte4: low2

	^ self new byte1: hi1 byte2: hi2 byte3: low1 byte4: low2! !

!ThirtyTwoBitRegister class methodsFor: 'instance creation' stamp: 'jmv 3/24/2009 14:54'!
loadFrom: aByteArray at: index

	^ self new loadFrom: aByteArray at: index! !


!ThirtyTwoBitRegister class reorganize!
('instance creation' byte1:byte2:byte3:byte4: loadFrom:at: new)
!

SortedCollection removeSelector: #should:precede:!
SortedCollection removeSelector: #sortTopologically!
Form initialize!
FileStream initialize!
FileContentsBrowser initialize!
Collection removeSelector: #topologicallySortedUsing:!
ChangeList initialize!
Smalltalk removeClassNamed: #ExternalStructureInspector!
