1
+ {-# LANGUAGE BlockArguments #-}
1
2
{-# LANGUAGE DuplicateRecordFields #-}
2
3
{-# LANGUAGE FlexibleContexts #-}
3
4
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -80,7 +81,7 @@ subBuilder (Builder s) = do
80
81
81
82
emit :: Assembly. Instruction -> Builder ()
82
83
emit instruction =
83
- modify $ \ s -> s {instructions = s. instructions Tsil. :> instruction}
84
+ modify \ s -> s {instructions = s. instructions Tsil. :> instruction}
84
85
85
86
tagBytes :: Num a => a
86
87
tagBytes = wordBytes
@@ -157,14 +158,14 @@ getFreeShadowStackSlot :: Builder (Int, Builder ())
157
158
getFreeShadowStackSlot = do
158
159
slot <- gets (. nextShadowStackSlot)
159
160
let newNextSlot = slot + 1
160
- modify $ \ s ->
161
+ modify \ s ->
161
162
s
162
163
{ nextShadowStackSlot = newNextSlot
163
164
, shadowStackSlotCount = max newNextSlot s. shadowStackSlotCount
164
165
}
165
166
pure
166
167
( slot
167
- , modify $ \ s ->
168
+ , modify \ s ->
168
169
s
169
170
{ nextShadowStackSlot =
170
171
if s. nextShadowStackSlot == newNextSlot
@@ -244,7 +245,7 @@ heapAllocate nameSuggestion constructorTag size = do
244
245
result <- extractValue nameSuggestion destinationOperand 0
245
246
heapPointer' <- extractValue " heap_pointer" destinationOperand 1
246
247
heapLimit' <- extractValue " heap_limit" destinationOperand 2
247
- modify $ \ s -> s {heapPointer = heapPointer', heapLimit = heapLimit'}
248
+ modify \ s -> s {heapPointer = heapPointer', heapLimit = heapLimit'}
248
249
pure result
249
250
250
251
extractHeapPointer :: Assembly. NameSuggestion -> Assembly. Operand -> Builder Assembly. Operand
@@ -286,7 +287,7 @@ switch returnType scrutinee branches defaultBranch = do
286
287
initialHeapPointer <- gets (. heapPointer)
287
288
initialHeapLimit <- gets (. heapLimit)
288
289
let wrapBranch branch = subBuilder $ do
289
- modify $ \ s ->
290
+ modify \ s ->
290
291
s
291
292
{ nextShadowStackSlot = initialNextShadowStackSlot
292
293
, heapPointer = initialHeapPointer
@@ -304,13 +305,13 @@ switch returnType scrutinee branches defaultBranch = do
304
305
)
305
306
306
307
((defaultReturn, defaultNextShadowStackSlot), defaultInstructions) <- wrapBranch defaultBranch
307
- branches' <- forM branches $ \ (i, branch) -> do
308
+ branches' <- forM branches \ (i, branch) -> do
308
309
((branchReturn, branchNextShadowStackSlot), branchInstructions) <- wrapBranch branch
309
310
pure ((i, Assembly. BasicBlock branchInstructions branchReturn), branchNextShadowStackSlot)
310
311
let branchNextShadowStackSlots = snd <$> branches'
311
312
when (any (/= defaultNextShadowStackSlot) branchNextShadowStackSlots) $
312
313
panic " ClosureConvertedToAssembly.switch: Shadow stack mismatch"
313
- modify $ \ s -> s {nextShadowStackSlot = defaultNextShadowStackSlot}
314
+ modify \ s -> s {nextShadowStackSlot = defaultNextShadowStackSlot}
314
315
case returnType of
315
316
Assembly. Void -> do
316
317
resultLocal <- freshLocal " heap_pointer_and_limit"
@@ -319,7 +320,7 @@ switch returnType scrutinee branches defaultBranch = do
319
320
emit $ Assembly. Switch (Assembly. Return (resultType, resultLocal)) scrutinee (fst <$> branches') $ Assembly. BasicBlock defaultInstructions defaultReturn
320
321
heapPointer <- extractValue " heap_pointer" resultOperand 0
321
322
heapLimit <- extractValue " heap_limit" resultOperand 1
322
- modify $ \ s -> s {heapPointer, heapLimit}
323
+ modify \ s -> s {heapPointer, heapLimit}
323
324
pure Assembly. Void
324
325
Assembly. Return (type_, nameSuggestion) -> do
325
326
resultLocal <- freshLocal $ nameSuggestion <> " _with_heap_pointer_and_limit"
@@ -329,15 +330,15 @@ switch returnType scrutinee branches defaultBranch = do
329
330
result <- extractValue nameSuggestion resultOperand 0
330
331
heapPointer <- extractValue " heap_pointer" resultOperand 1
331
332
heapLimit <- extractValue " heap_limit" resultOperand 2
332
- modify $ \ s -> s {heapPointer, heapLimit}
333
+ modify \ s -> s {heapPointer, heapLimit}
333
334
pure $ Assembly. Return result
334
335
335
336
-------------------------------------------------------------------------------
336
337
337
338
freshLocal :: Assembly. NameSuggestion -> Builder Assembly. Local
338
339
freshLocal nameSuggestion = do
339
340
fresh <- gets (. fresh)
340
- modify $ \ s -> s {fresh = fresh + 1 }
341
+ modify \ s -> s {fresh = fresh + 1 }
341
342
pure $ Assembly. Local fresh nameSuggestion
342
343
343
344
copy :: Assembly. Operand -> Operand -> Assembly. Operand -> Builder ()
@@ -366,7 +367,7 @@ callVoid global args = do
366
367
let resultStructOperand = Assembly. LocalOperand resultStruct
367
368
heapPointer' <- extractValue " heap_pointer" resultStructOperand 0
368
369
heapLimit' <- extractValue " heap_limit" resultStructOperand 1
369
- modify $ \ s ->
370
+ modify \ s ->
370
371
s
371
372
{ heapPointer = heapPointer'
372
373
, heapLimit = heapLimit'
@@ -394,7 +395,7 @@ callDirect nameSuggestion global args = do
394
395
result <- extractValue nameSuggestion resultStructOperand 0
395
396
heapPointer' <- extractValue " heap_pointer" resultStructOperand 1
396
397
heapLimit' <- extractValue " heap_limit" resultStructOperand 2
397
- modify $ \ s ->
398
+ modify \ s ->
398
399
s
399
400
{ heapPointer = heapPointer'
400
401
, heapLimit = heapLimit'
@@ -424,7 +425,7 @@ callInitFunction nameSuggestion global args = do
424
425
result <- extractValue nameSuggestion resultStructOperand 0
425
426
heapPointer' <- extractValue " heap_pointer" resultStructOperand 1
426
427
heapLimit' <- extractValue " heap_limit" resultStructOperand 2
427
- modify $ \ s ->
428
+ modify \ s ->
428
429
s
429
430
{ heapPointer = heapPointer'
430
431
, heapLimit = heapLimit'
@@ -630,7 +631,7 @@ withFunctionDefinitionParameters m = do
630
631
heapPointer <- gets (. heapPointer)
631
632
heapLimit <- gets (. heapLimit)
632
633
pure $
633
- mkDefinition $ \ returnType parameters (Assembly. BasicBlock instructions returnOperand) ->
634
+ mkDefinition \ returnType parameters (Assembly. BasicBlock instructions returnOperand) ->
634
635
Assembly. FunctionDefinition
635
636
( case returnType of
636
637
Assembly. Void -> Assembly. Return $ Assembly. Struct [Assembly. WordPointer , Assembly. WordPointer ]
@@ -677,11 +678,11 @@ generateGlobal env name representation term = do
677
678
pure $ Assembly. KnownConstantDefinition Assembly. Word knownConstant True
678
679
Nothing ->
679
680
case representation of
680
- Representation. Empty -> makeConstantDefinition Assembly. WordPointer $ \ globalPointer -> do
681
+ Representation. Empty -> makeConstantDefinition Assembly. WordPointer \ globalPointer -> do
681
682
(_, deallocateTerm) <- generateTypedTerm env term (Direct emptyTypeOperand) representation
682
683
sequence_ deallocateTerm
683
684
pure globalPointer
684
- Representation. Direct Representation. Doesn'tContainHeapPointers -> makeConstantDefinition Assembly. Word $ \ globalPointer -> do
685
+ Representation. Direct Representation. Doesn'tContainHeapPointers -> makeConstantDefinition Assembly. Word \ globalPointer -> do
685
686
(result, deallocateTerm) <- generateTypedTerm env term (Direct directTypeOperand) representation
686
687
directResult <- forceDirect result
687
688
sequence_ deallocateTerm
@@ -693,7 +694,7 @@ generateGlobal env name representation term = do
693
694
indirectCase containsHeapPointers
694
695
where
695
696
indirectCase containsHeapPointers = do
696
- makeConstantDefinition Assembly. WordPointer $ \ globalPointer -> do
697
+ makeConstantDefinition Assembly. WordPointer \ globalPointer -> do
697
698
(type_, _representation) <- typeOf env term
698
699
typeSize <- sizeOfType type_
699
700
globalPointer' <- globalAllocate " globals" globalPointer typeSize
@@ -1227,7 +1228,7 @@ boxedConstructorSize env con params args = do
1227
1228
tele <- fetch $ Query. ClosureConvertedConstructorType con
1228
1229
params' <- mapM (Evaluation. evaluate env) params
1229
1230
args' <- mapM (Evaluation. evaluate env) args
1230
- maybeResult <- Evaluation. applyTelescope env (Telescope. fromVoid tele) params' $ \ env' type_ -> do
1231
+ maybeResult <- Evaluation. applyTelescope env (Telescope. fromVoid tele) params' \ env' type_ -> do
1231
1232
type' <- Evaluation. evaluate env' type_
1232
1233
size <- ClosureConverted.Representation. compileBoxedConstructorFields env' type' args'
1233
1234
Evaluation. evaluate env' size
0 commit comments