[Vm-dev] VM Maker: VMMaker.oscog-eem.1079.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Feb 24 21:08:11 UTC 2015
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1079.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1079
Author: eem
Time: 24 February 2015, 1:06:45.228 pm
UUID: fdd342f3-6d47-4bbe-be50-86e2865b8b3b
Ancestors: VMMaker.oscog-eem.1078
Avoid casting nil to pointers
=============== Diff against VMMaker.oscog-eem.1078 ===============
Item was added:
+ ----- Method: CCodeGenerator>>variableOfType:acceptsValue:ofType: (in category 'inlining') -----
+ variableOfType: variableType acceptsValue: exprNode ofType: expressionType
+ "Simple type checking for assignment/return values"
+
+ ^variableType isNil "means as yet untyped, hence can adapt"
+ or: [expressionType isNil "means we don't know. Potentially dangerous to say yes, but Slang is traditionally lax :("
+ or: [variableType = expressionType
+ or: [variableType notNil
+ and: [(variableType includes: $*)
+ ifTrue:
+ [(exprNode isVariable and: [exprNode name = 'nil'])
+ or: [expressionType last = $*
+ and: [(self isVoidPointer: variableType)
+ or: [self isVoidPointer: expressionType]]]]
+ ifFalse: "Require a cast if assigning integral with floating-point but not the other way around"
+ [((self isIntegralCType: variableType)
+ and: [(self isIntegralCType: expressionType)
+ and: [(self sizeOfIntegralCType: variableType) >= (self sizeOfIntegralCType: expressionType)]])
+ or: [(self isFloatingPointCType: variableType)
+ and: [(self isFloatingPointCType: expressionType)
+ or: [self isIntegralCType: expressionType]]]]]]]]!
Item was removed:
- ----- Method: CCodeGenerator>>variableOfType:acceptsValueOfType: (in category 'inlining') -----
- variableOfType: variableType acceptsValueOfType: expressionType
- "Simple type checking for assignment/return values"
-
- ^variableType isNil "means as yet untyped, hence can adapt"
- or: [expressionType isNil "means we don't know. Potentially dangerous to say yes, but Slang is traditionally lax :("
- or: [variableType = expressionType
- or: [variableType notNil
- and: [(variableType includes: $*)
- ifTrue:
- [expressionType last = $*
- and: [(self isVoidPointer: variableType)
- or: [self isVoidPointer: expressionType]]]
- ifFalse: "Require a cast if assigning integral with floating-point but not the other way around"
- [((self isIntegralCType: variableType)
- and: [(self isIntegralCType: expressionType)
- and: [(self sizeOfIntegralCType: variableType) >= (self sizeOfIntegralCType: expressionType)]])
- or: [(self isFloatingPointCType: variableType)
- and: [(self isFloatingPointCType: expressionType)
- or: [self isIntegralCType: expressionType]]]]]]]]!
Item was changed:
----- Method: TMethod>>node:typeCompatibleWith:inliningInto:in: (in category 'inlining') -----
node: exprNode typeCompatibleWith: argName inliningInto: inlineSelector in: aCodeGen
"Answer either exprNode or, iff argName is typed and exprNode is untyped, a cast of exprNode to the type of argName."
| formalType actualType |
^((exprNode isSend or: [exprNode isVariable])
and: [(formalType := self typeFor: argName in: aCodeGen) notNil
and: [(actualType := aCodeGen typeFor: exprNode in: self) isNil
+ or: [(aCodeGen variableOfType: formalType acceptsValue: exprNode ofType: actualType) not]]])
- or: [(aCodeGen variableOfType: formalType acceptsValueOfType: actualType) not]]])
ifTrue: [aCodeGen nodeToCast: exprNode to: formalType]
ifFalse:
[((exprNode isSend or: [exprNode isVariable])
and: [(aCodeGen
variableOfType: (aCodeGen typeFor: exprNode in: self)
+ acceptsValue: exprNode
+ ofType: (self typeFor: argName in: aCodeGen)) not]) ifTrue:
- acceptsValueOfType: (self typeFor: argName in: aCodeGen)) not]) ifTrue:
[aCodeGen logger
nextPutAll:
'type mismatch for formal ', argName, ' and actual ', exprNode asString,
' when inlining ', inlineSelector, ' in ', selector, '. Use a cast.';
cr; flush].
exprNode]!
More information about the Vm-dev
mailing list