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
556f732c
Commit
556f732c
authored
Aug 09, 2014
by
dbarbera
Browse files
Merge remote-tracking branch 'upstream/master' into llvm
parents
ca03c19c
6ccdef40
Changes
8
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
556f732c
...
...
@@ -758,7 +758,8 @@ def _prim_call(prim):
param_stmts
,
param_str
,
local_var
=
expression
(
exp
)
stmts
.
extend
(
param_stmts
)
local_decl
.
extend
(
local_var
)
if
min_length
==
max_length
:
if
min_length
==
max_length
\
and
not
isinstance
(
exp
,
ogAST
.
PrimSubstring
):
ada_string
+=
min_length
else
:
if
isinstance
(
exp
,
ogAST
.
PrimSubstring
):
...
...
@@ -830,7 +831,9 @@ def _prim_index(prim):
idx_string
=
int
(
idx_string
)
+
1
else
:
idx_string
=
'1+Integer({idx})'
.
format
(
idx
=
idx_string
)
ada_string
+=
'.Data({idx})'
.
format
(
idx
=
idx_string
)
if
not
isinstance
(
receiver
,
ogAST
.
PrimSubstring
):
ada_string
+=
'.Data'
ada_string
+=
'({idx})'
.
format
(
idx
=
idx_string
)
stmts
.
extend
(
idx_stmts
)
local_decl
.
extend
(
idx_var
)
...
...
@@ -862,7 +865,9 @@ def _prim_substring(prim):
else
:
r2_string
+=
' + 1'
ada_string
+=
'.Data({r1}..{r2})'
.
format
(
r1
=
r1_string
,
r2
=
r2_string
)
if
not
isinstance
(
receiver
,
ogAST
.
PrimSubstring
):
ada_string
+=
'.Data'
ada_string
+=
'({r1}..{r2})'
.
format
(
r1
=
r1_string
,
r2
=
r2_string
)
stmts
.
extend
(
r1_stmts
)
stmts
.
extend
(
r2_stmts
)
local_decl
.
extend
(
r1_local
)
...
...
Renderer.py
View file @
556f732c
...
...
@@ -279,8 +279,8 @@ def _decision(ast, scene, parent, states):
if
not
parent
:
symbol
.
setPos
(
ast
.
pos_x
,
ast
.
pos_y
)
for
branch
in
ast
.
answers
:
render
(
branch
,
scene
=
scene
,
parent
=
symbol
,
states
=
states
)
render
(
branch
,
scene
=
scene
,
parent
=
symbol
,
states
=
states
)
symbol
.
updateConnectionPointPosition
(
)
return
symbol
...
...
@@ -300,8 +300,7 @@ def _answer(ast, scene, parent, states):
if
not
parent
:
symbol
.
setPos
(
ast
.
pos_x
,
ast
.
pos_y
)
if
ast
.
transition
:
render
(
ast
.
transition
,
scene
=
scene
,
parent
=
symbol
,
states
=
states
)
render
(
ast
.
transition
,
scene
=
scene
,
parent
=
symbol
,
states
=
states
)
return
symbol
...
...
genericSymbols.py
View file @
556f732c
...
...
@@ -899,9 +899,9 @@ class Symbol(QObject, QGraphicsPathItem, object):
# Minimum size is the size of the text inside the symbol
try
:
height
=
max
(
user_height
,
self
.
text
.
boundingRect
().
height
()
+
10
)
self
.
text
.
boundingRect
().
height
()
+
10
)
width
=
max
(
user_width
,
self
.
text
.
boundingRect
().
width
()
+
30
)
self
.
text
.
boundingRect
().
width
()
+
30
)
except
AttributeError
:
height
=
max
(
user_height
,
15
)
width
=
max
(
user_width
,
30
)
...
...
@@ -1327,6 +1327,8 @@ class HorizontalSymbol(Symbol, object):
self
.
connection
=
self
.
connect_to_parent
()
self
.
updateConnectionPoints
()
self
.
cam
(
self
.
pos
(),
self
.
pos
())
LOG
.
debug
(
'{} positionned at {}'
.
format
(
unicode
(
self
),
unicode
(
self
.
scenePos
())))
def
update_connections
(
self
):
'''
...
...
@@ -1470,8 +1472,6 @@ class VerticalSymbol(Symbol, object):
Determine the coordinates based on the position
and size of the parent item, and make proper connections
'''
LOG
.
debug
(
'insert_symbol: '
+
unicode
(
self
)
+
' at '
+
unicode
(
x
)
+
', '
+
unicode
(
y
))
if
not
parent
:
# Place standalone item on the scene at given coordinates
# (e.g. floating state)
...
...
@@ -1533,11 +1533,12 @@ class VerticalSymbol(Symbol, object):
# Create the connection with the parent symbol
self
.
connection
=
self
.
connect_to_parent
()
self
.
update_position
()
LOG
.
debug
(
unicode
(
self
)
+
' positionned at '
+
unicode
(
self
.
pos
()))
self
.
updateConnectionPoints
()
if
y
is
not
None
:
self
.
setY
(
y
)
self
.
cam
(
self
.
pos
(),
self
.
pos
())
LOG
.
debug
(
'{} positionned at {}'
.
format
(
unicode
(
self
),
unicode
(
self
.
scenePos
())))
def
update_position
(
self
):
'''
...
...
ogParser.py
View file @
556f732c
...
...
@@ -133,6 +133,14 @@ type_name = lambda t: \
types
=
lambda
:
getattr
(
DV
,
'types'
,
{})
def
substring_range
(
substring
):
''' Return the range of a substring '''
left
,
right
=
substring
.
value
[
1
][
'substring'
]
left_bty
=
find_basic_type
(
left
.
exprType
)
right_bty
=
find_basic_type
(
right
.
exprType
)
return
left_bty
.
Min
,
right_bty
.
Max
def
is_integer
(
ty
):
''' Return true if a type is an Integer Type '''
return
find_basic_type
(
ty
).
kind
in
(
...
...
@@ -1434,7 +1442,22 @@ def primary_index(root, context):
node
.
value
=
[
receiver
,
{
'index'
:
params
}]
if
receiver_bty
.
kind
==
'SequenceOfType'
:
# Range check
if
isinstance
(
receiver
,
ogAST
.
PrimSubstring
):
r_min
,
r_max
=
substring_range
(
receiver
)
else
:
r_min
,
r_max
=
receiver_bty
.
Min
,
receiver_bty
.
Max
node
.
exprType
=
receiver_bty
.
type
idx_bty
=
find_basic_type
(
params
[
0
].
exprType
)
if
not
is_integer
(
idx_bty
):
errors
.
append
(
error
(
root
,
'Index is not an integer'
))
else
:
if
float
(
idx_bty
.
Min
)
<
float
(
r_min
)
or
\
float
(
idx_bty
.
Max
)
>=
float
(
r_max
):
errors
.
append
(
error
(
root
,
'Index outside of range [{} .. <{}]'
.
format
(
r_min
,
r_max
)))
else
:
msg
=
'Index can only be applied to type SequenceOf'
errors
.
append
(
error
(
root
,
msg
))
...
...
sdlSymbols.py
View file @
556f732c
...
...
@@ -242,6 +242,7 @@ class Decision(VerticalSymbol):
def
updateConnectionPointPosition
(
self
):
''' Compute the joining point of decision branches '''
LOG
.
debug
(
'UpdateConnectionPointPosition of {}'
.
format
(
unicode
(
self
)))
new_y
=
0
new_x
=
self
.
boundingRect
().
width
()
/
2.0
answers
=
False
...
...
tests/regression/test-substrings/dataview-uniq.asn
View file @
556f732c
...
...
@@ -44,6 +44,9 @@ SeqBool2 ::= SEQUENCE (SIZE(1..2)) OF BOOLEAN
MyOctStr ::= OCTET STRING (SIZE (3))
String ::= OCTET STRING (SIZE(0..100))
IntSeq ::= SEQUENCE (SIZE(0..100)) OF T-UInt8
FixedIntSeq ::= SEQUENCE (SIZE(5)) OF T-UInt8
-- You can also declare variables (they will be visible in C, Ada and SDL)
myVar MySeqOf ::= { hello, world }
...
...
tests/regression/test-substrings/expected
View file @
556f732c
[C Code] Running test
0
0
1
2
2
TRUE
TRUE
Hello
...
...
tests/regression/test-substrings/myfunction.pr
View file @
556f732c
/* CIF PROCESS (
200
, 14
3
), (150, 75) */
/* CIF PROCESS (
197
, 14
6
), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (0, 133), (282, 136) */
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF TEXT (0, 133), (282, 216) */
dcl str MyOctStr := 'abc';
dcl variable_str String := 'Hello!';
...
...
@@ -9,9 +12,10 @@ dcl seqof MySeqOf := {hello, world};
dcl seqint seqInt := {1};
dcl seqbool seqBool := { true, false};
dcl seqbool2 seqBool2 := { true, false};
/* CIF ENDTEXT */
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
dcl iseq IntSeq := {0,1,2,3};
dcl fixedseq FixedIntSeq := {0,1,2,3,4};
dcl n t_UInt8;
/* CIF ENDTEXT */
/* CIF PROCEDURE (1416, 490), (91, 35) */
PROCEDURE factorial;
...
...
@@ -30,142 +34,169 @@ endfor;
/* CIF RETURN (315, 201), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (
104
, 27
3
), (65, 37) */
/* CIF START (
353
, 2
1
7), (65, 37) */
START;
/* CIF TASK (60, 325), (151, 35) */
/* CIF TASK (319, 269), (131, 35) */
TASK n := iseq(0,2)(0);
/* CIF PROCEDURECALL (335, 319), (100, 35) */
CALL writeln(n)
/* CIF COMMENT (455, 319), (77, 35) */
COMMENT 'print 0';
/* CIF TASK (306, 369), (158, 40) */
TASK iseq := iseq(0,3)(0,2);
/* CIF TASK (316, 424), (138, 56) */
TASK for x in iseq:
call writeln(x);
endfor
/* CIF COMMENT (494, 420), (81, 72) */
COMMENT 'print
0
1
2';
/* CIF TASK (289, 495), (192, 35) */
TASK n := length(fixedseq(0,1));
/* CIF PROCEDURECALL (335, 545), (100, 35) */
CALL writeln(n)
/* CIF COMMENT (455, 545), (83, 35) */
COMMENT 'print 2';
/* CIF TASK (309, 595), (151, 35) */
TASK seqof := seqof(0,1)
/* CIF COMMENT (
23
2,
32
5), (208, 35) */
/* CIF COMMENT (
48
2,
59
5), (208, 35) */
COMMENT 'equivalent to seqof := seqof';
/* CIF DECISION (75, 375), (123, 50) */
/* CIF TASK (303, 645), (165, 35) */
TASK n := iseq(0,2)(0,1)(0);
/* CIF TASK (314, 695), (141, 35) */
TASK n := iseq(100- 1);
/* CIF DECISION (324, 745), (123, 50) */
DECISION hello in seqof
/* CIF COMMENT (
218, 37
6), (179, 53) */
/* CIF COMMENT (
467, 74
6), (179, 53) */
COMMENT 'Check IN operator with
enumerated type';
/* CIF ANSWER (
4, 44
5), (70, 24) */
/* CIF ANSWER (
242, 81
5), (70, 24) */
(true):
/* CIF PROCEDURECALL (
-49, 48
4), (177, 35) */
/* CIF PROCEDURECALL (
188, 85
4), (177, 35) */
CALL writeln(hello in seqof)
/* CIF COMMENT (
148, 48
4), (114, 35) */
/* CIF COMMENT (
386, 85
4), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (
267, 44
5), (70, 24) */
/* CIF ANSWER (
505, 81
5), (70, 24) */
(false):
ENDDECISION;
/* CIF DECISION (
59, 53
4), (155, 50) */
/* CIF DECISION (
308, 90
4), (155, 50) */
DECISION hello in seqof(0,0)
/* CIF COMMENT (
242, 507
), (236, 56) */
/* CIF COMMENT (
479, 865
), (236, 56) */
COMMENT 'Check IN operator with
list substring - first element only
should go to branch TRUE';
/* CIF ANSWER (
6, 567
), (66, 33) */
/* CIF ANSWER (
232, 929
), (66, 33) */
(true):
/* CIF PROCEDURECALL (
-60, 615
), (201, 35) */
/* CIF PROCEDURECALL (
165, 977
), (201, 35) */
CALL writeln(hello in seqof(0,1))
/* CIF COMMENT (
162, 615
), (114, 35) */
/* CIF COMMENT (
400, 977
), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (
284, 568
), (70, 24) */
/* CIF ANSWER (
522, 929
), (70, 24) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (
40, 665
), (191, 35) */
/* CIF PROCEDURECALL (
289, 1027
), (191, 35) */
CALL writeln(variable_str(0,4))
/* CIF COMMENT (
243, 610
), (113, 35) */
/* CIF COMMENT (
496, 988
), (113, 35) */
COMMENT 'print "Hello"';
/* CIF TASK (
48, 715
), (176, 56) */
/* CIF TASK (
297, 1077
), (176, 56) */
TASK for x in seqof:
call writeln(num(x));
endfor
/* CIF COMMENT (
242, 668
), (96, 56) */
/* CIF COMMENT (
498, 1039
), (96, 56) */
COMMENT 'print:
12
13';
/* CIF TASK (
46, 786
), (180, 56) */
/* CIF TASK (
295, 1148
), (180, 56) */
TASK for x in seqof(0,1):
call writeln(-num(x));
endfor
/* CIF COMMENT (
244, 732
), (96, 56) */
/* CIF COMMENT (
502, 1116
), (96, 56) */
COMMENT 'print:
-12
-13';
/* CIF PROCEDURECALL (
46, 857
), (180, 35) */
/* CIF PROCEDURECALL (
295, 1219
), (180, 35) */
CALL writeln(length(seqof))
/* CIF COMMENT (
246, 817
), (77, 35) */
/* CIF COMMENT (
507, 1180
), (77, 35) */
COMMENT 'print 2';
/* CIF PROCEDURECALL (
32, 907
), (209, 35) */
/* CIF PROCEDURECALL (
281, 1269
), (209, 35) */
CALL writeln(length(seqof(0,1)))
/* CIF COMMENT (
261, 86
7), (77, 35) */
/* CIF COMMENT (
516, 123
7), (77, 35) */
COMMENT 'print 2';
/* CIF LABEL (
55, 957
), (162, 35) */
/* CIF LABEL (
304, 1319
), (162, 35) */
variable_length_seq:
/* CIF TASK (
65, 1007
), (142, 56) */
/* CIF TASK (
314, 1369
), (142, 56) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (
227, 953
), (96, 53) */
/* CIF COMMENT (
488, 1331
), (96, 53) */
COMMENT 'print:
1';
/* CIF TASK (
60, 1078
), (152, 56) */
/* CIF TASK (
309, 1440
), (152, 56) */
TASK for x in seqint(0,0):
call writeln(x);
endfor
/* CIF COMMENT (
232, 1024
), (96, 53) */
/* CIF COMMENT (
473, 1412
), (96, 53) */
COMMENT 'print:
1';
/* CIF DECISION (
75, 1149
), (123, 50) */
/* CIF DECISION (
324, 1511
), (123, 50) */
DECISION 1 in seqint
/* CIF COMMENT (
217, 1099
), (179, 53) */
/* CIF COMMENT (
470, 1470
), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (
5, 1191
), (66, 33) */
/* CIF ANSWER (
228, 1536
), (66, 33) */
(true):
/* CIF PROCEDURECALL (
-49, 1239
), (177, 35) */
/* CIF PROCEDURECALL (
173, 1584
), (177, 35) */
CALL writeln(1 in seqint)
/* CIF COMMENT (
149, 1239
), (114, 35) */
/* CIF COMMENT (
382, 1584
), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (
265, 1191
), (70, 24) */
/* CIF ANSWER (
497, 1536
), (70, 24) */
(false):
ENDDECISION;
/* CIF DECISION (
72, 1289
), (128, 50) */
/* CIF DECISION (
321, 1634
), (128, 50) */
DECISION 1 in seqint(0,0)
/* CIF COMMENT (
21
9, 1
239
), (179, 53) */
/* CIF COMMENT (
45
9, 1
594
), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (
5, 1331
), (70, 24) */
/* CIF ANSWER (
234, 1659
), (70, 24) */
(true):
/* CIF PROCEDURECALL (
-51, 1370
), (182, 35) */
/* CIF PROCEDURECALL (
177, 1698
), (182, 35) */
CALL writeln(1 in seqint(0,0))
/* CIF COMMENT (
151, 1370
), (114, 35) */
/* CIF COMMENT (
382, 1698
), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (
266, 1331
), (70, 24) */
/* CIF ANSWER (
497, 1659
), (70, 24) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (
46, 1420
), (180, 35) */
/* CIF PROCEDURECALL (
295, 1748
), (180, 35) */
CALL writeln(length(seqint))
/* CIF COMMENT (
246, 1380
), (77, 35) */
/* CIF COMMENT (
497, 1709
), (77, 35) */
COMMENT 'print 1';
/* CIF PROCEDURECALL (
30, 1470
), (212, 35) */
/* CIF PROCEDURECALL (
279, 1798
), (212, 35) */
CALL writeln(length(seqint(0,0)))
/* CIF COMMENT (
262, 1430
), (77, 35) */
/* CIF COMMENT (
516, 1764
), (77, 35) */
COMMENT 'print 1';
/* CIF TASK (
54, 1520
), (163, 35) */
/* CIF TASK (
303, 1848
), (163, 35) */
TASK seqint := seqint // {2};
/* CIF TASK (
41, 1570
), (190, 35) */
/* CIF TASK (
290, 1898
), (190, 35) */
TASK seqint := seqint(0,0) // {5};
/* CIF TASK (
65, 1620
), (142, 56) */
/* CIF TASK (
314, 1948
), (142, 56) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (
229, 1590
), (96, 56) */
/* CIF COMMENT (
494, 1911
), (96, 56) */
COMMENT 'print:
1
5';
/* CIF TASK (2
0, 1691
), (233, 35) */
/* CIF TASK (2
69, 2019
), (233, 35) */
TASK seqbool := seqbool and seqbool
/* CIF COMMENT (27
3
, 1
675
), (194, 35) */
/* CIF COMMENT (
5
27, 1
979
), (194, 35) */
COMMENT 'should not raise any error';
/* CIF TASK (
7, 1741
), (258, 38) */
/* CIF TASK (
256, 2069
), (258, 38) */
TASK 'seqbool2 := seqbool2 and seqbool2'
/* CIF COMMENT (
285, 1737
), (213, 35) */
/* CIF COMMENT (
537, 2033
), (213, 35) */
COMMENT 'Variable-length -> raise error';
/* CIF NEXTSTATE (
101, 1794
), (68, 33) */
/* CIF NEXTSTATE (
339, 2122
), (68, 33) */
NEXTSTATE Wait;
/* CIF STATE (839, 313), (70, 35) */
STATE wait;
...
...
Write
Preview
Markdown
is supported
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