@@ -8,6 +8,7 @@ import Idris.AbsSyntax hiding (TypeCase)
8import IRTS.Bytecode
8import IRTS.Bytecode
9import IRTS.Lang
9import IRTS.Lang
10import IRTS.Simplified
10import IRTS.Simplified
11+import IRTS.Defunctionalise
11import IRTS.CodegenCommon
12import IRTS.CodegenCommon
12import Idris.Core.TT
13import Idris.Core.TT
13import IRTS.System
14import IRTS.System
@@ -1328,7 +1329,8 @@ translateBC info bc
1328 | NULL r <- bc = jsNULL info r
1329 | NULL r <- bc = jsNULL info r
1329 | CALL n <- bc = jsCALL info n
1330 | CALL n <- bc = jsCALL info n
1330 | TAILCALL n <- bc = jsTAILCALL info n
1331 | TAILCALL n <- bc = jsTAILCALL info n
1332+ | FOREIGNCALL r _ (DConst (Str n)) args
1331− | FOREIGNCALL r _ n a <- bc = error "jsFOREIGN info r n a"
1333+ <- bc = jsFOREIGN info r n (map fcall args)
1332 | TOPBASE n <- bc = jsTOPBASE info n
1334 | TOPBASE n <- bc = jsTOPBASE info n
1333 | BASETOP n <- bc = jsBASETOP info n
1335 | BASETOP n <- bc = jsBASETOP info n
1334 | STOREOLD <- bc = jsSTOREOLD info
1336 | STOREOLD <- bc = jsSTOREOLD info
@@ -1342,4 +1344,19 @@ translateBC info bc
1342 | OP r o a <- bc = jsOP info r o a
1344 | OP r o a <- bc = jsOP info r o a
1343 | ERROR e <- bc = jsERROR info e
1345 | ERROR e <- bc = jsERROR info e
1344 | otherwise = JSRaw $ "//" ++ show bc
1346 | otherwise = JSRaw $ "//" ++ show bc
1347+ where fcall (t, arg) = (toFType t, arg)
1350+ | i == sUN "JS_IntChar" = ATInt ITChar
1351+ | i == sUN "JS_IntNative" = ATInt ITNative
1352+toAType t = error (show t ++ " not defined in toAType")
1355+ | c == sUN "JS_Str" = FString
1356+ | c == sUN "JS_Float" = FArith ATFloat
1357+ | c == sUN "JS_Ptr" = FPtr
1358+ | c == sUN "JS_Unit" = FUnit
1359+toFType (FApp c [_,ity])
1360+ | c == sUN "JS_IntT" = FArith (toAType ity)
1361+toFType t = error (show t ++ " not yet defined in toFType")