@@ -106,9 +106,9 @@ literals = mkPattern' match'
106 , Just op <- renderOp fn
106 , Just op <- renderOp fn
107 , Just t <- unboxType dict
107 , Just t <- unboxType dict
108 = mconcat <$> sequence
108 = mconcat <$> sequence
109− [ return $ emit $ unbox t x
109+ [ return $ emit $ unbox' t x
110 , return $ emit op
110 , return $ emit op
111− , return $ emit $ unbox t y
111+ , return $ emit $ unbox' t y
113 match (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [n])
113 match (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [n])
114 | fnMod == dictMod
114 | fnMod == dictMod
@@ -117,7 +117,7 @@ literals = mkPattern' match'
117 , Just t <- unboxType dict
117 , Just t <- unboxType dict
118 = mconcat <$> sequence
118 = mconcat <$> sequence
119 [ return $ emit "-"
119 [ return $ emit "-"
120− , return $ emit $ unbox t n
120+ , return $ emit $ unbox' t n
122 match (App _ val args) = mconcat <$> sequence
122 match (App _ val args) = mconcat <$> sequence
123 [ prettyPrintCpp' val
123 [ prettyPrintCpp' val
@@ -179,18 +179,6 @@ literals = mkPattern' match'
179 , prettyPrintCpp' prop
179 , prettyPrintCpp' prop
180 , return $ emit "()"
180 , return $ emit "()"
182− match (Indexer _ (ArrayLiteral _ [name]) val) = mconcat <$> sequence
183− [ prettyPrintCpp' val
185− , prettyPrintCpp' name
186− , return $ emit "()"
188− match (Indexer _ (NumericLiteral _ (Left index)) val) = mconcat <$> sequence
189− [ prettyPrintCpp' val
191− , return . emit . T.pack $ show index
194 match (Indexer _ prop val) = mconcat <$> sequence
182 match (Indexer _ prop val) = mconcat <$> sequence
195 [ prettyPrintCpp' val
183 [ prettyPrintCpp' val
196 , return $ emit "["
184 , return $ emit "["
@@ -198,7 +186,7 @@ literals = mkPattern' match'
198 , return $ emit "]"
186 , return $ emit "]"
200 match (InstanceOf _ val ty) = mconcat <$> sequence
188 match (InstanceOf _ val ty) = mconcat <$> sequence
201− [ return . emit $ unbox dictType val
189+ [ return . emit $ unbox' dictType val
202 , return $ emit ".contains("
190 , return $ emit ".contains("
203 , prettyPrintCpp' ty
191 , prettyPrintCpp' ty
204 , return $ emit ")"
192 , return $ emit ")"
@@ -225,21 +213,21 @@ literals = mkPattern' match'
226 match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing True)) thens elses) = mconcat <$> sequence
214 match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing True)) thens elses) = mconcat <$> sequence
227 [ return $ emit "if ("
215 [ return $ emit "if ("
228− , return $ emit $ unbox "bool" cond
216+ , return $ emit $ unbox' "bool" cond
229 , return $ emit ") "
217 , return $ emit ") "
230 , prettyPrintCpp' thens
218 , prettyPrintCpp' thens
231 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
219 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
233 match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing False)) thens elses) = mconcat <$> sequence
221 match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing False)) thens elses) = mconcat <$> sequence
234 [ return $ emit "if (!("
222 [ return $ emit "if (!("
235− , return $ emit $ unbox "bool" cond
223+ , return $ emit $ unbox' "bool" cond
236 , return $ emit ")) "
224 , return $ emit ")) "
237 , prettyPrintCpp' thens
225 , prettyPrintCpp' thens
238 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
226 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
240 match (IfElse _ (Binary _ EqualTo x y@(NumericLiteral _ n)) thens elses) = mconcat <$> sequence
228 match (IfElse _ (Binary _ EqualTo x y@(NumericLiteral _ n)) thens elses) = mconcat <$> sequence
241 [ return $ emit "if ("
229 [ return $ emit "if ("
242− , return $ emit $ unbox t x
230+ , return $ emit $ unbox' t x
243 , return $ emit $ " == "
231 , return $ emit $ " == "
244 , prettyPrintCpp' y
232 , prettyPrintCpp' y
245 , return $ emit ") "
233 , return $ emit ") "
@@ -251,7 +239,7 @@ literals = mkPattern' match'
251 | Right _ <- n = float
239 | Right _ <- n = float
252 match (IfElse _ (Binary _ EqualTo a b@StringLiteral{}) thens elses) = mconcat <$> sequence
240 match (IfElse _ (Binary _ EqualTo a b@StringLiteral{}) thens elses) = mconcat <$> sequence
253 [ return $ emit "if ("
241 [ return $ emit "if ("
254− , return $ emit $ unbox string a
242+ , return $ emit $ unbox' string a
255 , return $ emit $ " == "
243 , return $ emit $ " == "
256 , prettyPrintCpp' b
244 , prettyPrintCpp' b
257 , return $ emit ") "
245 , return $ emit ") "
@@ -412,11 +400,11 @@ stringLiteral pss | Just s <- decodeString pss =
412 encodeChar c = T.singleton $ c
400 encodeChar c = T.singleton $ c
413stringLiteral _ = "\"\\uFFFD\""
401stringLiteral _ = "\"\\uFFFD\""
415−unbox :: Text -> AST -> Text
403+unbox' :: Text -> AST -> Text
416−unbox _ v@(NumericLiteral{}) = prettyPrintCpp1 v
404+unbox' _ v@(NumericLiteral{}) = prettyPrintCpp1 v
417−unbox _ v@(BooleanLiteral{}) = prettyPrintCpp1 v
405+unbox' _ v@(BooleanLiteral{}) = prettyPrintCpp1 v
418−unbox _ v@(StringLiteral{}) = prettyPrintCpp1 v
406+unbox' _ v@(StringLiteral{}) = prettyPrintCpp1 v
419−unbox t v = "unbox<" <> t <> ">(" <> prettyPrintCpp1 v <> ")"
407+unbox' t v = unbox t <> "(" <> prettyPrintCpp1 v <> ")"
421unboxType :: Text -> Maybe Text
409unboxType :: Text -> Maybe Text
422unboxType t
410unboxType t
@@ -490,24 +478,6 @@ implFooterSource mn foreigns =
497−arrayType = "array_t"
511varDecl :: Text
481varDecl :: Text
512varDecl = "const boxed&"
482varDecl = "const boxed&"