Commit 11252539 authored by Maxime Perrotin's avatar Maxime Perrotin

Complete support of local choice determinants

parent 71e0e3b1
...@@ -691,11 +691,15 @@ def check_call(name, params, context): ...@@ -691,11 +691,15 @@ def check_call(name, params, context):
}) })
elif name == 'present': elif name == 'present':
return type('Present', (object,), { # now there is a proper type defined for choice selectors
'kind': 'ChoiceEnumeratedType', sort = type_name (p.exprType) + "-selection"
'EnumValues': param_btys[0].Children return types()[sort].type
})
# return type('Present', (object,), {
# 'kind': 'ChoiceEnumeratedType',
# 'EnumValues': param_btys[0].Children
# })
#
elif name == 'round': elif name == 'round':
return type('Round', (REAL,), { return type('Round', (REAL,), {
'Min': str(round(float(param_btys[0].Min))), 'Min': str(round(float(param_btys[0].Min))),
...@@ -2774,7 +2778,7 @@ def syntype(root, ta_ast, context): ...@@ -2774,7 +2778,7 @@ def syntype(root, ta_ast, context):
"kind": reftype + "Type" "kind": reftype + "Type"
}) })
types[str(newtypename)] = newtype types()[str(newtypename)] = newtype
LOG.debug("Found new SYNTYPE " + newtypename) LOG.debug("Found new SYNTYPE " + newtypename)
return errors, warnings return errors, warnings
...@@ -2794,19 +2798,19 @@ def newtype(root, ta_ast, context): ...@@ -2794,19 +2798,19 @@ def newtype(root, ta_ast, context):
if len(root.children) < 2: if len(root.children) < 2:
warnings.append('Use newtype definitions for arrays and records only') warnings.append('Use newtype definitions for arrays and records only')
newtype.kind = "BooleanType" newtype.kind = "BooleanType"
types[str(newtypename)] = newtype types()[str(newtypename)] = newtype
LOG.debug("Boolean newtype " + newtypename) LOG.debug("Boolean newtype " + newtypename)
elif (root.getChild(1).type == lexer.ARRAY): elif (root.getChild(1).type == lexer.ARRAY):
newtype.kind = "SequenceOfType" newtype.kind = "SequenceOfType"
newtype.type = get_array_type(root.getChild(1)) newtype.type = get_array_type(root.getChild(1))
newtype.Min = "Min" newtype.Min = "Min"
newtype.Max = "Max" newtype.Max = "Max"
types[str(newtypename)] = newtype types()[str(newtypename)] = newtype
LOG.debug("Found new ARRAY type " + newtypename) LOG.debug("Found new ARRAY type " + newtypename)
elif (root.getChild(1).type == lexer.STRUCT): elif (root.getChild(1).type == lexer.STRUCT):
newtype.kind = "SequenceType" newtype.kind = "SequenceType"
newtype.Children = get_struct_children(root.getChild(1)) newtype.Children = get_struct_children(root.getChild(1))
types[str(newtypename)] = newtype types()[str(newtypename)] = newtype
LOG.debug("Found new STRUCT type " + newtypename) LOG.debug("Found new STRUCT type " + newtypename)
else: else:
warnings.append( warnings.append(
......
...@@ -24,19 +24,30 @@ system toto; ...@@ -24,19 +24,30 @@ system toto;
/* CIF ENDTEXT */ /* CIF ENDTEXT */
/* CIF START (240, 89), (70, 35) */ /* CIF START (240, 89), (70, 35) */
START; START;
/* CIF decision (222, 144), (106, 50) */ /* CIF task (160, 144), (229, 35) */
task choice_selectors := present(val);
/* CIF decision (222, 194), (106, 50) */
decision present (val); decision present (val);
/* CIF ANSWER (195, 214), (70, 24) */ /* CIF ANSWER (195, 264), (70, 24) */
(foo): (foo):
/* CIF ANSWER (285, 214), (70, 24) */ /* CIF ANSWER (285, 264), (70, 24) */
(bar): (bar):
enddecision; enddecision;
/* CIF decision (222, 253), (106, 50) */ /* CIF decision (222, 303), (106, 50) */
decision present (val); decision present (val);
/* CIF ANSWER (241, 323), (70, 24) */ /* CIF ANSWER (166, 373), (129, 24) */
(choice_selectors):
/* CIF ANSWER (315, 373), (70, 24) */
else: else:
enddecision; enddecision;
/* CIF NEXTSTATE (243, 362), (64, 35) */ /* CIF decision (210, 412), (129, 50) */
decision choice_selectors;
/* CIF ANSWER (223, 482), (103, 24) */
(present(val)):
/* CIF ANSWER (346, 482), (70, 24) */
else:
enddecision;
/* CIF NEXTSTATE (243, 521), (64, 35) */
NEXTSTATE hop; NEXTSTATE hop;
/* CIF state (528, 360), (70, 35) */ /* CIF state (528, 360), (70, 35) */
state hop; state hop;
......
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