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
kazoo
Commits
e5c29d42
Commit
e5c29d42
authored
Jul 18, 2017
by
Maxime Perrotin
Browse files
Make connection parsing return option type
parent
b3b89882
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/option_type.ads
View file @
e5c29d42
...
...
@@ -8,7 +8,7 @@ package Option_Type is
type
Option
is
tagged
private
;
function
Just
(
I
:
T
)
return
Option
;
function
Nothing
return
Option
;
--
function Just (O : Option) return T;
function
Unsafe_
Just
(
O
:
Option
)
return
T
;
-- function Value (O : Option) return T renames Just;
function
Value_Or
(
O
:
Option
;
Default
:
T
)
return
T
;
function
Has_Value
(
O
:
Option
)
return
Boolean
;
...
...
@@ -27,7 +27,7 @@ private
function
Nothing
return
Option
is
(
Present
=>
False
,
others
=>
<>
);
--
function Just (O : Option) return T is (O.Value);
function
Unsafe_
Just
(
O
:
Option
)
return
T
is
(
O
.
Value
);
function
Value_Or
(
O
:
Option
;
Default
:
T
)
return
T
is
(
if
O
.
Present
then
O
.
Value
else
Default
);
...
...
src/parser_utils.adb
View file @
e5c29d42
...
...
@@ -411,25 +411,33 @@ package body Parser_Utils is
Current_Function
:
Node_Id
;
-- Parse a connection
function
Parse_Connection
(
Conn
:
Node_Id
)
return
Connection
is
function
Parse_Connection
(
Conn
:
Node_Id
)
return
Optional_Connection
is
use
Option_Connection
;
Caller
:
constant
Node_Id
:=
AIN
.
Item
(
AIN
.
First_Node
(
AIN
.
Path
(
AIN
.
Destination
(
Conn
))));
Callee
:
constant
Node_Id
:=
AIN
.
Item
(
AIN
.
First_Node
(
AIN
.
Path
(
AIN
.
Source
(
Conn
))));
PI_Name
:
constant
Name_Id
:=
Get_Interface_Name
(
Get_Referenced_Entity
(
AIN
.
Source
(
Conn
)));
PI_Name
:
Name_Id
;
-- None in case of cyclic interface
RI_Name
:
constant
Name_Id
:=
Get_Interface_Name
(
Get_Referenced_Entity
(
AIN
.
Destination
(
Conn
)));
begin
-- Put_Line (AIN.Node_Kind'Image (Kind (Caller)));
return
Connection
'(
Caller
=>
-- Filter out connections if the PI is cyclic (not a connection!)
if
Get_RCM_Operation_Kind
(
Caller
)
=
Cyclic_Operation
then
return
Nothing
;
end
if
;
PI_Name
:=
Get_Interface_Name
(
Get_Referenced_Entity
(
AIN
.
Source
(
Conn
)));
return
Just
(
Connection
'(
Caller
=>
(
if
Kind
(
Caller
)
=
K_Subcomponent_Access_Instance
then
US
(
"_env"
)
else
US
(
AIN_Case
(
Caller
))),
Callee
=>
(
if
Kind
(
Callee
)
=
K_Subcomponent_Access_Instance
then
US
(
"_env"
)
else
US
(
AIN_Case
(
Callee
))),
PI_Name
=>
US
(
Get_Name_String
(
PI_Name
)),
RI_Name
=>
US
(
Get_Name_String
(
RI_Name
)));
RI_Name
=>
US
(
Get_Name_String
(
RI_Name
)))
)
;
end
Parse_Connection
;
-- Create a vector of connections for a given system
...
...
@@ -438,13 +446,18 @@ package body Parser_Utils is
function
Parse_System_Connections
(
System
:
Node_Id
)
return
Channels
.
Vector
is
Conn
:
Node_Id
;
Result
:
Channels
.
Vector
;
use
Option_Connection
;
Conn
:
Node_Id
;
Result
:
Channels
.
Vector
;
Opt_Conn
:
Optional_Connection
;
begin
if
Present
(
AIN
.
Connections
(
System
))
then
Conn
:=
AIN
.
First_Node
(
AIN
.
Connections
(
System
));
while
Present
(
Conn
)
loop
Result
:=
Result
&
Parse_Connection
(
Conn
);
Opt_Conn
:=
Parse_Connection
(
Conn
);
if
Opt_Conn
.
Has_Value
then
Result
:=
Result
&
Opt_Conn
.
Unsafe_Just
;
end
if
;
Conn
:=
AIN
.
Next_Node
(
Conn
);
end
loop
;
end
if
;
...
...
src/parser_utils.ads
View file @
e5c29d42
...
...
@@ -172,7 +172,10 @@ package Parser_Utils is
Callee
:
Unbounded_String
;
RI_Name
:
Unbounded_String
;
PI_Name
:
Unbounded_String
;
end
record
;
end
record
;
package
Option_Connection
is
new
Option_Type
(
Connection
);
subtype
Optional_Connection
is
Option_Connection
.
Option
;
package
Channels
is
new
Indefinite_Vectors
(
Natural
,
Connection
);
package
Connection_Maps
is
new
Indefinite_Ordered_Maps
(
String
,
...
...
src/parser_version.ads
View file @
e5c29d42
package
Parser_Version
is
Parser_Release
:
constant
String
:=
"
2c4ef76
; Commit Date: S
at
Jul 1
5
1
8:25:37
2017 "
;
"
b3b8988
; Commit Date: S
un
Jul 1
6
1
9:13:52
2017 "
;
Ocarina_Version
:
constant
String
:=
"Ocarina 2017.x (Working Copy from r0338d89)"
;
end
Parser_Version
;
\ No newline at end of file
test/test1/Makefile
View file @
e5c29d42
AADL_PARSER
=
../../aadl_parser
all
:
build
all
:
test-parse
test-parse
:
$(AADL_PARSER)
-glue
-i
interfaceview.aadl
-c
deploymentview.aadl
-d
dataview.aadl ../common/ocarina_components.aadl ../common/TASTE_DV_Properties.aadl
...
...
test/test2/Makefile
View file @
e5c29d42
AADL_PARSER
=
../../aadl_parser
all
:
build
all
:
test-parse
test-parse
:
$(AADL_PARSER)
-gw
-i
InterfaceView.aadl
-d
DataView.aadl ../common/TASTE_IV_Properties.aadl
...
...
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