Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
3312237c
Commit
3312237c
authored
Jul 25, 2014
by
dbarbera
Browse files
Fix state constants generation
parent
0e0d3720
Changes
1
Hide whitespace changes
Inline
Side-by-side
LlvmGenerator.py
View file @
3312237c
...
...
@@ -334,10 +334,10 @@ def _process(process):
for
name
,
val
in
process
.
mapping
.
viewitems
():
if
not
name
.
endswith
(
'START'
):
cons_val
=
core
.
Constant
.
int
(
ctx
.
i32
,
len
(
ctx
.
states
))
ctx
.
states
[
name
]
=
cons_val
ctx
.
states
[
name
.
lower
()
]
=
cons_val
elif
name
!=
'START'
:
cons_val
=
core
.
Constant
.
int
(
ctx
.
i32
,
val
)
ctx
.
states
[
name
]
=
cons_val
ctx
.
states
[
name
.
lower
()
]
=
cons_val
# Generate state var
state_cons
=
ctx
.
module
.
add_global_variable
(
ctx
.
i32
,
'state'
)
...
...
@@ -494,7 +494,7 @@ def generate_input_signal(signal, inputs):
switch
=
ctx
.
builder
.
switch
(
g_state_val
,
exit_block
)
for
state_name
,
state_id
in
ctx
.
states
.
iteritems
():
if
state_name
.
endswith
(
'
START
'
):
if
state_name
.
endswith
(
'
start
'
):
continue
state_block
=
func
.
append_basic_block
(
'state_%s'
%
str
(
state_name
))
switch
.
add_case
(
state_id
,
state_block
)
...
...
@@ -1614,13 +1614,13 @@ def generate_next_state_terminator(term):
''' Generate the code for a next state transition terminator '''
state
=
term
.
inputString
.
lower
()
if
state
.
strip
()
!=
'-'
:
if
term
.
next_id
in
ctx
.
states
:
next_id_val
=
ctx
.
states
[
term
.
next_id
]
else
:
if
type
(
term
.
next_id
)
is
int
:
next_id_val
=
core
.
Constant
.
int
(
ctx
.
i32
,
term
.
next_id
)
if
term
.
next_id
==
-
1
:
ctx
.
builder
.
store
(
ctx
.
states
[
state
.
lower
()],
ctx
.
global_scope
.
resolve
(
'state'
))
else
:
next_id_val
=
ctx
.
states
[
term
.
next_id
.
lower
()]
ctx
.
builder
.
store
(
next_id_val
,
ctx
.
scope
.
resolve
(
'id'
))
if
term
.
next_id
==
-
1
:
ctx
.
builder
.
store
(
ctx
.
states
[
state
],
ctx
.
global_scope
.
resolve
(
'state'
))
else
:
nexts
=
[(
n
,
s
)
for
(
n
,
s
)
in
term
.
candidate_id
.
viewitems
()
if
n
!=
-
1
]
if
nexts
:
...
...
@@ -1632,10 +1632,10 @@ def generate_next_state_terminator(term):
switch
=
ctx
.
builder
.
switch
(
curr_state_val
,
default_case_block
)
for
next_state
,
states
in
nexts
:
next_id_val
=
ctx
.
states
[
next_state
]
next_id_val
=
ctx
.
states
[
next_state
.
lower
()
]
for
state
in
states
:
case_block
=
func
.
append_basic_block
(
''
)
switch
.
add_case
(
ctx
.
states
[
state
],
case_block
)
switch
.
add_case
(
ctx
.
states
[
state
.
lower
()
],
case_block
)
ctx
.
builder
.
position_at_end
(
case_block
)
ctx
.
builder
.
store
(
next_id_val
,
ctx
.
scope
.
resolve
(
'id'
))
ctx
.
builder
.
branch
(
end_block
)
...
...
Write
Preview
Supports
Markdown
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