[Vm-dev] VM Maker: VMMaker.oscog-eem.1746.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Mar 28 21:22:20 UTC 2016


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1746.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.1746
Author: eem
Time: 1 January 1970, 2:20:29.877909 pm
UUID: 9e4a49eb-8ebe-486d-b6f0-430100efa288
Ancestors: VMMaker.oscog-nice.1745

Modify generateAbs:on:indent: to generate fabsf for float.  Write the case statement a little more declaratively/extensibly.

=============== Diff against VMMaker.oscog-nice.1745 ===============

Item was changed:
  ----- Method: CCodeGenerator>>generateAbs:on:indent: (in category 'C translation') -----
  generateAbs: msgNode on: aStream indent: level
  	"Generate the C code for this message onto the given stream."
  
  	| type strippedType absFun |
  	type := self typeFor: msgNode receiver in: currentMethod.
  	strippedType := (type beginsWith: 'unsigned ')
  		ifTrue: [type allButFirst: 'unsigned ' size]
  		ifFalse: [(type beginsWith: 'u')
  			ifTrue: [type allButFirst: 1]
  			ifFalse: [type]].
+ 	absFun :=
+ 		(#(	('long long' llabs) ('__int64' #llabs) ('int64_t' #llabs)
+ 			(sqInt SQABS)
+ 			(sqLong SQLABS)
+ 			(double fabs)
+ 			(float fabsf))
+ 				detect: [:tuple| strippedType beginsWith: tuple first]
+ 				ifNone: [])
+ 			ifNotNil: [:tuple| tuple last]
+ 			ifNil: [#abs].
- 	absFun := (#('long long' '__int64' 'int64_t') anySatisfy: [:t| strippedType beginsWith: t]) ifTrue: [#llabs]
- 		ifFalse: [(strippedType beginsWith: #sqInt) ifTrue: [#SQABS]
- 		ifFalse: [(strippedType beginsWith: #sqLong) ifTrue: [#SQLABS]
- 		ifFalse: [(#('float' 'double') anySatisfy: [:t| strippedType beginsWith: t]) ifTrue: [#fabs]
- 		ifFalse: [#abs]]]].
  	
  	aStream nextPutAll: absFun.
  	aStream nextPut: $(.
  	self emitCExpression: msgNode receiver on: aStream.
+ 	aStream nextPut: $)!
- 	aStream nextPut: $).!



More information about the Vm-dev mailing list