Skip to content
GitLab
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
90f5876d
Commit
90f5876d
authored
Oct 12, 2015
by
Laszlo Domoszlai
Browse files
CT_APP_FUN1, CT_APP_FUN2
parent
f6634ed9
Changes
3
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
90f5876d
...
...
@@ -89,8 +89,7 @@ struct Thunk* create_thunk_var_strict(Code* expr, int frame_ptr)
{
Thunk
*
arg
=
local
(
frame_ptr
,
((
VarEntry
*
)
expr
)
->
index
);
// TODO: check how often happens
if
(
arg
->
desc
->
unboxable
)
if
(
arg
->
desc
->
unboxable
)
// unboxable means it is on the B stack
{
Thunk
*
target
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
memcpy
(
target
,
arg
,
sizeof
(
Thunk
));
...
...
@@ -122,6 +121,8 @@ void set_create_thunk_fun(Code* code)
case
CT_APP_PRIM_AS
:
case
CT_APP_PRIM_SA
:
case
CT_APP_FUN
:
case
CT_APP_FUN1
:
case
CT_APP_FUN2
:
case
CT_APP_THUNK
:
code
->
create_thunk
=
create_thunk_app_static
;
break
;
...
...
@@ -265,6 +266,30 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
destroy_stack_frame_b
(
root_frame_ptr_b
);
return
;
}
case
CT_APP_FUN1
:
{
Desc
*
slice
=
((
AppEntry
*
)
expr
)
->
f
;
int
argmask
=
1
;
arg_from_code
(
slice
,
((
AppEntry
*
)
expr
)
->
args
[
0
]);
expr
=
((
FunEntry
*
)
slice
)
->
body
;
frame_ptr
=
stack_top_a
-
1
;
continue
;
}
case
CT_APP_FUN2
:
{
Desc
*
slice
=
((
AppEntry
*
)
expr
)
->
f
;
int
argmask
=
1
;
arg_from_code
(
slice
,
((
AppEntry
*
)
expr
)
->
args
[
0
]);
arg_from_code
(
slice
,
((
AppEntry
*
)
expr
)
->
args
[
1
]);
expr
=
((
FunEntry
*
)
slice
)
->
body
;
frame_ptr
=
stack_top_a
-
2
;
continue
;
}
case
CT_APP_FUN
:
{
Desc
*
slice
=
((
AppEntry
*
)
expr
)
->
f
;
...
...
interpreter/code.h
View file @
90f5876d
...
...
@@ -7,7 +7,8 @@ enum CodeType {
CT_VAR
,
CT_VAR_STRICT
,
CT_APP_PRIM1
,
CT_APP_PRIM_S
,
CT_APP_PRIM2
,
CT_APP_PRIM_ST
,
CT_APP_PRIM_TS
,
CT_APP_PRIM_SS
,
CT_APP_PRIM_TA
,
CT_APP_PRIM_AT
,
CT_APP_PRIM_AS
,
CT_APP_PRIM_SA
,
CT_APP_THUNK
,
CT_APP_FUN
,
CT_APP_DYN
,
CT_APP_THUNK
,
CT_APP_DYN
,
CT_APP_FUN
,
CT_APP_FUN1
,
CT_APP_FUN2
,
CT_SELECT
,
CT_IF
,
CT_THUNK
};
...
...
interpreter/parse.c
View file @
90f5876d
...
...
@@ -409,7 +409,18 @@ Code* parseApp(char **ptr, bool dynamic) {
}
else
if
(
desc
->
type
==
FT_FUN
)
{
entry
->
base
.
type
=
CT_APP_FUN
;
if
(
nrArgs
==
1
)
{
entry
->
base
.
type
=
CT_APP_FUN1
;
}
else
if
(
nrArgs
==
2
)
{
entry
->
base
.
type
=
CT_APP_FUN2
;
}
else
{
entry
->
base
.
type
=
CT_APP_FUN
;
}
}
else
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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