@@ -52,13 +52,13 @@ literals = mkPattern' match'
52 match (BooleanLiteral _ False) = return $ emit "false"
52 match (BooleanLiteral _ False) = return $ emit "false"
53 -- match (ArrayLiteral _ []) = return $ emit "std::initializer_list<boxed>{}"
53 -- match (ArrayLiteral _ []) = return $ emit "std::initializer_list<boxed>{}"
54 match (ArrayLiteral _ xs) = mconcat <$> sequence
54 match (ArrayLiteral _ xs) = mconcat <$> sequence
55− [ return $ emit "as_array { "
55+ [ return $ emit "array_t{ {"
56 , intercalate (emit ", ") <$> forM xs prettyPrintCpp'
56 , intercalate (emit ", ") <$> forM xs prettyPrintCpp'
57− , return $ emit " }"
57+ , return $ emit "} }"
59 -- match (ObjectLiteral _ []) = return $ emit "std::initializer_list<std::pair<const string, boxed>>{}"
59 -- match (ObjectLiteral _ []) = return $ emit "std::initializer_list<std::pair<const string, boxed>>{}"
60 match (ObjectLiteral _ ps) = mconcat <$> sequence
60 match (ObjectLiteral _ ps) = mconcat <$> sequence
61− [ return $ emit "as_dict {\n"
61+ [ return $ emit "dict_t{ {\n"
62 , withIndent $ do
62 , withIndent $ do
63 cpps <- forM ps $ \(key, value) -> do
63 cpps <- forM ps $ \(key, value) -> do
64 value' <- prettyPrintCpp' value
64 value' <- prettyPrintCpp' value
@@ -67,7 +67,7 @@ literals = mkPattern' match'
67 return $ intercalate (emit ",\n") $ map (indentString <>) cpps
67 return $ intercalate (emit ",\n") $ map (indentString <>) cpps
68 , return $ emit "\n"
68 , return $ emit "\n"
69 , currentIndent
69 , currentIndent
70− , return $ emit "}"
70+ , return $ emit "} }"
73 objectPropertyToString :: (Emit gen) => PSString -> gen
73 objectPropertyToString :: (Emit gen) => PSString -> gen
@@ -106,7 +106,7 @@ literals = mkPattern' match'
107 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
107 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
108 | fnMod == dictMod
108 | fnMod == dictMod
109− , dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
109+ , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
110 , Just t <- unboxType dict
110 , Just t <- unboxType dict
111 = mconcat <$> sequence
111 = mconcat <$> sequence
112 [ return $ emit $ unbox t x
112 [ return $ emit $ unbox t x
@@ -231,7 +231,7 @@ literals = mkPattern' match'
231 , prettyPrintCpp' thens
231 , prettyPrintCpp' thens
232 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
232 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
234− match (IfElse _ (Binary _ EqualTo x@Var{} y@(NumericLiteral _ n)) thens elses) = mconcat <$> sequence
234+ match (IfElse _ (Binary _ EqualTo x y@(NumericLiteral _ n)) thens elses) = mconcat <$> sequence
235 [ return $ emit "if ("
235 [ return $ emit "if ("
236 , return $ emit $ unbox t x
236 , return $ emit $ unbox t x
237 , return $ emit $ " == "
237 , return $ emit $ " == "
@@ -243,7 +243,15 @@ literals = mkPattern' match'
244 t | Left _ <- n = int
244 t | Left _ <- n = int
245 | Right _ <- n = float
245 | Right _ <- n = float
246−
246+ match (IfElse _ (Binary _ EqualTo a b@StringLiteral{}) thens elses) = mconcat <$> sequence
247+ [ return $ emit "if ("
248+ , return $ emit $ unbox string a
249+ , return $ emit $ " == "
251+ , return $ emit ") "
252+ , prettyPrintCpp' thens
253+ , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintCpp') elses
247 match (IfElse _ cond thens elses) = mconcat <$> sequence
255 match (IfElse _ cond thens elses) = mconcat <$> sequence
248 [ return $ emit "if ("
256 [ return $ emit "if ("
249 , prettyPrintCpp' cond
257 , prettyPrintCpp' cond
@@ -401,7 +409,8 @@ unbox t v = "unbox<" <> t <> ">(" <> prettyPrintCpp1 v <> ")"
402unboxType :: Text -> Maybe Text
410unboxType :: Text -> Maybe Text
403unboxType t
411unboxType t
404− | t == C.semiringInt ||
413+ t == C.semiringInt ||
405 t == C.ringInt
414 t == C.ringInt
406 = Just int
415 = Just int
407 | t == C.semiringNumber ||
416 | t == C.semiringNumber ||
@@ -412,6 +421,7 @@ unboxType t
413renderOp :: Text -> Text
422renderOp :: Text -> Text
414renderOp op
423renderOp op
424+ | op == C.eq = " == "
415 | op == C.add = " + "
425 | op == C.add = " + "
416 | op == C.sub = " - "
426 | op == C.sub = " - "
417 | op == C.mul = " * "
427 | op == C.mul = " * "
@@ -476,6 +486,12 @@ int = "int"
476float :: Text
486float :: Text
477float = "double"
487float = "double"
479foreignDict :: Text
495foreignDict :: Text
480foreignDict = "_foreign_"
496foreignDict = "_foreign_"