Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Prog>>vcgen #394

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions src/Refinements/HornQuery.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Cf. Info.hs
{ #category : #'instance creation' }
HornQuery class >> fromThings: things [
| q |
q := self new.
q := self basicNew.
things do: [ :x | x addToQuery: q ].
^q
]
Expand Down Expand Up @@ -101,10 +101,23 @@ HornQuery class >> hornVariables: ks smalltalkBlock: aBlockClosure [
^self fromThings: {cstr}, ks
]

{ #category : #'as yet unclassified' }
HornQuery >> addPapp: j [
(HCon papp: j) addToQuery: self.
(Qualifier pappQual: j) addToQuery: self
{ #category : #'instance creation' }
HornQuery class >> mkQuery_qs: qs ks: ks cstr: c syms: syms defs: defs ddecls: ddecls [
"
mkQuery :: [F.Qualifier]
-> [H.Var a]
-> H.Cstr a
-> M.HashMap F.Symbol F.Sort
-> [F.Equation]
-> [F.DataDecl]
-> H.Query a
"
^self basicNew qs: qs ks: ks cstr: c syms: syms defs: defs ddecls: ddecls
]

{ #category : #'instance creation' }
HornQuery class >> new [
self shouldNotImplement
]

{ #category : #accessing }
Expand Down Expand Up @@ -288,6 +301,22 @@ HornQuery >> qMats: anObject [
qMats := anObject
]

{ #category : #'private - initialization' }
HornQuery >> qs: qs ks: ks cstr: c syms: syms defs: defs ddecls: ddecls [
qualifiers := qs.
vars := ks.
qCstr := {c}.
qCon := syms.
qDis := Dictionary new.
qEqns := defs.
qMats := #().
qData := ddecls.

defs isEmpty ifFalse: [ HOpt rewrite addToQuery: self ].

^self
]

{ #category : #accessing }
HornQuery >> qualifiers [
"qualifiers over which to solve cstrs"
Expand All @@ -304,7 +333,7 @@ HornQuery >> solve [
solve
]

{ #category : #private }
{ #category : #accessing }
HornQuery >> vars [
"κ-vars, with parameter-sorts"
vars isNil ifTrue: [ vars := OrderedCollection new ].
Expand Down
2 changes: 1 addition & 1 deletion src/SpriteLang/CGInfo.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CGInfo >> addReflectVar: f rtype: t xts: xts outputSort: ot expr: e [
expr: e
sort: ot.
self cgiDefs add: fDef.
self cgiConsts add: (HCon symbol: f sort: t rtypeSort)
self cgiConsts add: f -> t rtypeSort
]

{ #category : #API }
Expand Down
5 changes: 5 additions & 0 deletions src/SpriteLang/HCstr.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ mkHead :: F.SrcSpan -> H.Pred -> SrcCstr
^CstrAnd of: (smashed collect: #cHead)
]

{ #category : #'*SpriteLang' }
HCstr >> strengthenInv: aΓContext [
^self
]

{ #category : #'*SpriteLang' }
HCstr class >> subPs: coll1 _: coll2 [
| p1 p1s p2 p2s |
Expand Down
34 changes: 19 additions & 15 deletions src/SpriteLang/Prog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,26 @@ Prog >> solve [

{ #category : #verification }
Prog >> vcgen [
| expr′ env expr′′ c_cgi c cgi query |
| expr′ env eL ps pqs c_cgi c cgi rfls syms c′ query |
expr′ := expr uniq2.
env := ΓContext empEnv: meas typs: data.
expr′′ := expr′ elaborate: env.
c_cgi := [ expr′′ check: env rtype: TInt instance bTrue ] runCG.
c := c_cgi key. cgi := c_cgi value.
query := HornQuery new.
c addToQuery: query.
cgi cgiKVars do: [ :kVar | kVar addToQuery: query ].
quals do: [ :q | q addToQuery: query ].
query qCon: (Dictionary newFromAssociations: meas).
#(1 2 3) do: [ :j | query addPapp: j ].
cgi cgiDefs do: [ :equ | equ addToQuery: query ].
cgi cgiConsts do: [ :con | con addToQuery: query ].
cgi cgiDefs isEmpty ifFalse: [
HOpt rewrite addToQuery: query
eL := expr′ elaborate: env.
ps := #(1 2 3) collect: [ :j |
| hcon |
hcon := HCon papp: j.
hcon symbol -> hcon sort
].
^query
pqs := #(1 2 3) collect: [ :j | Qualifier pappQual: j ].
c_cgi := [ eL check: env rtype: TInt instance bTrue ] runCG.
c := c_cgi key. cgi := c_cgi value.
rfls := cgi cgiConsts.
syms := Dictionary newFromAssociations: ps, meas, rfls.
c′ := c strengthenInv: env.
^HornQuery
mkQuery_qs: quals, pqs
ks: cgi cgiKVars
cstr: "cI &" c′
syms: syms
defs: cgi cgiDefs
ddecls: #()
]
Loading