Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
f5899162
Commit
f5899162
authored
Nov 11, 2014
by
Maxime Perrotin
Browse files
Add prefix to generated procedures (Ada)
parent
30d209be
Changes
3
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
f5899162
...
...
@@ -87,6 +87,7 @@ LOCAL_VAR = {}
OUT_SIGNALS
=
[]
PROCEDURES
=
[]
UNICODE_SEP
=
u
'
\u00dc
'
@
singledispatch
def
generate
(
ast
):
...
...
@@ -110,7 +111,7 @@ def _process(process):
LOG
.
info
(
'Generating Ada code for process '
+
str
(
process_name
))
# In case model has nested states, flatten everything
Helper
.
flatten
(
process
,
sep
=
u
'
\u00dc
'
)
Helper
.
flatten
(
process
,
sep
=
UNICODE_SEP
)
# Make an maping {input: {state: transition...}} in order to easily
# generate the lookup tables for the state machine runtime
...
...
@@ -236,7 +237,7 @@ package {process_name} is'''.format(process_name=process_name,
taste_template
.
append
(
u
'when {state} =>'
.
format
(
state
=
state
))
input_def
=
mapping
[
signal
[
'name'
]].
get
(
state
)
# Check for nested states to call optional exit procedure
sep
=
u
'
\u00dc
'
sep
=
UNICODE_SEP
state_tree
=
state
.
split
(
sep
)
context
=
process
exitlist
=
[]
...
...
@@ -435,7 +436,7 @@ def write_statement(param, newline):
code
,
string
,
local
=
expression
(
param
)
if
type_kind
==
'OctetStringType'
:
# Octet string -> convert to Ada string
sep
=
u
'
\u00dc
'
sep
=
UNICODE_SEP
last_it
=
u
""
if
isinstance
(
param
,
ogAST
.
PrimSubstring
):
range_str
=
u
"{}'Range"
.
format
(
string
)
...
...
@@ -593,11 +594,12 @@ def _call_external_function(output):
# no need to use temporary variables, we are in pure Ada
list_of_params
.
append
(
p_id
)
if
list_of_params
:
code
.
append
(
u
'{proc}({params});'
.
format
(
code
.
append
(
u
'p{sep}{proc}({params});'
.
format
(
sep
=
UNICODE_SEP
,
proc
=
proc
.
inputString
,
params
=
', '
.
join
(
list_of_params
)))
else
:
code
.
append
(
u
'{};'
.
format
(
proc
.
inputString
))
code
.
append
(
u
'
p{}
{};'
.
format
(
UNICODE_SEP
,
proc
.
inputString
))
return
code
,
local_decl
...
...
@@ -1665,7 +1667,8 @@ def _inner_procedure(proc):
VARIABLES
.
update
({
var
[
'name'
]:
(
var
[
'type'
],
None
)})
# Build the procedure signature
pi_header
=
u
'procedure {proc_name}'
.
format
(
proc_name
=
proc
.
inputString
)
pi_header
=
u
'procedure p{sep}{proc_name}'
.
format
(
sep
=
UNICODE_SEP
,
proc_name
=
proc
.
inputString
)
if
proc
.
fpar
:
pi_header
+=
'('
params
=
[]
...
...
@@ -1722,7 +1725,8 @@ def _inner_procedure(proc):
code
.
append
(
'begin'
)
code
.
extend
(
tr_code
)
code
.
extend
(
code_labels
)
code
.
append
(
u
'end {procName};'
.
format
(
procName
=
proc
.
inputString
))
code
.
append
(
u
'end p{sep}{procName};'
.
format
(
sep
=
UNICODE_SEP
,
procName
=
proc
.
inputString
))
code
.
append
(
'
\n
'
)
# Reset the scope to how it was prior to the procedure definition
...
...
tests/regression/test-standalone/dataview-uniq.asn
View file @
f5899162
...
...
@@ -28,6 +28,7 @@ Type2 ::= BOOLEAN
Toto ::= SEQUENCE { elem-1 Type1, elem-2 Type2 }
SeqBool ::= SEQUENCE(SIZE(1..5)) OF BOOLEAN
Enum ::= ENUMERATED {enum1}
default-seqof SeqOf ::= {4,7,9}
default-str My-OctStr ::= 'DEADBEEF'H
...
...
tests/regression/test-standalone/og.pr
View file @
f5899162
...
...
@@ -49,6 +49,21 @@ dcl test Some_Thing := 4;
/* CIF RETURN (181, 263), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (439, 309), (70, 35) */
PROCEDURE haha
/* CIF COMMENT (529, 309), (184, 35) */
COMMENT 'same name as a variable';
ENDPROCEDURE;
/* CIF PROCEDURE (414, 353), (124, 35) */
PROCEDURE default_seqof
/* CIF COMMENT (558, 353), (189, 35) */
COMMENT 'same name as a constant';
ENDPROCEDURE;
/* CIF PROCEDURE (430, 404), (78, 35) */
PROCEDURE enum1
/* CIF COMMENT (528, 404), (206, 35) */
COMMENT 'same name as an enum item';
ENDPROCEDURE;
/* CIF START (155, 216), (70, 35) */
START;
/* CIF NEXTSTATE (155, 266), (70, 35) */
...
...
@@ -61,7 +76,13 @@ dcl test Some_Thing := 4;
CALL hehe(hihi);
/* CIF OUTPUT (286, 386), (89, 35) */
OUTPUT we(test);
/* CIF NEXTSTATE (296, 436), (70, 35) */
/* CIF PROCEDURECALL (296, 436), (70, 35) */
CALL haha;
/* CIF PROCEDURECALL (269, 486), (124, 35) */
CALL default_seqof;
/* CIF PROCEDURECALL (292, 536), (78, 35) */
CALL enum1;
/* CIF NEXTSTATE (296, 586), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS og;
...
...
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