Type resolving reintroduced again.
During resolution part, all CUnresolvedNode are replaced by corresponding typedef nodes.
--- a/Cface__CConstNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CConstNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -119,6 +119,12 @@
"Created: / 04-07-2008 / 09:28:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
+isCStructredNode
+ ^ type isCStructuredNode
+
+ "Created: / 06-07-2015 / 23:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
isForeign
^type isForeign
@@ -137,6 +143,12 @@
"Created: / 02-11-2007 / 10:41:30 / haja"
"Modified: / 10-02-2008 / 10:44:45 / janfrog"
+!
+
+isUnresolved
+ ^ type isUnresolved
+
+ "Created: / 06-07-2015 / 22:41:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CConstNode class methodsFor:'documentation'!
--- a/Cface__CModifierNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CModifierNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -84,6 +84,13 @@
"stub code automatically generated - please change if required"
^ aVisitor visitCModifierNode:self
+!
+
+isUnresolved
+ self assert: type isUnresolved not.
+ ^ false
+
+ "Created: / 06-07-2015 / 22:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CModifierNode class methodsFor:'documentation'!
@@ -95,3 +102,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/Cface__CNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -197,16 +197,16 @@
"Created: / 17-02-2008 / 21:52:13 / janfrog"
!
+isCUnresolvedTypeNode
+ ^ false
+!
+
isCUnsignedNode
^ false
"Created: / 17-02-2008 / 21:52:38 / janfrog"
!
-isCUserDefinedTypeNode
- ^ false
-!
-
isCVoidNode
^ false
@@ -242,3 +242,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/Cface__CPointerNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CPointerNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -101,6 +101,18 @@
isCPointerNode
^ true
+!
+
+isCPointerToCStructure
+ ^ type isCStructuredNode
+
+ "Created: / 06-07-2015 / 23:01:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isCPointerToChar
+ ^ type isCCharNode
+
+ "Created: / 06-07-2015 / 23:01:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CPointerNode methodsFor:'visiting'!
--- a/Cface__CTypeNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CTypeNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -59,14 +59,6 @@
"Created: / 09-09-2008 / 21:33:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
-!CTypeNode methodsFor:'converting'!
-
-resolved
- ^ self
-
- "Created: / 17-02-2008 / 17:56:03 / janfrog"
-! !
-
!CTypeNode methodsFor:'queries'!
shouldBeIgnored
@@ -103,6 +95,12 @@
^cName isNil
"Created: / 04-07-2008 / 11:44:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+isUnresolved
+ "return false here; to be redefined in subclass(es)"
+
+ ^ false
! !
!CTypeNode methodsFor:'visiting'!
@@ -125,3 +123,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/Cface__CTypedefNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CTypedefNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -46,10 +46,13 @@
!
ffiTypeSymbol
-
- ^type ffiTypeSymbol
+ type isCPointerToCStructure ifTrue:[
+ ^ self smalltalkClassName ? #pointer
+ ].
+ ^ type ffiTypeSymbol
"Created: / 03-07-2008 / 22:40:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 06-07-2015 / 23:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
type
--- a/Cface__CUnresolvedTypeNode.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__CUnresolvedTypeNode.st Mon Jul 06 23:08:04 2015 +0100
@@ -73,42 +73,17 @@
!CUnresolvedTypeNode methodsFor:'accessing'!
-cByteSize
+ffiPointerTypeSymbol
+ self shouldNotImplement
- ^type cByteSize
-
- "Created: / 09-07-2008 / 19:39:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Created: / 06-07-2015 / 22:50:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
ffiTypeSymbol
- "Superclass Cface::CTypeNode says that I am responsible to implement this method"
-
- ^type ffiTypeSymbol
+ self shouldNotImplement
"Created: / 03-07-2008 / 22:55:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-type
- ^ type
-
- "Created: / 12-02-2008 / 23:21:13 / janfrog"
-!
-
-type:something
- type := something.
-
- "Created: / 12-02-2008 / 23:21:13 / janfrog"
-! !
-
-!CUnresolvedTypeNode methodsFor:'converting'!
-
-resolved
- type
- ifNil:[ self error:'User defined type ' , cName , ' not yet resolved' ].
- ^ type
-
- "Created: / 17-02-2008 / 17:56:03 / janfrog"
- "Modified: / 09-07-2008 / 19:51:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 06-07-2015 / 22:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CUnresolvedTypeNode methodsFor:'printing'!
@@ -151,32 +126,10 @@
!CUnresolvedTypeNode methodsFor:'testing'!
-isCEnumNode
- ^ type isCEnumNode
-
- "Created: / 06-07-2015 / 17:37:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isCPointerToCStructure
- ^type isCPointerToCStructure
-
- "Created: / 06-07-2015 / 17:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+isUnresolved
+ ^ true
-isCStructNode
- ^ type isCStructNode
-
- "Created: / 06-07-2015 / 17:37:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isCUnionNode
- ^ type isCUnionNode
-
- "Created: / 06-07-2015 / 17:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isCUserDefinedTypeNode
- ^ true
+ "Created: / 06-07-2015 / 22:31:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CUnresolvedTypeNode methodsFor:'visiting'!
--- a/Cface__TypeCollector.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__TypeCollector.st Mon Jul 06 23:08:04 2015 +0100
@@ -105,13 +105,14 @@
oldNode := typeMap at: node cName ifAbsent:nil.
oldNode
ifNil:
- [typeMap at: node cName put: node type]
+ [typeMap at: node cName put: node]
ifNotNil:
[node isForeign ifFalse:
- [typeMap at: node cName put: node type]]
+ [typeMap at: node cName put: node]]
"Created: / 12-02-2008 / 22:55:53 / janfrog"
"Modified: / 10-07-2008 / 20:10:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 06-07-2015 / 22:52:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitCUnionNode: anObject
@@ -131,3 +132,4 @@
version_SVN
^ '$Id$'
! !
+
--- a/Cface__TypeResolver.st Mon Jul 06 22:28:52 2015 +0100
+++ b/Cface__TypeResolver.st Mon Jul 06 23:08:04 2015 +0100
@@ -24,6 +24,19 @@
"Created: / 12-02-2008 / 23:44:35 / janfrog"
! !
+!TypeResolver methodsFor:'private'!
+
+resolve: node
+ node type isUnresolved ifTrue:[
+ | type |
+
+ type := typeMap at: node type cName ifAbsent:[ CPointerNode new type: CIntNode new ].
+ node type: type
+ ].
+
+ "Created: / 06-07-2015 / 22:33:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!TypeResolver methodsFor:'processing'!
process: aCNode
@@ -38,37 +51,92 @@
!TypeResolver methodsFor:'visiting'!
-visitCTypedefNode: anObject
+visitCArgumentNode:anObject
+ super visitCArgumentNode: anObject.
+ self resolve: anObject.
+
+ "Created: / 06-07-2015 / 22:33:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
- anObject type isCUserDefinedTypeNode ifTrue:[
- | realType |
+visitCArrayNode:anObject
+ super visitCArrayNode:anObject.
+ self resolve: anObject
+
+ "Created: / 06-07-2015 / 22:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
- realType := typeMap at: anObject type cName ifAbsent:[nil].
- realType notNil ifTrue:[
- self visit: realType.
- anObject type: realType.
- ].
- ]
+visitCConstNode:anObject
+ self visit: anObject type.
+ self resolve: anObject
+
+ "Created: / 06-07-2015 / 22:38:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
- "Created: / 05-09-2012 / 11:37:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+visitCFunctionNode:anObject
+ super visitCFunctionNode:anObject.
+ anObject return isUnresolved ifTrue:[
+ | type |
+
+ type := typeMap at: anObject return cName ifAbsent:[ CPointerNode new type: CIntNode new ].
+ anObject return: type
+ ].
+
+ "Created: / 06-07-2015 / 22:49:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-visitCUnresolvedTypeNode:anObject
- "/thisContext isRecursive ifTrue:[^self].
-
- anObject type isNil ifTrue:[
+visitCFunctionTypeNode:anObject
+ super visitCFunctionTypeNode:anObject.
+ anObject return isUnresolved ifTrue:[
| type |
- type := (typeMap at:anObject cName ifAbsent:[ CPointerNode new type:CVoidNode new ]).
- self visit:type.
- anObject type:type
- ]
+ type := typeMap at: anObject return cName ifAbsent:[ CPointerNode new type: CIntNode new ].
+ anObject return: type
+ ].
+
+ "Created: / 06-07-2015 / 22:48:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+visitCLongNode:anObject
+ self assert: anObject type isUnresolved not.
+ super visitCLongNode: anObject
+
+ "Created: / 06-07-2015 / 22:37:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+visitCPointerNode:anObject
+ super visitCPointerNode:anObject.
+ self resolve: anObject
+
+ "Created: / 06-07-2015 / 22:34:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
- "Created: / 12-02-2008 / 23:45:17 / janfrog"
- "Modified: / 17-02-2008 / 18:30:56 / janfrog"
- "Modified: / 09-07-2008 / 20:53:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
- "Modified: / 06-07-2015 / 08:01:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 06-07-2015 / 22:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+visitCShortNode:anObject
+ self assert: anObject type isUnresolved not.
+ super visitCShortNode:anObject.
+
+ "Created: / 06-07-2015 / 22:37:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+visitCStructFieldNode:anObject
+ super visitCStructFieldNode:anObject.
+ self resolve: anObject
+
+ "Created: / 06-07-2015 / 22:39:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+visitCTypedefNode: anObject
+ super visitCTypedefNode: anObject.
+ self resolve: anObject.
+
+ "Created: / 05-09-2012 / 11:37:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 06-07-2015 / 22:46:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+visitCUnsignedNode:anObject
+ self assert: anObject type isUnresolved not.
+ super visitCUnsignedNode: anObject
+
+ "Created: / 06-07-2015 / 22:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TypeResolver class methodsFor:'documentation'!