Commit 0200ae92 authored by László Domoszlai's avatar László Domoszlai

enable to set flags in the flavour file

git-svn-id: https://svn.cs.ru.nl/repos/clean-sapl/branches/hierarchical@458 cb785ff4-4565-4a15-8565-04c4fcf96d79
parent 7ee35566
......@@ -2,6 +2,7 @@ definition module Sapl.Target.Flavour
import Sapl.SaplParser, Text.StringAppender
from Data.Map import :: Map
from Data.Set import :: Set
:: Arity :== Int
......@@ -27,6 +28,9 @@ from Data.Map import :: Map
:: Flavour = { fun_prefix :: String
// Optional flags to tune the compiler
, options :: Set String
/**
* Returns a map of function names which are built-in. For every such function
* a implementation specific name and its arity is provided.
......@@ -41,3 +45,8 @@ from Data.Map import :: Map
}
toFlavour :: !String -> Maybe Flavour
// Check if a given flag is set or not in the flavour file
isSet :: !Flavour !String -> Bool
......@@ -4,7 +4,10 @@ import StdList, StdFunc, StdArray
import Data.Maybe, Text.JSON, Data.Map, Text.StringAppender
import Sapl.SaplParser
from Data.Set import qualified fromList, member
:: FlavourRep = { fun_prefix :: String
, options :: [String]
, bifs :: [BIFRep]
}
......@@ -51,7 +54,10 @@ where
mbRep = fromJSON (fromString str)
toFlavour` rep
= {fun_prefix = rep.FlavourRep.fun_prefix, builtInFunctions = builtInFunctions, inlineFunctions = inlineFunctions}
= { fun_prefix = rep.FlavourRep.fun_prefix
, options = 'Data.Set'.fromList rep.FlavourRep.options
, builtInFunctions = builtInFunctions
, inlineFunctions = inlineFunctions}
where
bifs = filter (\f -> isJust f.ext_fun) rep.bifs
bifList = map (\f -> (f.sapl_fun, (fromJust f.ext_fun, f.BIFRep.arity))) bifs
......@@ -84,6 +90,10 @@ where
# arr = if (i<=size arr) (update arr (i-1) '1') arr
= collectStrictnessInfo arr bs
collectStrictnessInfo arr [_:bs] = collectStrictnessInfo arr bs
isSet :: !Flavour !String -> Bool
isSet f opt = 'Data.Set'.member opt f.Flavour.options
\ No newline at end of file
......@@ -678,7 +678,7 @@ generateJS f tramp saplsrc mbPst
# pts = tokensWithPositions saplsrc
= case parse pts of
Ok (funcs, s) # newpst = mergeParserStates s mbPst
# (funcs, newpst) = doStrictnessPropagation newpst f funcs
# (funcs, newpst) = if (isSet f "enableStrictnessPropagation") (doStrictnessPropagation newpst f funcs) (funcs, newpst)
# state = newState f tramp newpst
# a = newAppender <++ "/*Trampoline: "
# a = if tramp (a <++ "ON") (a <++ "OFF")
......
{
"fun_prefix":"__",
"options":["enableStrictnessPropagation"],
"bifs":[
{
"sapl_fun":"add",
......
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