Commit 57ffa902 authored by Ahmed's avatar Ahmed
Browse files

extends the usability of argumentReturnMathCommand

enable using of multiple argumentRterunMathCommand in the same component
parent 2791387e
...@@ -75,9 +75,7 @@ public class LanguageUnitCPP extends LanguageUnit { ...@@ -75,9 +75,7 @@ public class LanguageUnitCPP extends LanguageUnit {
} }
public String getGeneratedHeader(TaggingResolver taggingResolver, BluePrintCPP bluePrint) { public String getGeneratedHeader(TaggingResolver taggingResolver, BluePrintCPP bluePrint) {
MathCommand mathCommand = bluePrint.getMathCommandRegister().getMathCommand(ComponentConverter.nameOfFunction);
ExecutionOrderFixer.fixExecutionOrder(taggingResolver, bluePrint, (GeneratorCPP) bluePrint.getGenerator()); ExecutionOrderFixer.fixExecutionOrder(taggingResolver, bluePrint, (GeneratorCPP) bluePrint.getGenerator());
String nameOfFunction = ComponentConverter.nameOfFunction;
String resultString = ""; String resultString = "";
//guard defines //guard defines
resultString += "#ifndef " + bluePrint.getName().toUpperCase() + "\n"; resultString += "#ifndef " + bluePrint.getName().toUpperCase() + "\n";
......
...@@ -17,9 +17,9 @@ import de.monticore.lang.monticar.generator.*; ...@@ -17,9 +17,9 @@ import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cpp.*; import de.monticore.lang.monticar.generator.cpp.*;
import de.monticore.lang.monticar.generator.cpp.instruction.ConstantConnectInstructionCPP; import de.monticore.lang.monticar.generator.cpp.instruction.ConstantConnectInstructionCPP;
import de.monticore.lang.monticar.generator.optimization.MathInformationRegister; import de.monticore.lang.monticar.generator.optimization.MathInformationRegister;
import de.monticore.symboltable.types.references.ActualTypeArgument;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
...@@ -31,8 +31,8 @@ import java.util.stream.Collectors; ...@@ -31,8 +31,8 @@ import java.util.stream.Collectors;
public class ComponentConverter { public class ComponentConverter {
public static BluePrintCPP currentBluePrint = null; public static BluePrintCPP currentBluePrint = null;
public static String nameOfFunction = ""; public static List<String> namesOfFunctions = new ArrayList<>();
public static MathCommand usedMathCommand = null; public static List<MathCommand> usedMathCommand = new ArrayList<>();
public static BluePrint convertComponentSymbolToBluePrint(EMAComponentInstanceSymbol componentSymbol, MathStatementsSymbol mathStatementsSymbol, List<String> includeStrings, GeneratorCPP generatorCPP) { public static BluePrint convertComponentSymbolToBluePrint(EMAComponentInstanceSymbol componentSymbol, MathStatementsSymbol mathStatementsSymbol, List<String> includeStrings, GeneratorCPP generatorCPP) {
BluePrintCPP bluePrint = new BluePrintCPP(GeneralHelperMethods.getTargetLanguageComponentName(componentSymbol.getFullName())); BluePrintCPP bluePrint = new BluePrintCPP(GeneralHelperMethods.getTargetLanguageComponentName(componentSymbol.getFullName()));
...@@ -61,27 +61,32 @@ public class ComponentConverter { ...@@ -61,27 +61,32 @@ public class ComponentConverter {
} }
bluePrint.addVariable(ComponentInstanceConverter.convertComponentInstanceSymbolToVariable(instanceSymbol, componentSymbol)); bluePrint.addVariable(ComponentInstanceConverter.convertComponentInstanceSymbolToVariable(instanceSymbol, componentSymbol));
} }
//create arrays from variables that only differ at the end by _number_ //create arrays from variables that only differ at the end by _number_
BluePrintFixer.fixBluePrintVariableArrays(bluePrint); BluePrintFixer.fixBluePrintVariableArrays(bluePrint);
//ToDo: add bluePrintFixer.fixBluePrintCvVariableArrays; //ToDo: add bluePrintFixer.fixBluePrintCvVariableArrays;
MathInformationFilter.filterStaticInformation(componentSymbol, bluePrint, mathStatementsSymbol, generatorCPP, includeStrings); MathInformationFilter.filterStaticInformation(componentSymbol, bluePrint, mathStatementsSymbol, generatorCPP, includeStrings);
//save function name //save function name
if(mathStatementsSymbol != null) { if(mathStatementsSymbol != null) {
if (mathStatementsSymbol.getMathExpressionSymbols().get(0).isAssignmentExpression()) { List<MathExpressionSymbol> mathExpressionSymbols = mathStatementsSymbol.getMathExpressionSymbols();
if (((MathAssignmentExpressionSymbol) mathStatementsSymbol.getMathExpressionSymbols().get(0)).getExpressionSymbol() instanceof MathMatrixNameExpressionSymbol) { for(MathExpressionSymbol mathExpresionSymbol : mathExpressionSymbols){
nameOfFunction = ((MathMatrixNameExpressionSymbol) ((MathAssignmentExpressionSymbol) mathStatementsSymbol.getMathExpressionSymbols().get(0)).getExpressionSymbol()).getNameToAccess(); if (mathExpresionSymbol.isAssignmentExpression()) {
} if (((MathAssignmentExpressionSymbol) mathExpresionSymbol).getExpressionSymbol() instanceof MathMatrixNameExpressionSymbol) {
} else if(mathStatementsSymbol.getMathExpressionSymbols().get(0).isValueExpression()){ namesOfFunctions.add(((MathMatrixNameExpressionSymbol) ((MathAssignmentExpressionSymbol) mathExpresionSymbol).getExpressionSymbol()).getNameToAccess());
if(((MathValueSymbol) mathStatementsSymbol.getMathExpressionSymbols().get(0)).getValue() instanceof MathMatrixNameExpressionSymbol){
nameOfFunction = ((MathMatrixNameExpressionSymbol)((MathValueSymbol) mathStatementsSymbol.getMathExpressionSymbols().get(0)).getValue()).getNameToAccess(); }
} else if(mathExpresionSymbol.isValueExpression()) {
if (((MathValueSymbol) mathExpresionSymbol).getValue() instanceof MathMatrixNameExpressionSymbol) {
boolean bool = namesOfFunctions.add(((MathMatrixNameExpressionSymbol) ((MathValueSymbol) mathExpresionSymbol).getValue()).getNameToAccess());
}
} }
} }
} }
if(nameOfFunction != "") { if(namesOfFunctions != null) {
usedMathCommand = bluePrint.getMathCommandRegister().getMathCommand(nameOfFunction); for(String nameOfFunction : namesOfFunctions){
usedMathCommand.add(bluePrint.getMathCommandRegister().getMathCommand(nameOfFunction));
}
} }
//ToDo: add a BluePrintFixer.fixerBluePrintCVfuncitons(bluePrint, nameOfFunction); //ToDo: add a BluePrintFixer.fixerBluePrintCVfuncitons(bluePrint, nameOfFunction);
......
...@@ -194,9 +194,10 @@ public class ComponentConverterMethodGeneration { ...@@ -194,9 +194,10 @@ public class ComponentConverterMethodGeneration {
mathExpressionSymbol, BluePrintCPP bluePrint, List<String> includeStrings/*, int lastIndex*/) { mathExpressionSymbol, BluePrintCPP bluePrint, List<String> includeStrings/*, int lastIndex*/) {
MathFunctionFixer.fixMathFunctions(mathExpressionSymbol, bluePrint); MathFunctionFixer.fixMathFunctions(mathExpressionSymbol, bluePrint);
String result = ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, includeStrings); String result = ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, includeStrings);
if(ComponentConverter.usedMathCommand != null) { for (MathCommand mathCommand : ComponentConverter.usedMathCommand)
String argumentReturnFunctionName = ComponentConverter.usedMathCommand.getMathCommandName(); if(mathCommand != null) {
if (ComponentConverter.usedMathCommand.isArgumentReturnMathCommand() && result.contains(argumentReturnFunctionName)) { String argumentReturnFunctionName = mathCommand.getMathCommandName();
if (mathCommand.isArgumentReturnMathCommand() && result.contains(argumentReturnFunctionName)) {
result = fixArgumentReturnInstruction(result, method, mathExpressionSymbol, bluePrint); result = fixArgumentReturnInstruction(result, method, mathExpressionSymbol, bluePrint);
} }
} }
......
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