git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'golang' of github.com:andyarvanitis/purescript-native into golang
commit7d698385bce3a1f8165d34a389cff17adc00b1fc authorAndy Arvanitis <andyarvanitis@gmail.com> dateTue 9 Jul 2019, 21:20 (7 years ago) parent6cbb9c0d1f477b
4 files changed+18−5
app/Main.hs+5−4 runtime/purescript.go+5 src/CodeGen/IL/Optimizer/Inliner.hs+1−1 src/CodeGen/IL/Printer.hs+7
app/Main.hs+5−4
@@ -63,10 +63,11 @@ main = do
6363 B.writeFile "Makefile" $(embedFile "support/Makefile")
6464 when ("--help" `elem` opts') $
6565 putStrLn help
66− if null files then do
67− currentDir <- getCurrentDirectory
68− processFiles opts' [currentDir]
69− else do
66+ if null files then
67+ when (null opts) $ do
68+ currentDir <- getCurrentDirectory
69+ processFiles opts' [currentDir]
70+ else
7071 processFiles opts' files
7172 return ()
7273 where
runtime/purescript.go+5
@@ -42,6 +42,11 @@ func SafeGet(dict map[string]Any, key string) Any {
4242 return value
4343}
4444
45+func At(arr Any, index int) Any {
46+ a, _ := arr.([]Any)
47+ return a[index]
48+}
49+
4550func Contains(dict Any, key string) bool {
4651 d, _ := dict.(map[string]Any)
4752 _, found := d[key]
src/CodeGen/IL/Optimizer/Inliner.hs+1−1
@@ -48,7 +48,7 @@ inlineCommonValues = everywhere convert
4848 | isDict boundedBoolean dict && isDict fnBottom fn = BooleanLiteral ss False
4949 | isDict boundedBoolean dict && isDict fnTop fn = BooleanLiteral ss True
5050 convert (App ss (App _ fn [dict]) [x])
51− | isDict ringInt dict && isDict fnNegate fn = Unary ss Negate x -- (unbox x $ snd ringInt)
51+ | isDict ringInt dict && isDict fnNegate fn = Unary ss Negate (unbox x $ snd ringInt)
5252 convert (App ss (App _ (App _ fn [dict]) [x]) [y])
5353 | isDict semiringInt dict && isDict fnAdd fn = intOp ss Add semiringInt x y
5454 | isDict semiringInt dict && isDict fnMultiply fn = intOp ss Multiply semiringInt x y
src/CodeGen/IL/Printer.hs+7
@@ -175,6 +175,13 @@ literals = mkPattern' match'
175175 , prettyPrintIL' (Var Nothing $ withPrefix name)
176176 , return $ emit "()"
177177 ]
178+ match (Indexer _ index@NumericLiteral{} val) = mconcat <$> sequence
179+ [ return $ emit "At("
180+ , prettyPrintIL' val
181+ , return $ emit ", "
182+ , prettyPrintIL' index
183+ , return $ emit ")"
184+ ]
178185 match (Indexer _ prop val) = mconcat <$> sequence
179186 [ return $ emit "Get("
180187 , prettyPrintIL' val