Commit 6d2406fa authored by Christoph Richter's avatar Christoph Richter
Browse files

Fixed command name detection

parent 5378fd7d
Pipeline #62384 passed with stage
in 2 minutes and 35 seconds
......@@ -6,6 +6,8 @@ import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol
import java.util.HashSet;
import static de.monticore.lang.monticar.generator.cpp.MathCommandRegisterCPP.removeBrackets;
/**
* @author Sascha Schneiders.
*/
......@@ -36,7 +38,9 @@ public abstract class MathCommand {
convert(mathExpressionSymbol, bluePrint);
if (mathExpressionSymbol instanceof MathMatrixNameExpressionSymbol) {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
targetLanguageCommandNames.add(mathMatrixNameExpressionSymbol.getTextualRepresentation());
String s = mathMatrixNameExpressionSymbol.getTextualRepresentation();
s = removeBrackets(s);
targetLanguageCommandNames.add(s);
}
}
......@@ -53,10 +57,9 @@ public abstract class MathCommand {
public boolean isTargetLanguageCommand(String command) {
if (!command.isEmpty())
for (String s : getTargetLanguageCommandNames())
if (s.contains(command))
if (s.contentEquals(command))
return true;
return false;
}
}
......@@ -97,6 +97,14 @@ public class MathCommandRegisterCPP extends MathCommandRegister {
return fullString;
}
public static String removeBrackets(String fullString) {
String result = removeTrailingStrings(fullString, "(");
int idx = result.indexOf("(");
if (idx > 0)
result = result.substring(0, idx);
return result;
}
public static String calculateName(String fullName) {
int index = fullName.indexOf("(");
String name = "";
......
......@@ -271,7 +271,7 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
return MathConverter.curBackend.usesZeroBasedIndexing()
&& symbol.isMathMatrixAccessOperatorSymbolPresent()
&& (!symbol.getNameToAccess().isEmpty())
&& (!MathCommandRegisterCPP.containsCommandExpression(symbol, input))
&& (!MathCommandRegisterCPP.containsCommandExpression(symbol, symbol.getNameToAccess() + input))
&& (!MathFunctionFixer.fixForLoopAccess(symbol.getMathMatrixAccessOperatorSymbol().getMathMatrixNameExpressionSymbol(), ComponentConverter.currentBluePrint))
&& (!StringValueListExtractorUtil.containsPortName(symbol.getNameToAccess()));
}
......
Supports Markdown
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