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
f1746aa7
Commit
f1746aa7
authored
Apr 14, 2014
by
Maxime Perrotin
Browse files
Nested states and C/Ada interface
parent
ead6784b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
f1746aa7
...
...
@@ -204,10 +204,13 @@ def _process(process):
# Add the declaration of the runTransition procedure
process_level_decl
.
append
(
'procedure runTransition(Id: Integer);'
)
process_level_decl
.
append
(
'procedure start;'
)
process_level_decl
.
append
(
'pragma export(C, start, "{}_start");'
.
format
(
process_name
))
# Generate the code of the start transition:
start_transition
=
[
'begin'
]
start_transition
.
append
(
'
runTransition(0)
;'
)
start_transition
.
append
(
'
start
;'
)
mapping
=
{}
...
...
@@ -268,6 +271,13 @@ package {process_name} is'''.format(process_name=process_name,
# Generate the code for the process-level variable declarations
taste_template
.
extend
(
process_level_decl
)
# Generate the code for the start procedure
taste_template
.
extend
([
'procedure start is'
,
'begin'
,
'runTransition(0);'
,
'end start;'
,
''
])
# Add the code of the procedures definitions
taste_template
.
extend
(
inner_procedures_code
)
...
...
@@ -287,6 +297,8 @@ package {process_name} is'''.format(process_name=process_name,
# Add declaration of the provided interface in the .ads file
ads_template
.
append
(
'-- Provided interface "'
+
signal
[
'name'
]
+
'"'
)
ads_template
.
append
(
pi_header
+
';'
)
ads_template
.
append
(
'pragma export(C, {name}, "{proc}_{name}");'
.
format
(
name
=
signal
[
'name'
],
proc
=
process_name
))
pi_header
+=
' is'
taste_template
.
append
(
pi_header
)
...
...
Clipboard.py
View file @
f1746aa7
...
...
@@ -42,8 +42,8 @@ def copy(selection):
# When several items are selected, take the first of each subbranch
if
item
.
hasParent
and
not
item
.
parentItem
().
grabber
.
isSelected
():
branch_top_level
.
append
(
item
)
elif
not
item
.
hasParent
:
# and not item.is_singleton:
# Take also floating items
//, if they allow for copy (e.g. not START)
elif
not
item
.
hasParent
:
# Take also floating items
floating_items
.
append
(
item
)
# Check if selected items would allow a paste - reject copy otherwise
# e.g. floating and non-floating items cannot be pasted together
...
...
@@ -102,10 +102,7 @@ def paste(parent, scene):
'''
CLIPBOARD
.
clear
()
if
not
parent
:
try
:
new_symbols
=
paste_floating_objects
(
scene
)
except
TypeError
:
raise
new_symbols
=
paste_floating_objects
(
scene
)
else
:
new_symbols
=
paste_below_item
(
parent
,
scene
)
return
new_symbols
...
...
@@ -127,7 +124,8 @@ def paste_floating_objects(scene):
try
:
new_item
=
Renderer
.
render
(
state
,
scene
=
CLIPBOARD
,
terminators
=
terminators
,
states
=
states
)
except
TypeError
:
except
TypeError
as
err
:
LOG
.
debug
(
'No paste "'
+
state
.
inputString
+
'" -'
+
str
(
err
))
# Discard terminators (explanation given in Renderer._state)
pass
else
:
...
...
ogParser.py
View file @
f1746aa7
...
...
@@ -2669,7 +2669,7 @@ def task(root, parent=None, context=None):
errors
=
[]
warnings
=
[]
coord
=
False
comment
=
None
comment
,
body
=
None
,
None
for
child
in
root
.
getChildren
():
if
child
.
type
==
lexer
.
CIF
:
# Get symbol coordinates
...
...
@@ -2690,12 +2690,16 @@ def task(root, parent=None, context=None):
warnings
.
append
(
'Unsupported child type in task definition: '
+
str
(
child
.
type
))
# Report errors with symbol coordinates
if
coord
:
if
coord
and
body
:
body
.
pos_x
,
body
.
pos_y
,
body
.
width
,
body
.
height
=
\
pos_x
,
pos_y
,
width
,
height
errors
=
[[
e
,
[
pos_x
,
pos_y
]]
for
e
in
errors
]
warnings
=
[[
w
,
[
pos_x
,
pos_y
]]
for
w
in
warnings
]
body
.
comment
=
comment
if
body
:
body
.
comment
=
comment
else
:
warnings
.
append
(
'TASK missing content'
)
body
=
ogAST
.
TaskAssign
()
return
body
,
errors
,
warnings
...
...
opengeode.py
View file @
f1746aa7
...
...
@@ -990,7 +990,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
item
.
edit_text
()
for
view
in
self
.
views
():
view
.
viewport
().
update
()
view
.
refresh
()
view
.
ensureVisible
(
item
)
return
item
...
...
@@ -1083,7 +1083,9 @@ class SDL_View(QtGui.QGraphicsView, object):
self
.
lander_scene
.
setSceneRect
(
0
,
0
,
self
.
width
(),
self
.
height
())
if
not
self
.
lander
:
self
.
lander
=
Lander
.
Lander
(
self
.
lander_scene
)
self
.
parent_scene
.
append
(
self
.
scene
())
horpos
=
self
.
horizontalScrollBar
().
value
()
verpos
=
self
.
verticalScrollBar
().
value
()
self
.
parent_scene
.
append
((
self
.
scene
(),
horpos
,
verpos
))
self
.
scene
().
clear_focus
()
self
.
setScene
(
self
.
lander_scene
)
self
.
up_button
.
setEnabled
(
True
)
...
...
@@ -1169,15 +1171,22 @@ class SDL_View(QtGui.QGraphicsView, object):
self
.
scene
().
clear_focus
()
# Scene may need to be informed when it is left:
self
.
scene
().
scene_left
.
emit
()
self
.
setScene
(
self
.
parent_scene
.
pop
())
scene
,
horpos
,
verpos
=
self
.
parent_scene
.
pop
()
self
.
setScene
(
scene
)
self
.
horizontalScrollBar
().
setSliderPosition
(
horpos
)
self
.
verticalScrollBar
().
setSliderPosition
(
verpos
)
self
.
set_toolbar
()
if
not
self
.
parent_scene
:
self
.
up_button
.
setEnabled
(
False
)
self
.
refresh
()
self
.
horizontalScrollBar
().
setSliderPosition
(
horpos
)
self
.
verticalScrollBar
().
setSliderPosition
(
verpos
)
def
go_down
(
self
,
scene
):
''' Enter a nested diagram (procedure, composite state) '''
self
.
parent_scene
.
append
(
self
.
scene
())
horpos
=
self
.
horizontalScrollBar
().
value
()
verpos
=
self
.
verticalScrollBar
().
value
()
self
.
parent_scene
.
append
((
self
.
scene
(),
horpos
,
verpos
))
self
.
scene
().
clear_focus
()
self
.
setScene
(
scene
)
self
.
up_button
.
setEnabled
(
True
)
...
...
@@ -1229,6 +1238,10 @@ class SDL_View(QtGui.QGraphicsView, object):
# pylint: disable=C0103
def
mouseReleaseEvent
(
self
,
evt
):
self
.
mode
=
''
# Adjust scrollbars if diagram got bigger due to a move
if
self
.
scene
().
context
!=
'statechart'
:
# Make sure scene size remains OK when adding/moving symbols
self
.
refresh
()
super
(
SDL_View
,
self
).
mouseReleaseEvent
(
evt
)
def
save_as
(
self
):
...
...
@@ -1257,7 +1270,7 @@ class SDL_View(QtGui.QGraphicsView, object):
'process '
+
self
.
scene
().
process_name
+
'[*]'
)
# If the current scene is a nested one, save the top parent
if
self
.
parent_scene
:
scene
=
self
.
parent_scene
[
0
]
scene
=
self
.
parent_scene
[
0
]
[
0
]
else
:
scene
=
self
.
scene
()
pr_raw
=
scene
.
get_pr_string
()
...
...
@@ -1386,7 +1399,7 @@ class SDL_View(QtGui.QGraphicsView, object):
''' Parse the model and check for warnings and errors '''
# If the current scene is a nested one, save the top parent
if
self
.
parent_scene
:
scene
=
self
.
parent_scene
[
0
]
scene
=
self
.
parent_scene
[
0
]
[
0
]
else
:
scene
=
self
.
scene
()
pr_raw
=
scene
.
get_pr_string
()
...
...
@@ -1400,7 +1413,7 @@ class SDL_View(QtGui.QGraphicsView, object):
''' Generate Ada code '''
# If the current scene is a nested one, save the top parent
if
self
.
parent_scene
:
scene
=
self
.
parent_scene
[
0
]
scene
=
self
.
parent_scene
[
0
]
[
0
]
else
:
scene
=
self
.
scene
()
pr_raw
=
scene
.
get_pr_string
()
...
...
sdl92Lexer.py
View file @
f1746aa7
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-04-
06 20:42:56
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-04-
10 09:59:44
import
sys
from
antlr3
import
*
...
...
sdl92Parser.py
View file @
f1746aa7
This diff is collapsed.
Click to expand it.
tests/regression/test10/test.c
0 → 100644
View file @
f1746aa7
#include
<math.h>
#include
<stdio.h>
/* Ada code external interface */
extern
void
challenge_start
();
extern
void
challenge_run
();
/* Provide code called by the Ada state machine as external procedure */
void
challenge_RI_pow
(
long
long
*
a
,
long
long
*
b
,
long
long
*
res
)
{
*
res
=
(
long
long
)
pow
((
double
)
*
a
,
(
double
)
*
b
);
}
int
main
()
{
printf
(
"[C Code] Calling START
\n
"
);
challenge_start
();
printf
(
"[C Code] Calling RUN
\n
"
);
challenge_run
();
printf
(
"[C Code] Calling RUN AGAIN....
\n
"
);
challenge_run
();
return
0
;
}
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