| /** |
| * ******************************************************************************* |
| * 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 com.google.inject.Singleton |
| import org.eclipse.app4mc.amalthea.model.EnumMode |
| import org.eclipse.app4mc.amalthea.model.Mode |
| import org.eclipse.app4mc.amalthea.model.NumericMode |
| import org.eclipse.app4mc.amlt2systemc.m2t.module.BaseTransformer |
| import org.eclipse.app4mc.transformation.util.OutputBuffer |
| |
| @Singleton |
| class ModeTransformer extends BaseTransformer { |
| |
| @Inject OutputBuffer outputBuffer |
| |
| def create new String(_mode.name) transform(Mode _mode) { |
| // generate definition |
| val modeSwitchDefinition = generateInc(it, _mode) |
| outputBuffer.appendTo("INC", it, modeSwitchDefinition + "\n") |
| } |
| |
| private def dispatch String generateInc(String _name, EnumMode _mode) ''' |
| #include<stdio> |
| #include "Common.h" |
| #include "ModeLabel.h" |
| |
| //Enumeration mode definition |
| auto «_name» = Mode::CreateMode(«_name»); |
| «FOR literal : _mode.literals» |
| auto «literal.name» = «_name»->addLiteral(«literal.name»); |
| «ENDFOR» |
| ''' |
| |
| private def dispatch String generateInc(String _name, NumericMode _mode) ''' |
| #include<stdio> |
| #include "Common.h" |
| #include "ModeLabel.h" |
| |
| //Numeric mode definition |
| auto «_name» = Mode::CreateMode(«_mode.uniqueName»); |
| |
| ''' |
| } |