@@ -8,6 +8,7 @@ import Idris.AbsSyntax hiding (TypeCase)
88import IRTS.Bytecode
99import IRTS.Lang
1010import IRTS.Simplified
11+import IRTS.Defunctionalise
1112import IRTS.CodegenCommon
1213import Idris.Core.TT
1314import IRTS.System
@@ -1328,7 +1329,8 @@ translateBC info bc
13281329 | NULL r <- bc = jsNULL info r
13291330 | CALL n <- bc = jsCALL info n
13301331 | TAILCALL n <- bc = jsTAILCALL info n
1331− | FOREIGNCALL r _ n a <- bc = error "jsFOREIGN info r n a"
1332+ | FOREIGNCALL r _ (DConst (Str n)) args
1333+ <- bc = jsFOREIGN info r n (map fcall args)
13321334 | TOPBASE n <- bc = jsTOPBASE info n
13331335 | BASETOP n <- bc = jsBASETOP info n
13341336 | STOREOLD <- bc = jsSTOREOLD info
@@ -1342,4 +1344,19 @@ translateBC info bc
13421344 | OP r o a <- bc = jsOP info r o a
13431345 | ERROR e <- bc = jsERROR info e
13441346 | otherwise = JSRaw $ "//" ++ show bc
1347+ where fcall (t, arg) = (toFType t, arg)
1348+
1349+toAType (FCon i)
1350+ | i == sUN "JS_IntChar" = ATInt ITChar
1351+ | i == sUN "JS_IntNative" = ATInt ITNative
1352+toAType t = error (show t ++ " not defined in toAType")
1353+
1354+toFType (FCon c)
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")
13451362