Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
49c09581
Commit
49c09581
authored
Jul 11, 2016
by
Laszlo Domoszlai
Browse files
add --no-strictness-propagation option to precompiler and use it for builtins to avoid
compiling out trick with _trace
parent
c334e3d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
interpreter/builtin.sapl
View file @
49c09581
...
...
@@ -8,7 +8,10 @@ App7 !f a1 a2 a3 a4 a5 a6 a7 = f a1 a2 a3 a4 a5 a6 a7
App8 !f a1 a2 a3 a4 a5 a6 a7 a8 = f a1 a2 a3 a4 a5 a6 a7 a8
App9 !f a1 a2 a3 a4 a5 a6 a7 a8 a9 = f a1 a2 a3 a4 a5 a6 a7 a8 a9
error str = _trace str
:: _Tuple2 = _Tuple2 a b
:: _Tuple2!3 = _Tuple2!3 a b
:: _Tuple3 = _Tuple3 a b c
:: _Tuple4 = _Tuple4 a b c d
...
...
@@ -36,13 +39,3 @@ array_replace_B_R !arr !idx::I !elem::R = _Tuple2 (array_select_B_R arr idx) (ar
second !f !s = s
trace !str a = second (_trace str) a
tupsels2v0 !t = select t (_Tuple2 a0 a1 -> a0)
tupsels2v1 !t = select t (_Tuple2 a0 a1 -> a1)
tupsels3v0 !t = select t (_Tuple3 a0 a1 a2 -> a0)
tupsels3v1 !t = select t (_Tuple3 a0 a1 a2 -> a1)
tupsels3v2 !t = select t (_Tuple3 a0 a1 a2 -> a2)
tupsels4v0 !t = select t (_Tuple4 a0 a1 a2 a3 -> a0)
tupsels4v1 !t = select t (_Tuple4 a0 a1 a2 a3 -> a1)
tupsels4v2 !t = select t (_Tuple4 a0 a1 a2 a3 -> a2)
tupsels4v3 !t = select t (_Tuple4 a0 a1 a2 a3 -> a3)
\ No newline at end of file
interpreter/compile_builtin.bat
0 → 100644
View file @
49c09581
..\precompiler\precompiler.exe
--no-strictness-propagation
builtin
.sapl
builtin
.bsapl
\ No newline at end of file
precompiler/precompiler.icl
View file @
49c09581
...
...
@@ -97,7 +97,7 @@ sTerm ctx t a = sTermS ctx (simplify t) a
where
sTermS
ctx
(
SLit
lit
)
a
=
a
<++
"L"
<++
lit
sTermS
ctx
(
SVar
var
)
a
=
a
<++
sVarApp
ctx
var
sTermS
ctx
(
SSelect
expr
idx
)
a
=
a
<++
"S"
<++
sTerm
{
ctx
&
inspine
=
False
}
expr
<++
sNum
idx
sTermS
ctx
(
SSelect
expr
_
idx
)
a
=
a
<++
"S"
<++
sTerm
{
ctx
&
inspine
=
False
}
expr
<++
sNum
idx
// The function part could by arbitrary SaplTerm in theory, but in practice at this point
// it can be only SVar
sTermS
ctx
(
SApplication
(
SVar
var
)
terms
)
a
=
a
<++
appType
ctx
var
<++
sNum
(
length
terms
)
<++
sVar
ctx
var
<++
sList0
(
sTerm
{
ctx
&
inspine
=
False
})
terms
...
...
@@ -187,19 +187,25 @@ where
Start
world
#
(
args
,
world
)
=
getCommandLine
world
|
length
args
<
3
|
length
args
<
2
=
setReturnCode
-1
world
#
no_strictness_prop
=
args
!!
1
==
"--no-strictness-propagation"
#
extra
=
if
no_strictness_prop
1
0
|
length
args
<
(
3
+
extra
)
=
setReturnCode
-1
world
#
(
Ok
sapl
,
world
)
=
readFile
(
args
!!
1
)
world
#
(
Ok
sapl
,
world
)
=
readFile
(
args
!!
(
1
+
extra
)
)
world
// tokenize
#
tokens
=
tokensWithPositions
sapl
// parse
#
(
Ok
(
fs
,
ps
))
=
parse
tokens
// strictness propagation
#
(
fs
,
ps
)
=
doStrictnessPropagation
ps
isStrictArg
fs
#
(
fs
,
ps
)
=
if
no_strictness_prop
(
fs
,
ps
)
(
doStrictnessPropagation
ps
isStrictArg
fs
)
// lifting
#
fs
=
map
prepareFun
fs
#
(_,
world
)
=
writeFile
(
args
!!
2
)
(
toString
(
genDefs
fs
newAppender
))
world
#
(_,
world
)
=
writeFile
(
args
!!
(
2
+
extra
)
)
(
toString
(
genDefs
fs
newAppender
))
world
=
world
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment