Skip to content

Commit

Permalink
Implement datatype-monomorphization plumbing
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Nov 12, 2024
1 parent e2dfe2d commit 4e9c62d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/Refinements/FApp.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ FApp >> hash [
^s hash
]

{ #category : #hotel }
FApp >> monomorphicDeclIn: γ [
"Like fappSmtSort but don't go all the way to Z3.
Do we want to keep this layer?"
(s isKindOf: FTC) ifFalse: [ self error ].
s isSetCon ifTrue: [ self error ].
s isMapCon ifTrue: [ self shouldBeImplemented ].
s isBitVec ifTrue: [ self shouldBeImplemented ].

^(s maybeDataIn: γ)
ifNil: [ self error]
ifNotNil: [ :d |
| instance ct_ts ct ts |
ct_ts := self unFApp. ct := ct_ts first. ts := ct_ts allButFirst.
instance := d apply: (ts collect: [ :each | each z3sort: γ ]).
instance monomorphicDeclIn: γ

]
]

{ #category : #printing }
FApp >> printOn: aStream [
aStream nextPutAll: '(FApp '.
Expand Down
4 changes: 3 additions & 1 deletion src/Refinements/FTC.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ FTC >> fappSmtSort: ts originalFApp: anFApp in: γ [
^(self maybeDataIn: γ)
ifNil: [ (FObj symbol: typeConstructor symbol) fappSmtSort: ts originalFApp: anFApp in: γ ]
ifNotNil: [ :d |
| instance |
d ddVars = ts size ifFalse: [ self error ].
d instantiateZ3Sort: (ts collect: [ :t | t z3sort: γ ])
instance := d apply: (ts collect: [ :t | t z3sort: γ ]).
instance z3sort: γ
]
]

Expand Down
16 changes: 14 additions & 2 deletions src/Refinements/TC.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ instance Eq FTycon where
^symbol = rhs symbol
]

{ #category : #'as yet unclassified' }
{ #category : #hotel }
TC >> apply: ts [
| monoSymbol |
ts isEmpty ifTrue: [ ^self ].
monoSymbol :=
'(',
symbol,
(ts inject: '' into: [ :soFar :thisArgType | ' ', thisArgType printString ]),
')'.
^TC symbol: monoSymbol
]

{ #category : #hotel }
TC >> fTyconSort [
^FTC new: self
]
Expand All @@ -27,7 +39,7 @@ TC >> hash [
^symbol hash
]

{ #category : #'as yet unclassified' }
{ #category : #hotel }
TC >> isListTC [
^symbol isListConName
]
Expand Down
5 changes: 5 additions & 0 deletions src/Refinements/Z3Sort.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ Cf. Types/Sorts.hs

]

{ #category : #'*Refinements' }
Z3Sort >> monomorphicDeclIn: _ [
^self
]

{ #category : #'*Refinements' }
Z3Sort >> monomorphicSortName [
^self printString
Expand Down

0 comments on commit 4e9c62d

Please sign in to comment.