on master help sign in
javascript: inline some SLIDEs and PROJECTs
4ac55ccraichoo
src/IRTS/CodegenJavaScript.hs+10
@@ -824,6 +824,7 @@ jsERROR :: CompileInfo -> String -> JS
824jsERROR _ = JSError
824jsERROR _ = JSError
825
825
826jsSLIDE :: CompileInfo -> Int -> JS
826jsSLIDE :: CompileInfo -> Int -> JS
827+jsSLIDE _ 1 = JSAssign (jsLOC 0) (jsTOP 0)
827jsSLIDE _ n = JSApp (JSIdent "i$SLIDE") [JSNum (JSInt n)]
828jsSLIDE _ n = JSApp (JSIdent "i$SLIDE") [JSNum (JSInt n)]
828
829
829jsMKCON :: CompileInfo -> Reg -> Int -> [Reg] -> JS
830jsMKCON :: CompileInfo -> Reg -> Int -> [Reg] -> JS
@@ -931,6 +932,15 @@ jsCONSTCASE info reg cases def =
931 prepBranch bc = JSSeq $ map (translateBC info) bc
932 prepBranch bc = JSSeq $ map (translateBC info) bc
932
933
933jsPROJECT :: CompileInfo -> Reg -> Int -> Int -> JS
934jsPROJECT :: CompileInfo -> Reg -> Int -> Int -> JS
935+jsPROJECT _ reg loc 0 = JSNoop
936+jsPROJECT _ reg loc 1 =
937+ JSAssign (jsLOC loc) (
938+ JSIndex (
939+ JSProj (translateReg reg) "args"
940+ ) (
941+ JSNum (JSInt 0)
942+ )
943+ )
934jsPROJECT _ reg loc ar =
944jsPROJECT _ reg loc ar =
935 JSApp (JSIdent "i$PROJECT") [ translateReg reg
945 JSApp (JSIdent "i$PROJECT") [ translateReg reg
936 , JSNum (JSInt loc)
946 , JSNum (JSInt loc)