Commit d9aff34e authored by Maxime Perrotin's avatar Maxime Perrotin

First compilation with state aggregations

parent 85057ee4
......@@ -186,7 +186,8 @@ LD_LIBRARY_PATH=. taste-gui -l
# Get list of parallel states to be added to the global list of states,
# and list of their inner substates
aggregates, substates = Helper.state_aggregations(process)
#aggregates, substates = Helper.state_aggregations(process)
aggregates = Helper.state_aggregations(process)
# End debug
......@@ -199,7 +200,7 @@ LD_LIBRARY_PATH=. taste-gui -l
process_level_decl = []
# Establish the list of states (excluding START states)
statelist = ', '.join(chain(aggregates, (name for name in
statelist = ', '.join(chain(aggregates.viewkeys(), (name for name in
if not name.endswith(u'START')))) or 'No_State'
if statelist:
......@@ -213,9 +214,11 @@ LD_LIBRARY_PATH=. taste-gui -l
process_level_decl.append('state : States;')
# State aggregation: add list of substates (XXX to be added in C generator)
for each in substates:
process_level_decl.append(u'{}{}state: States;'
.format(each, UNICODE_SEP))
# for each in substates:
for substates in aggregates.viewvalues():
for each in substates:
process_level_decl.append(u'{}{}state: States;'
.format(each, UNICODE_SEP))
for var_name, (var_type, def_value) in process.variables.viewitems():
if def_value:
......@@ -242,9 +245,19 @@ LD_LIBRARY_PATH=. taste-gui -l
.format(name=name, val=str(val)))
# Declare start procedure for aggregate states XXX add in C generator
for each in aggregates:
process_level_decl.append(u'procedure {}{}START;'.format(each,
# should create one START per "via" clause, TODO later
aggreg_start_proc = []
for name, substates in aggregates.viewitems():
proc_name = u'procedure {}{}START'.format(name, UNICODE_SEP)
aggreg_start_proc.extend([u'{} is'.format(proc_name),
.format(sub=subname, sep=UNICODE_SEP)
for subname in substates)
aggreg_start_proc.extend([u'end {}{}START;'
.format(name, UNICODE_SEP),
# Add the declaration of the runTransition procedure, if needed
if process.transitions:
......@@ -342,7 +355,6 @@ package {process_name} is'''.format(process_name=process_name,
dll_api.append('end dll_set_l_{};'.format(var_name))
# Generate the the code of the procedures
inner_procedures_code = []
for proc in process.content.inner_procedures:
......@@ -356,6 +368,10 @@ package {process_name} is'''.format(process_name=process_name,
# Add the code of the procedures definitions
# Generate the code of the START procedures of state aggregations
# XXX to be added to C generator
# Add the code of the DLL interface
......@@ -40,7 +40,9 @@ __all__ = ['flatten', 'rename_everything', 'inner_labels_to_floating',
def state_aggregations(process):
''' Return the list of state aggregations and substates '''
aggregates, substates = [], []
#aggregates, substates = [], []
# { aggregate_name : [list of parallel states] }
aggregates = defaultdict(list)
def do_composite(comp, aggregate=''):
''' Recursively find all state aggregations in order to create
variables to store the state of each parallel state '''
......@@ -53,10 +55,12 @@ def state_aggregations(process):
if term.inputString.lower() == each.statename.lower():
term.next_is_aggregation = True
if isinstance(comp, ogAST.StateAggregation):
elif aggregate: # Elif: no state for an inner state aggregation
# Composite state inside a state aggregation
# Here, all the terminators inside the composite states must
# be flagged with the name of the substate so that the NEXTSTATE
# will not be using the main "context.state" variable but will
......@@ -68,7 +72,7 @@ def state_aggregations(process):
for each in process.terminators:
if each.inputString.lower() in aggregates:
each.next_is_aggregation = True
return aggregates, substates
return aggregates #, substates
def map_input_state(process):
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