Commit 29cd5778 authored by László Domoszlai's avatar László Domoszlai

extract strictness information from the template of inline functions

git-svn-id: https://svn.cs.ru.nl/repos/clean-sapl/branches/hierarchical@454 cb785ff4-4565-4a15-8565-04c4fcf96d79
parent 5d3631c0
......@@ -19,9 +19,10 @@ from Data.Map import :: Map
:: InlineCoderFun :== TermCoderFun TermCoderFun [SaplTerm] StringAppender -> StringAppender
:: InlineFunDef =
{ fun :: !InlineCoderFun
, arity :: !Arity
, data_cons :: !Bool
{ fun :: !InlineCoderFun
, arity :: !Arity
, strictness :: !{#Char} // '1','0'
, data_cons :: !Bool
}
:: Flavour = { fun_prefix :: String
......
implementation module Sapl.Target.Flavour
import StdList, StdFunc
import StdList, StdFunc, StdArray
import Data.Maybe, Text.JSON, Data.Map, Text.StringAppender
import Sapl.SaplParser
......@@ -58,19 +58,32 @@ where
builtInFunctions = fromList bifList
ifs = filter (\f -> isJust f.inline_exp) rep.bifs
ifList = map (\f -> (f.sapl_fun, { InlineFunDef
| fun = toInlineFun (fromJust f.inline_exp)
, arity = f.BIFRep.arity
, data_cons = maybe False id f.BIFRep.data_cons })) ifs
ifList = map toInlineFunDef ifs
inlineFunctions = fromList ifList
toInlineFun tpl = inst
toInlineFunDef f
= (f.sapl_fun, { InlineFunDef
| fun = toInlineFun
, arity = f.BIFRep.arity
, strictness = collectStrictnessInfo (createArray f.BIFRep.arity '0') bindings
, data_cons = maybe False id f.BIFRep.data_cons })
where
inst eval feval args a = foldl app a bindings
toInlineFun = inst
where
bindings = extractBindings tpl
app a (StringPart str) = a <++ str
app a (Binding x) = eval (args!!(x-1)) a
app a (ForceBinding x) = feval (args!!(x-1)) a
inst eval feval args a = foldl app a bindings
where
app a (StringPart str) = a <++ str
app a (Binding x) = eval (args!!(x-1)) a
app a (ForceBinding x) = feval (args!!(x-1)) a
template = fromJust f.inline_exp
bindings = extractBindings template
collectStrictnessInfo arr [] = arr
collectStrictnessInfo arr [ForceBinding i:bs]
# arr = if (i<=size arr) (update arr (i-1) '1') arr
= collectStrictnessInfo arr bs
collectStrictnessInfo arr [_:bs] = collectStrictnessInfo arr bs
\ No newline at end of file
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