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
4bfb088d
Commit
4bfb088d
authored
Sep 16, 2015
by
Laszlo Domoszlai
Browse files
better naming + increase fib argument
parent
2cb21c80
Changes
3
Hide whitespace changes
Inline
Side-by-side
interpreter/prim.c
View file @
4bfb088d
...
...
@@ -7,44 +7,44 @@
#define arg(idx) stack_a[stack_top_a - idx]
void
__add
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__add
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__INT__
;
target
->
_int
=
readI
(
arg
(
2
))
+
readI
(
arg
(
1
));
}
void
__sub
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__sub
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__INT__
;
target
->
_int
=
readI
(
arg
(
2
))
-
readI
(
arg
(
1
));
}
void
__gt
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__gt
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__BOOL__
;
target
->
_bool
=
readI
(
arg
(
2
))
>
readI
(
arg
(
1
));
}
void
__lt
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__lt
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__BOOL__
;
target
->
_bool
=
readI
(
arg
(
2
))
<
readI
(
arg
(
1
));
}
void
__eqI
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__eqI
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__BOOL__
;
target
->
_bool
=
readI
(
arg
(
2
))
==
readI
(
arg
(
1
));
}
void
__eqB
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__eqB
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__BOOL__
;
target
->
_bool
=
readB
(
arg
(
2
))
==
readB
(
arg
(
1
));
}
void
__not
(
int
frame_ptr
)
{
Thunk
*
target
=
get_dst
(
frame_ptr
);
void
__not
(
int
dst_idx
)
{
Thunk
*
target
=
get_dst
(
dst_idx
);
target
->
desc
=
(
Desc
*
)
__BOOL__
;
target
->
_bool
=
!
readB
(
arg
(
1
));
}
...
...
tests/fib.exp
View file @
4bfb088d
[1346269]
\ No newline at end of file
[14930352]
\ No newline at end of file
tests/fib.sapl
View file @
4bfb088d
main = example.Start
example.Start = example.fib 3
0
example.Start = example.fib 3
5
example.fib !n_0 = if (lt n_0 2) 1 (add (example.fib (sub n_0 1)) (example.fib (sub n_0 2)))
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