blob: 9c69a237145254b2ddb57b01e2ebbee53430b3b2 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2019-2020 Robert Bosch GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
* *******************************************************************************
*/
package org.eclipse.app4mc.amlt2systemc.m2t.transformers.sw
import com.google.inject.Inject
import org.eclipse.app4mc.amlt2systemc.m2t.transformers.sw.IActivityGraphItemContainerTransformer.ActivityGraphBuffer
import org.eclipse.app4mc.amlt2systemc.m2t.transformers.common.ModeConditionTransformer
import org.eclipse.app4mc.amalthea.model.WhileLoop
class WhileLoopTransformer extends IActivityGraphItemContainerTransformer {
@Inject ModeConditionTransformer modeConditionTransformer
static int cnt =0;
static def getName(){
return "whileLoop_" + cnt;
}
def void transform(WhileLoop whileLoop, ActivityGraphBuffer parentContent) {
val name = getName()
cnt++;
parentContent.addBody("WhileLoop " + name + ";")
val content = new ActivityGraphBuffer(name, parentContent.module, false)
val conditionContent = modeConditionTransformer.transformCondition(whileLoop.condition, name, false)
val activityGraphContents = transformItems(whileLoop, name, content.module, content.parentIsPointer)
activityGraphContents.addAll(conditionContent)
parentContent.getIncludes().addAll(activityGraphContents.getIncludes())
parentContent.getSource().addAll(activityGraphContents.getSource())
parentContent.addAsActivityGraphItem("<WhileLoop>(" + name + ")")
}
}