Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Franck Pommereau
/
cct
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Wiki
Network
Create a new issue
Commits
Authored by
Franck Pommereau
2018-04-23 15:41:18 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25908238b804243ec1758c983fa95b731553d5e1
25908238
1 parent
d03434ba
simple tests passed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
.gitignore
cctlib/cttc.py
.gitignore
View file @
2590823
...
...
@@ -9,3 +9,4 @@ __pycache__
#*
cctlib/parser.out
cct-test
/ttclib
...
...
cctlib/cttc.py
View file @
2590823
...
...
@@ -194,6 +194,13 @@ class CodeGenVisitor (Visitor) :
outfile
.
write
(
"
\n
#
\n
# string literals from file
%
r
\n
#
\n\n
"
%
c
.
path
)
outfile
.
write
(
s
)
outfile
.
write
(
"
\n
#
\n
"
"# call main
\n
"
"#
\n\n
"
"IRQ0:
\n
"
" set R9 @main
\n
"
" call R9
\n
"
" halt
\n
"
)
def
_calc_function_var_addrs
(
self
,
symtab
,
last_fp_loc
):
self
.
_calc_function_arg_addrs
(
symtab
)
...
...
@@ -201,7 +208,7 @@ class CodeGenVisitor (Visitor) :
def
_calc_function_arg_addrs
(
self
,
symtab
):
for
symbol
in
symtab
.
entries
.
values
():
symbol
.
compile_loc
=
2
+
symbol
.
param_num
symbol
.
compile_loc
=
3
+
symbol
.
param_num
if
not
symbol
.
is_used
:
self
.
warning
(
"function argument '
%
s' is never used."
%
symbol
.
name
)
...
...
@@ -401,7 +408,7 @@ class CodeGenVisitor (Visitor) :
call
=
node
.
arglist
.
nodes
[
0
]
.
get_str
()
expect
=
self
.
test
[
call
]
ret
=
self
.
_accept_and_pop
(
node
.
arglist
.
nodes
[
1
])
self
.
o
(
" ###
%
s ==
%
s # ==
%
s"
%
(
ret
,
expect
,
call
))
self
.
o
(
" ###
%
s ==
%
s # ==
%
s
\n
"
%
(
ret
,
expect
,
call
))
self
.
stack
.
done
()
return
self
.
c
(
"FUNCTION CALL to
%
s() - begin"
%
...
...
Please
register
or
login
to post a comment