@@ -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
@@ -149,7 +150,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
149150 CppLambda [CppCaptureAll] (farg <$> [f'])
150151 (Just $ CppAny [])
151152 (CppBlock $ fieldLambdas fs')]
152− | otherwise = [CppReturn (CppObjectLiteral ((ctorKey, CppStringLiteral name) : zip fields' (CppVar <$> fields')))]
153+ | otherwise = [CppReturn (CppArrayLiteral (CppStringLiteral name : (CppVar <$> fields')))]
153154
154155 declToCpp _ ident val = do
155156 val' <- valueToCpp val
@@ -407,7 +408,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
407408 return $ case ctorType of
408409 ProductType -> cpps
409410 SumType ->
410− [ CppIfElse (CppBinary Equal (CppIndexer (CppStringLiteral ctorKey) (CppVar varName))
411+ [ CppIfElse (CppBinary Equal (CppIndexer (CppVar ctorKey) (CppVar varName))
411412 (CppStringLiteral ctor'))
412413 (CppBlock cpps)
413414 Nothing ]
@@ -420,8 +421,10 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
420421 cpps <- binderToCpp argVar done'' binder
421422 return (CppVariableIntroduction (argVar, Nothing)
422423 []
423− (Just (CppIndexer (CppStringLiteral $ identToCpp field) (CppVar varName)))
424+ (Just (CppIndexer (fieldToIndex field) (CppVar varName)))
424425 : cpps)
426+ fieldToIndex :: Ident -> Cpp
427+ fieldToIndex = CppNumericLiteral . Left . (+1) . read . dropWhile isLetter . runIdent
425428
426429 binderToCpp _ _ b@(ConstructorBinder{}) =
427430 error $ "Invalid ConstructorBinder in binderToCpp: " ++ show b