Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taste-model-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TASTE
taste-model-checker
Commits
7ec8bc4d
Commit
7ec8bc4d
authored
Jun 22, 2018
by
Maxime Perrotin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve a bit the enumerated
parent
4aeaa78f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
22 deletions
+50
-22
asn1-iterators/src/asn1_iterators-generic_enumerated.ads
asn1-iterators/src/asn1_iterators-generic_enumerated.ads
+2
-0
asn1-iterators/stg/ada_iterators-iterators-adb.stg
asn1-iterators/stg/ada_iterators-iterators-adb.stg
+18
-9
asn1-iterators/stg/ada_iterators-iterators-ads.stg
asn1-iterators/stg/ada_iterators-iterators-ads.stg
+7
-6
asn1-iterators/test/DataView.asn
asn1-iterators/test/DataView.asn
+2
-0
asn1-iterators/test/test_generic.adb
asn1-iterators/test/test_generic.adb
+21
-7
No files found.
asn1-iterators/src/asn1_iterators-generic_enumerated.ads
View file @
7ec8bc4d
...
...
@@ -7,6 +7,8 @@ use Interfaces;
generic
type
Sort
is
(
<>
);
-- a discrete type, such as enumerated
package
ASN1_Iterators
.
Generic_Enumerated
is
-- To avoid exception with 'Succ attribute when last item is reached
-- keep a flag set to one when the iteration is finished
Is_Last
:
Boolean
:=
False
;
-- function Elem_Init return Sort is (Sort'First);
...
...
asn1-iterators/stg/ada_iterators-iterators-adb.stg
View file @
7ec8bc4d
...
...
@@ -18,9 +18,17 @@ group ada_iterators_iterators_adb;
RootXml
(
arrsFiles
)
::=
<<
--
This
file
was
generated
automatically
by
TASTE
:
DO
NOT
EDIT
with
Ada
.
Strings
,
Ada
.
Strings
.
Fixed
,
Ada
.
Characters
.
Handling
;
use
Ada
.
Strings
,
Ada
.
Strings
.
Fixed
,
Ada
.
Characters
.
Handling
;
package
body
ASN1_Ada_Iterators
.
iterators
is
$
arrsFiles
;
separator
=
"
\n
"
$
$
arrsFiles
;
separator
=
"
\n
"
$
end
;
>>
...
...
@@ -47,8 +55,8 @@ ImportedMod(sName, sCName, arrsTypes, arrsVars) ::= <<
/*
A
single
Type
Assignment
,
this
is
filled
for
all
types
of
all
modules
*/
TasXml
(
sName
,
nLine
,
nPos
,
sType
,
sCName
,
sAssigOp
,
sContract
)
::=
<<
package
body
$
sCName
$
_pkg
is
$
sType
$
$
sContract
$
$
sType
$
$
sContract
$
end
;
>>
...
...
@@ -67,7 +75,8 @@ $sSubType$
sName
may
be
Generic_Integer
or
Generic_Real
*/
MinMaxType
(
sName
,
sMin
,
sMax
,
bFixedSize
,
bIsUnsigned
,
bIsRealType
)
::=
<<
function
Image
(
Elm
:
ASN1_Type
)
return
String
is
(
Elm
'Img);
function
Image
(
Elm
:
ASN1_Type
)
return
String
is
(
Ada
.
Strings
.
Fixed
.
Trim
(
Elm
'Img, Both));
procedure To_ASN1 (From : Interfaces.$if(bIsUnsigned)$Unsigned_64$else$$if(bIsRealType)$Long_Float$else$Integer_64$endif$$endif$; To : out ASN1_Type) is
begin
...
...
@@ -119,7 +128,7 @@ EnumItem (sName, sCName, nVal, nLine, nPos, sCID) ::= <<
/* Enumerated type: arrsItems is an array of EnumItem */
EnumType(arrsItems) ::= <<
function Image (Elm : ASN1_Type) return String is (
Elm'
Img
);
function Image (Elm : ASN1_Type) return String is (
To_Lower (Elm'
Img
)
);
>>
...
...
@@ -201,23 +210,23 @@ begin
end if;
if Elm.Data'
Length
>
1
then
for
Idx
in
2
..
Elm
.
Data
'Length loop
Res := Res & "," & Image (Elm.Data (Idx));
Res := Res & ",
" & Image (Elm.Data (Idx));
end loop;
end if;
return To_String ("{" & Res & " }");
return To_String ("{
" & Res & " }");
end;
$else$
function Image_Rec (Elm : ASN1_Type) return String is
(if Elm.Length > 0 then
(Image (Elm.Data (1))
& (if Elm.Length > 1 then ","
& (if Elm.Length > 1 then ",
"
& Image_Rec (ASN1_Type'
(
Length
=>
Elm
.
Length
-
1
,
Data
=>
Elm
.
Data
(
2
..
Elm
.
Length
)
&
Elm
.
Data
(
1
..
Elm
.
Data
'Length - Elm.Length + 1)))
else ""))
else "");
begin
return "{" & Image_Rec (Elm) & " }";
return "{
" & Image_Rec (Elm) & " }";
end;
$endif$
>>
...
...
asn1-iterators/stg/ada_iterators-iterators-ads.stg
View file @
7ec8bc4d
...
...
@@ -69,10 +69,10 @@ ImportedMod(sName, sCName, arrsTypes, arrsVars) ::= <<
TasXml
(
sName
,
nLine
,
nPos
,
sType
,
sCName
,
sAssigOp
,
sContract
)
::=
<<
--
Type
"$sName$ defined at line $nLine$
package $sCName$_pkg is
subtype ASN1_Type is asn1Scc$sCName$;
package Inner is new $sType$
subtype Instance is Inner.Instance;
function Image (Elm : ASN1_Type) return String;
subtype ASN1_Type is asn1Scc$sCName$;
package Inner is new $sType$
subtype Instance is Inner.Instance;
function Image (Elm : ASN1_Type) return String;
end;
>>
...
...
@@ -92,8 +92,8 @@ $sSubType$
*/
MinMaxType(sName, sMin, sMax, bFixedSize, bIsUnsigned, bIsRealType) ::= <<
Generic_$if(bIsUnsigned)$Unsigned_$endif$$sName$ (Min => $sMin$, Max => $sMax$);
package It renames Inner.It;
procedure To_ASN1(From : Interfaces.$if(bIsUnsigned)$Unsigned_64$else$$if(bIsRealType)$Long_Float$else$Integer_64$endif$$endif$; To : out ASN1_Type);
package It renames Inner.It;
procedure To_ASN1(From : Interfaces.$if(bIsUnsigned)$Unsigned_64$else$$if(bIsRealType)$Long_Float$else$Integer_64$endif$$endif$; To : out ASN1_Type);
>>
...
...
@@ -143,6 +143,7 @@ EnumItem (sName, sCName, nVal, nLine, nPos, sCID) ::= <<
/* Enumerated type: arrsItems is an array of EnumItem */
EnumType(arrsItems) ::= <<
Generic_Enumerated (Sort => ASN1_Type);
package It renames Inner.It;
>>
...
...
asn1-iterators/test/DataView.asn
View file @
7ec8bc4d
...
...
@@ -9,6 +9,8 @@ MyVarSeqOf ::= SEQUENCE (SIZE (1..4)) OF MyInteger
MyEnum ::= ENUMERATED { hello, world, how-are-you }
MySeqOfEnum ::= SEQUENCE (SIZE (3)) OF MyEnum
--MyChoice ::= CHOICE {
-- choice-a MyInteger,
-- choice-b MySeqOf
...
...
asn1-iterators/test/test_generic.adb
View file @
7ec8bc4d
...
...
@@ -27,16 +27,19 @@ procedure test_generic is
use
MySeqOf_Pkg
;
use
MyVarSeqOf_Pkg
;
use
MyEnum_Pkg
;
use
MySeqOfEnum_Pkg
;
-- Test cases
MyIt
:
MyInteger_Pkg
.
Instance
;
Fixed_SeqOf
:
MySeqOf_Pkg
.
Instance
;
Var_SeqOf
:
MyVarSeqOf_Pkg
.
Instance
;
Enum
:
MyEnum_Pkg
.
Instance
;
MyIt
:
MyInteger_Pkg
.
Instance
;
Fixed_SeqOf
:
MySeqOf_Pkg
.
Instance
;
Var_SeqOf
:
MyVarSeqOf_Pkg
.
Instance
;
Enum
:
MyEnum_Pkg
.
Instance
;
SeqOfEnum
:
MySeqOfEnum_Pkg
.
Instance
;
SeqOfItm
:
asn1SccMySeqOf
;
VarSeqOfItm
:
asn1SccMyVarSeqOf
;
i
:
Natural
:=
1
;
SeqOfItm
:
asn1SccMySeqOf
;
VarSeqOfItm
:
asn1SccMyVarSeqOf
;
SeqOfEnumItm
:
asn1SccMySeqOfEnum
;
i
:
Natural
:=
1
;
begin
-- test: compute all possible values of the integer type
...
...
@@ -45,6 +48,7 @@ begin
--Put_Line(each'img);
Put_Line
(
Image
(
each
));
end
loop
;
-- test: compute all combinations of values for the fixed-size array
Put_Line
(
"Variable-size array:"
);
for
each
of
Var_SeqOf
loop
...
...
@@ -57,6 +61,7 @@ begin
end
loop
;
-- test: compute all combination of values for the variable-size array
New_Line
;
Put_Line
(
"Fixed-size array:"
);
i
:=
1
;
for
each
of
Fixed_SeqOf
loop
...
...
@@ -68,10 +73,19 @@ begin
end
if
;
end
loop
;
New_Line
;
Put_Line
(
"Enumerated type"
);
for
Each
of
Enum
loop
Put_Line
(
Image
(
Each
));
end
loop
;
New_Line
;
Put_Line
(
"Sequence of Enumerated type"
);
for
Each
of
SeqOfEnum
loop
To_ASN1
(
From
=>
Each
,
To
=>
SeqOfEnumItm
);
Put
(
Image
(
SeqOfEnumItm
)
&
" "
);
end
loop
;
New_Line
;
end
;
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