Commit 224b89b1 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix bug with empty sequence/string assignment

parent 1c9bd93f
......@@ -144,6 +144,7 @@ Changelog
1.3.18 (04/2016)
- Add support for value notation of NULL type
- Remove warning when accessing CHOICE fields
1.3.17 (04/2016)
- Add support for value notation of empty SEQUENCEs ("{}")
......
......@@ -2293,6 +2293,8 @@ def array_content(prim, values, asnty):
inputs: prim is of type PrimStringLiteral or PrimSequenceOf
values is a string with the sequence of numbers as processed by expression
asnty is the reference type of the string literal '''
if isinstance(prim, ogAST.PrimEmptyString):
return values
if asnty.Min != asnty.Max:
length = len(prim.value)
if isinstance(prim, ogAST.PrimStringLiteral):
......
......@@ -1736,6 +1736,7 @@ def primary(root, context):
# Primary "{ }" used in empty SEQUENCE OF (i.e. "{}")
# and also in value notation of SEQUENCEs that have no fields
prim = ogAST.PrimEmptyString()
prim.value = []
prim.exprType = type('PrES', (object,), {
'kind': 'SequenceOfType',
'Min': '0',
......@@ -1840,7 +1841,10 @@ def variables(root, ta_ast, context):
expr.right.inputString + ', type= ' +
type_name(expr.right.exprType) + ') ' + str(err))
else:
if def_value.exprType == UNKNOWN_TYPE:
if def_value.exprType == UNKNOWN_TYPE or not \
isinstance(def_value, (ogAST.ExprAppend,
ogAST.PrimSequenceOf,
ogAST.PrimStringLiteral)):
def_value.exprType = asn1_sort
def_value.expected_type = asn1_sort
......
......@@ -2,6 +2,7 @@ TASTE-Dataview DEFINITIONS ::=
BEGIN
EmptySeq ::= SEQUENCE {}
SeqOf ::= SEQUENCE (SIZE(0..10)) OF BOOLEAN
AnotherEmptySeq ::= SEQUENCE {}
......
......@@ -16,7 +16,7 @@ signal we;
FROM ENV TO og WITH dd;
FROM og TO ENV WITH we;
CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */
/* CIF PROCESS (225, 50), (150, 75) */
PROCESS og;
/* CIF TEXT (56, 58), (337, 130) */
-- Test choice assignments and access
......@@ -24,17 +24,21 @@ signal we;
dcl ch ChoiceWithEmptySeq := a: NULL;
dcl em EmptySeq := {};
dcl eso SeqOf := {};
/* CIF ENDTEXT */
/* CIF START (160, 226), (70, 35) */
START;
/* CIF TASK (148, 276), (93, 35) */
/* CIF TASK (146, 276), (98, 35) */
TASK ch := b: {};
/* CIF TASK (144, 326), (100, 35) */
/* CIF TASK (152, 326), (85, 35) */
TASK eso := {};
/* CIF TASK (142, 376), (106, 35) */
TASK em := ch!b
/* CIF COMMENT (261, 324), (175, 40) */
/* CIF COMMENT (264, 374), (177, 40) */
COMMENT 'This is ok, there should
be no warning raised';
/* CIF NEXTSTATE (160, 376), (70, 35) */
/* CIF NEXTSTATE (160, 426), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (460, 231), (70, 35) */
STATE wait;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment