Commit 939f66c9 authored by Maxime Perrotin's avatar Maxime Perrotin

Fix missing expected_types in SEQOF

parent 84ed9813
......@@ -70,6 +70,7 @@
import logging
import traceback
from singledispatch import singledispatch
import ogAST
......@@ -1622,8 +1623,7 @@ def _sequence_of(seqof):
seqof_ty = seqof.exprType
try:
asn_type = find_basic_type(TYPES[seqof_ty.ReferencedTypeName].type)
min_size = asn_type.Min
max_size = asn_type.Max
min_size, max_size = asn_type.Min, asn_type.Max
except AttributeError:
asn_type = None
min_size, max_size = seqof_ty.Min, seqof_ty.Max
......@@ -1634,7 +1634,6 @@ def _sequence_of(seqof):
min_size, max_size = asn_type.Min, asn_type.Max
except AttributeError:
pass
tab = []
for i in xrange(len(seqof.value)):
item_stmts, item_str, local_var = expression(seqof.value[i])
......@@ -1972,6 +1971,8 @@ def array_content(prim, values, asnty):
values is a string with the sequence of numbers as processed by expression
asnty is the reference type of the string literal '''
#rtype = find_basic_type(prim.exprType)
if asnty.Min == asnty.Max:
print prim.inputString, asnty, asnty.Min, asnty.Max
if asnty.Min != asnty.Max:
length = len(prim.value)
if isinstance(prim, ogAST.PrimStringLiteral):
......
......@@ -679,6 +679,8 @@ def check_type_compatibility(primary, type_ref, context):
str(basic_type.Min) + '..' + str(basic_type.Max) + ']')
for elem in primary.value:
check_type_compatibility(elem, basic_type.type, context)
if not hasattr(primary, 'expected_type'):
primary.expected_type = type_ref
return
elif isinstance(primary, ogAST.PrimSequence) \
and basic_type.kind == 'SequenceType':
......@@ -696,7 +698,7 @@ def check_type_compatibility(primary, type_ref, context):
' of type {t1} '
.format(field=ufield,
t1=type_name(type_ref)))
elif field.lower() not in user_fields:
elif ufield.lower() not in user_fields:
# Optional field not set - OK
continue
else:
......@@ -989,6 +991,7 @@ def fix_expression_types(expr, context):
expr.right.value[det] = check_expr.right
if expr.right.is_raw != expr.left.is_raw:
print 'HIHI', raw_expr, ref_type
check_type_compatibility(raw_expr, ref_type, context)
if not raw_expr.exprType.kind.startswith(('Integer',
'Real',
......@@ -998,6 +1001,9 @@ def fix_expression_types(expr, context):
# that can be computed
# Also true for raw SEQOF and String - Min/Max must not change
# Substrings: CHECKME XXX
# EDIT: Size of raw SeqOf and Strings is known from looking at
# the number of elements. Min/Max are irrelevant. In principle
# removing SequenceOf and String from here should be OK.
raw_expr.exprType = ref_type
else:
compare_types(expr.left.exprType, expr.right.exprType)
......@@ -3419,8 +3425,8 @@ def decision(root, parent, context):
for en in q_basic.EnumValues.keys()]
# check for missing answers
if set(answers) != set(enumerants) and not has_else:
print set(answers)
print set(enumerants)
#print set(answers)
#print set(enumerants)
qerr.append('Decision "{}": Missing branches for answer(s) "{}"'
.format(dec.inputString,
'", "'.join(set(enumerants) - set(answers))))
......
......@@ -13,7 +13,7 @@ dcl fail t_bool := false;
-- Test optional field
dcl V5 Toto := { elem_1 'Hello' };
dcl V6 Toto := { elem_1 'Hello', elem_2 {'Hello', 'World'} };
dcl V6 Toto := { elem_1 'Hello', elem_2 {'Ola', 'TheWorld'} };
dcl V7 AChoice := a: TRUE;
dcl V8 ACHoice := b: {'Hello', 'World!'};
......@@ -21,7 +21,7 @@ dcl V8 ACHoice := b: {'Hello', 'World!'};
/* CIF START (1109, 72), (60, 30) */
START;
/* CIF TASK (1050, 118), (177, 35) */
TASK v8 := b: {'hello', 'world'} ;
TASK v8 := b: {'hello', 'world'};
/* CIF LABEL (1104, 168), (70, 35) */
one:
/* CIF DECISION (1090, 218), (98, 50) */
......
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