@@ -168,11 +168,7 @@ producesNode (Undefined T_NodeSet{}) = True
168168producesNode _ = False
169169
170170asPatternDataflow :: IR. Reg -> BPat -> CG ()
171- asPatternDataflow r asPat@ (AsPat _ asVal) = case asVal of
172- Unit -> pure ()
173- Lit {} -> pure ()
174- Var v -> addReg v r
175- ConstTagNode tag args -> do
171+ asPatternDataflow r asPat@ (AsPat tag args _) = do
176172 irTag <- getTag tag
177173 bindInstructions <- forM (zip [1 .. ] args) $ \ (idx, arg) -> do
178174 argReg <- newReg
@@ -187,7 +183,6 @@ asPatternDataflow r asPat@(AsPat _ asVal) = case asVal of
187183 , srcReg = r
188184 , instructions = concat bindInstructions
189185 }
190- valPat -> error $ " unsupported @pattern: " ++ show (PP asPat)
191186asPatternDataflow _ pat = error $ " not @pattern: " ++ show (PP pat)
192187
193188{- NOTE: para is needed to specify the order of evalution of the lhs and rhs on binds.
@@ -227,17 +222,10 @@ codeGen e = flip evalState emptyCGState $ para folder e >> mkCByProgramM where
227222 cgRhs
228223
229224 -- NOTE: @patterns
230- EBindF (lhs, cgLhs) asPat@ (AsPat var valPat ) (_, cgRhs) -> do
225+ EBindF (lhs, cgLhs) asPat@ (AsPat tag args var ) (_, cgRhs) -> do
231226 lhsRes <- cgLhs
232227 case lhsRes of
233- Z -> do
234- r <- newReg
235- emit IR. Set {dstReg = r, constant = IR. CSimpleType unitType}
236- addReg var r
237- case valPat of
238- Unit -> pure ()
239- Var inner -> addReg inner r
240- _ -> error $ " pattern mismatch at CreatedBy bind codegen, expected Unit got " ++ show (PP valPat)
228+ Z -> error $ " pattern mismatch at CreatedBy bind codegen, expected Unit got " ++ show (PP $ ConstTagNode tag args)
241229 R r -> do
242230 case lhs of
243231 SReturn val | producesNode val -> do
0 commit comments