Commit 162a3fed authored by László Domoszlai's avatar László Domoszlai

bug fixes for the JS compiler(s)

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2358 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 79c0e43f
...@@ -296,10 +296,10 @@ forceTermCoder t=:(SApplication name args) s a ...@@ -296,10 +296,10 @@ forceTermCoder t=:(SApplication name args) s a
// TODO: inline (...) doc // TODO: inline (...) doc
| (isJust inlinefunc && (snd (fromJust inlinefunc)) == length args) | (isJust inlinefunc && (snd (fromJust inlinefunc)) == length args)
= a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t s a) args <++ ")" = a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t {s & cs_intrfunc = Nothing} a) args <++ ")"
| (isJust builtin && (snd (fromJust builtin)) == length args) | (isJust builtin && (snd (fromJust builtin)) == length args)
= a <++ func_name <++ "(" <++ make_app_args name args s <++ ")" = a <++ func_name <++ "(" <++ make_app_args name args {s & cs_intrfunc = Nothing} <++ ")"
| (isNothing function_args) && (isNothing builtin) | (isNothing function_args) && (isNothing builtin)
= a <++ "Sapl.feval(" <++ termCoder t s <++ ")" = a <++ "Sapl.feval(" <++ termCoder t s <++ ")"
......
...@@ -290,8 +290,6 @@ forceTermCoder t=:(SApplication name args) s a ...@@ -290,8 +290,6 @@ forceTermCoder t=:(SApplication name args) s a
// argument. In this case, the deeper call can't be handled as tail recursive! // argument. In this case, the deeper call can't be handled as tail recursive!
True = a <++ make_tr_app args {s & cs_intrfunc = Nothing} True = a <++ make_tr_app args {s & cs_intrfunc = Nothing}
= a <++ "Sapl.feval(" <++ func_name <++ "(" <++ make_app_args name args {s & cs_intrfunc = Nothing} <++ "))" = a <++ "Sapl.feval(" <++ func_name <++ "(" <++ make_app_args name args {s & cs_intrfunc = Nothing} <++ "))"
// TRAMPOLINE!
// = a <++ func_name <++ "(" <++ make_app_args name args {s & cs_intrfunc = Nothing} <++ ")"
// more arguments than needed // more arguments than needed
| (isJust function_args && (length (fromJust function_args) < length args)) | (isJust function_args && (length (fromJust function_args) < length args))
...@@ -299,10 +297,10 @@ forceTermCoder t=:(SApplication name args) s a ...@@ -299,10 +297,10 @@ forceTermCoder t=:(SApplication name args) s a
// TODO: inline (...) doc // TODO: inline (...) doc
| (isJust inlinefunc && (snd (fromJust inlinefunc)) == length args) | (isJust inlinefunc && (snd (fromJust inlinefunc)) == length args)
= a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t s a) args <++ ")" = a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t {s & cs_intrfunc = Nothing} a) args <++ ")"
| (isJust builtin && (snd (fromJust builtin)) == length args) | (isJust builtin && (snd (fromJust builtin)) == length args)
= a <++ func_name <++ "(" <++ make_app_args name args s <++ ")" = a <++ func_name <++ "(" <++ make_app_args name args {s & cs_intrfunc = Nothing} <++ ")"
| (isNothing function_args) && (isNothing builtin) | (isNothing function_args) && (isNothing builtin)
= a <++ "Sapl.feval(" <++ termCoder t s <++ ")" = a <++ "Sapl.feval(" <++ termCoder t s <++ ")"
...@@ -343,9 +341,9 @@ forceTermCoder t=:(SName name _) s a ...@@ -343,9 +341,9 @@ forceTermCoder t=:(SName name _) s a
| (isJust constructor_args) && (length (fromJust constructor_args) == 0) | (isJust constructor_args) && (length (fromJust constructor_args) == 0)
= a <++ escapeName name <++ "()" = a <++ escapeName name <++ "()"
| isCAF | isCAF
= a <++ escapeName name <++ "()" = a <++ "Sapl.feval(" <++ escapeName name <++ "())"
| (isJust function_args && (length (fromJust function_args) == 0)) | (isJust function_args && (length (fromJust function_args) == 0))
= a <++ escapeName name <++ "()" = a <++ "Sapl.feval(" <++ escapeName name <++ "())"
= a <++ "Sapl.feval(" <++ termCoder t s <++ ")" = a <++ "Sapl.feval(" <++ termCoder t s <++ ")"
where where
isStrictEq (SStrictName aname) = aname == name isStrictEq (SStrictName aname) = aname == name
...@@ -366,13 +364,16 @@ tailCallCoder t=:(SApplication name args) s a ...@@ -366,13 +364,16 @@ tailCallCoder t=:(SApplication name args) s a
| (isJust constructor_args && (length (fromJust constructor_args) == length args)) || | (isJust constructor_args && (length (fromJust constructor_args) == length args)) ||
(isJust function_args && (length (fromJust function_args) == length args)) (isJust function_args && (length (fromJust function_args) == length args))
= a <++ func_name <++ "(" <++ make_app_args name args s <++ ")"*/
| (isJust constructor_args && (length (fromJust constructor_args) == length args))
= a <++ func_name <++ "(" <++ make_app_args name args s <++ ")" = a <++ func_name <++ "(" <++ make_app_args name args s <++ ")"
// TODO: inline (...) doc // TODO: inline (...) doc
| (isJust inlinefunc && (snd (fromJust inlinefunc)) == length args) | (isJust inlinefunc && s.cs_haskell && (snd (fromJust inlinefunc)) == length args)
= a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t s a) args <++ ")" = a <++ "(" <++ (fst (fromJust inlinefunc)) (\t a = (if s.cs_haskell termCoder forceTermCoder) t s a) args <++ ")"
| (isJust builtin && (snd (fromJust builtin)) == length args) /* | (isJust builtin && (snd (fromJust builtin)) == length args)
= a <++ func_name <++ "(" <++ make_app_args name args s <++ ")" */ = a <++ func_name <++ "(" <++ make_app_args name args s <++ ")" */
// Otherwise // Otherwise
...@@ -390,10 +391,10 @@ tailCallCoder t=:(SName name _) s a ...@@ -390,10 +391,10 @@ tailCallCoder t=:(SName name _) s a
/* | any isStrictEq s.cs_current_vars /* | any isStrictEq s.cs_current_vars
= termCoder t s a = termCoder t s a
| isMember t s.cs_current_vars | isMember t s.cs_current_vars
= a <++ termCoder t s = a <++ termCoder t s*/
| (isJust constructor_args) && (length (fromJust constructor_args) == 0) | (isJust constructor_args) && (length (fromJust constructor_args) == 0)
= a <++ escapeName name <++ "()" = a <++ escapeName name <++ "()"
| isCAF /* | isCAF
= a <++ escapeName name <++ "()" = a <++ escapeName name <++ "()"
| (isJust function_args && (length (fromJust function_args) == 0)) | (isJust function_args && (length (fromJust function_args) == 0))
= a <++ escapeName name <++ "()" */ = a <++ escapeName name <++ "()" */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment