Skip to content

Commit d260d73

Browse files
committed
improvement: utilizing self-ref awerness
1 parent 90c3807 commit d260d73

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

compiler/src/IR2Raw.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,25 @@ getVal va = do
205205
tell [AssignRaw rVal (ProjectLVal va FieldValue)]
206206
return rVal
207207

208+
-- | Special case projection for self-references
209+
projectLVal VarFunSelfRef FieldTypLev = ProjectState MonPC
210+
projectLVal VarFunSelfRef FieldValLev = ProjectState MonPC
211+
projectLVal va field = ProjectLVal va field
212+
208213
-- | Generate instructions assigning the value label of the given runtime LVal
209214
-- to a new Raw variable.
210215
getValLbl :: VarAccess -> TM RawVar
211216
getValLbl va = do
212217
rValLbl <- freshRawVarWith "_vlbl_"
213-
tell [AssignRaw rValLbl (ProjectLVal va FieldValLev)]
218+
tell [AssignRaw rValLbl (projectLVal va FieldValLev)]
214219
return rValLbl
215220

216221
-- | Generate instructions assigning the type label of the given runtime LVal
217222
-- to a new Raw variable.
218223
getTyLbl :: VarAccess -> TM RawVar
219224
getTyLbl va = do
220-
rTyLbl <- freshRawVarWith "_tlbl_"
221-
tell [AssignRaw rTyLbl (ProjectLVal va FieldTypLev)]
225+
rTyLbl <- freshRawVarWith "_tlbl_"
226+
tell [AssignRaw rTyLbl (projectLVal va FieldTypLev)]
222227
return rTyLbl
223228

224229
-- | Generate instructions assigning the current PC label to a new Raw variable.

compiler/src/RawOpt.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ guessType = \case
243243
-- Revision 2023-08: Added missing cases
244244
ProjField _ _ -> Nothing
245245
ProjIdx _ _ -> Nothing
246+
ProjectLVal VarFunSelfRef FieldValue -> Just RawFunction
246247
ProjectLVal _ FieldValLev -> Just RawLevel
247248
ProjectLVal _ FieldTypLev -> Just RawLevel
248249
ProjectLVal _ FieldValue -> Nothing

0 commit comments

Comments
 (0)