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
b9ecfe99
Commit
b9ecfe99
authored
Feb 01, 2016
by
Laszlo Domoszlai
Browse files
fix bug
parent
be8a06f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
b9ecfe99
...
...
@@ -173,7 +173,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
switch
(
expr
->
type
)
{
case
CT_APP_PRIM1
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
)
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
...
...
@@ -201,7 +201,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case
CT_APP_PRIM2
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
)
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
...
...
@@ -258,7 +258,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case
CT_APP_PRIM
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
)
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
...
...
interpreter/desc_base.h
View file @
b9ecfe99
...
...
@@ -19,6 +19,7 @@ struct Desc {
unsigned
int
arity
:
8
;
// LIMITATION: maximum 32 arguments
unsigned
int
thunk_size
:
10
;
// It gives false result for strings and arrays
unsigned
int
hnf
:
1
;
// TODO: unused, remove?
unsigned
int
unboxable_return
:
1
;
};
void
(
*
eval
)();
...
...
interpreter/prim.c
View file @
b9ecfe99
...
...
@@ -385,7 +385,7 @@ void __trace(int dst_idx)
}
}
void
add_prim
(
int
arity
,
int
boxingMap
,
char
*
name
,
void
(
*
exec
)(
int
))
{
void
add_prim
(
int
arity
,
int
boxingMap
,
int
unboxableReturn
,
char
*
name
,
void
(
*
exec
)(
int
))
{
int
nameLength
=
strlen
(
name
);
// before the PrimEntry there are "arity" number of SliceEntries
...
...
@@ -396,6 +396,7 @@ void add_prim(int arity, int boxingMap, char* name, void (*exec)(int)) {
entry
->
base
.
arity
=
arity
;
entry
->
base
.
thunk_size
=
thunk_size_f
(
arity
);
entry
->
base
.
hnf
=
false
;
entry
->
base
.
unboxable_return
=
unboxableReturn
;
entry
->
boxingMap
=
boxingMap
;
entry
->
exec
=
exec
;
...
...
@@ -410,34 +411,34 @@ void add_prim(int arity, int boxingMap, char* name, void (*exec)(int)) {
}
void
init_prim
()
{
add_prim
(
2
,
0
b011
,
"addI"
,
&
__addI
);
add_prim
(
2
,
0
b011
,
"subI"
,
&
__subI
);
add_prim
(
2
,
0
b011
,
"multI"
,
&
__multI
);
add_prim
(
2
,
0
b011
,
"divI"
,
&
__divI
);
add_prim
(
2
,
0
b011
,
"gtI"
,
&
__gtI
);
add_prim
(
2
,
0
b011
,
"geI"
,
&
__geI
);
add_prim
(
2
,
0
b011
,
"geC"
,
&
__geC
);
add_prim
(
2
,
0
b011
,
"ltI"
,
&
__ltI
);
add_prim
(
2
,
0
b011
,
"eqI"
,
&
__eqI
);
add_prim
(
2
,
0
b011
,
"neqI"
,
&
__neqI
);
add_prim
(
2
,
0
b011
,
"eqB"
,
&
__eqB
);
add_prim
(
2
,
0
b011
,
"eqC"
,
&
__eqC
);
add_prim
(
1
,
0
b001
,
"not"
,
&
__not
);
add_prim
(
2
,
0
b011
,
"and"
,
&
__and
);
add_prim
(
2
,
0
b011
,
"or"
,
&
__or
);
add_prim
(
2
,
0
b011
,
"mod"
,
&
__mod
);
add_prim
(
1
,
0
b001
,
"C2I"
,
&
__C2I
);
add_prim
(
1
,
0
b001
,
"I2C"
,
&
__I2C
);
add_prim
(
2
,
0
b011
,
1
,
"addI"
,
&
__addI
);
add_prim
(
2
,
0
b011
,
1
,
"subI"
,
&
__subI
);
add_prim
(
2
,
0
b011
,
1
,
"multI"
,
&
__multI
);
add_prim
(
2
,
0
b011
,
1
,
"divI"
,
&
__divI
);
add_prim
(
2
,
0
b011
,
1
,
"gtI"
,
&
__gtI
);
add_prim
(
2
,
0
b011
,
1
,
"geI"
,
&
__geI
);
add_prim
(
2
,
0
b011
,
1
,
"geC"
,
&
__geC
);
add_prim
(
2
,
0
b011
,
1
,
"ltI"
,
&
__ltI
);
add_prim
(
2
,
0
b011
,
1
,
"eqI"
,
&
__eqI
);
add_prim
(
2
,
0
b011
,
1
,
"neqI"
,
&
__neqI
);
add_prim
(
2
,
0
b011
,
1
,
"eqB"
,
&
__eqB
);
add_prim
(
2
,
0
b011
,
1
,
"eqC"
,
&
__eqC
);
add_prim
(
1
,
0
b001
,
1
,
"not"
,
&
__not
);
add_prim
(
2
,
0
b011
,
1
,
"and"
,
&
__and
);
add_prim
(
2
,
0
b011
,
1
,
"or"
,
&
__or
);
add_prim
(
2
,
0
b011
,
1
,
"mod"
,
&
__mod
);
add_prim
(
1
,
0
b001
,
1
,
"C2I"
,
&
__C2I
);
add_prim
(
1
,
0
b001
,
1
,
"I2C"
,
&
__I2C
);
add_prim
(
1
,
0
b000
,
"string_size"
,
&
__string_size
);
add_prim
(
2
,
0
b010
,
"string_select"
,
&
__string_select
);
add_prim
(
1
,
0
b001
,
"string_create1"
,
&
__string_create1
);
add_prim
(
2
,
0
b011
,
"string_create2"
,
&
__string_create2
);
add_prim
(
3
,
0
b110
,
"string_update"
,
&
__string_update
);
add_prim
(
3
,
0
b110
,
"string_slice"
,
&
__string_slice
);
add_prim
(
2
,
0
b000
,
"string_append"
,
&
__string_append
);
add_prim
(
2
,
0
b000
,
"eqS"
,
&
__eqS
);
add_prim
(
1
,
0
b001
,
"C2S"
,
&
__C2S
);
add_prim
(
1
,
0
b000
,
1
,
"string_size"
,
&
__string_size
);
add_prim
(
2
,
0
b010
,
1
,
"string_select"
,
&
__string_select
);
add_prim
(
1
,
0
b001
,
0
,
"string_create1"
,
&
__string_create1
);
add_prim
(
2
,
0
b011
,
0
,
"string_create2"
,
&
__string_create2
);
add_prim
(
3
,
0
b110
,
0
,
"string_update"
,
&
__string_update
);
add_prim
(
3
,
0
b110
,
0
,
"string_slice"
,
&
__string_slice
);
add_prim
(
2
,
0
b000
,
0
,
"string_append"
,
&
__string_append
);
add_prim
(
2
,
0
b000
,
1
,
"eqS"
,
&
__eqS
);
add_prim
(
1
,
0
b001
,
0
,
"C2S"
,
&
__C2S
);
add_prim
(
1
,
0
b000
,
"_trace"
,
&
__trace
);
add_prim
(
1
,
0
b000
,
0
,
"_trace"
,
&
__trace
);
}
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