@@ -26,6 +26,7 @@ module Language.PureScript.CodeGen.Cpp
2626 , P.prettyPrintCpp
2727 ) where
2828
29+import Data.Char (isLetter)
2930import Data.List
3031import Data.Function (on)
3132import qualified Data.Map as M
@@ -146,7 +147,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
146147 CppLambda [CppCaptureAll] (farg <$> [f'])
147148 (Just $ CppAny [])
148149 (CppBlock $ fieldLambdas fs')]
149− | otherwise = [CppReturn (CppObjectLiteral ((ctorKey, CppStringLiteral name) : zip fields' (CppVar <$> fields')))]
150+ | otherwise = [CppReturn (CppArrayLiteral (CppStringLiteral name : (CppVar <$> fields')))]
150151
151152 declToCpp _ ident val = do
152153 val' <- valueToCpp val
@@ -404,7 +405,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
404405 return $ case ctorType of
405406 ProductType -> cpps
406407 SumType ->
407− [ CppIfElse (CppBinary Equal (CppIndexer (CppStringLiteral ctorKey) (CppVar varName))
408+ [ CppIfElse (CppBinary Equal (CppIndexer (CppVar ctorKey) (CppVar varName))
408409 (CppStringLiteral ctor'))
409410 (CppBlock cpps)
410411 Nothing ]
@@ -417,8 +418,10 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
417418 cpps <- binderToCpp argVar done'' binder
418419 return (CppVariableIntroduction (argVar, Nothing)
419420 []
420− (Just (CppIndexer (CppStringLiteral $ identToCpp field) (CppVar varName)))
421+ (Just (CppIndexer (fieldToIndex field) (CppVar varName)))
421422 : cpps)
423+ fieldToIndex :: Ident -> Cpp
424+ fieldToIndex = CppNumericLiteral . Left . (+1) . read . dropWhile isLetter . runIdent
422425
423426 binderToCpp _ _ b@(ConstructorBinder{}) =
424427 error $ "Invalid ConstructorBinder in binderToCpp: " ++ show b