use of org.lflang.lf.Value in project lingua-franca by lf-lang.
the class ValueGenerator method getInitializerList.
/**
* Create a list of parameter initializers in target code in the context
* of an reactor instantiation.
*
* This respects the parameter assignments given in the reactor
* instantiation and falls back to the reactors default initializers
* if no value is assigned to it.
*
* @param param The parameter to create initializers for
* @return A list of initializers in target code
*/
public List<String> getInitializerList(Parameter param, Instantiation i) {
List<Assignment> assignments = i.getParameters().stream().filter(it -> it.getLhs() == param).collect(Collectors.toList());
if (// Case 0: The parameter was not overwritten in the instantiation
assignments.isEmpty())
return getInitializerList(param);
// Case 1: The parameter was overwritten in the instantiation
List<String> list = new ArrayList<>();
if (assignments.get(0) == null)
return list;
for (Value init : assignments.get(0).getRhs()) list.add(getTargetValue(init, ASTUtils.isOfTimeType(param)));
return list;
}
Aggregations