Commit b445a371 authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

Revert "continued refactoring"

This reverts commit d7cb593c.
parent d7cb593c
......@@ -126,6 +126,7 @@ public class ExecuteMethodGenerator {
result += ";\n";
}
ComponentConverter.currentBluePrint.getMathInformationRegister().addVariable(mathValueSymbol);
//result += mathValueSymbol.getTextualRepresentation();
return result;
}
......@@ -139,6 +140,7 @@ public class ExecuteMethodGenerator {
result += " = " + generateExecuteCode(mathValueSymbol.getValue(), includeStrings);
result += ";\n";
}
//result += mathValueSymbol.getTextualRepresentation();
return result;
}
......@@ -188,6 +190,11 @@ public class ExecuteMethodGenerator {
return result;
}
/*if (mathAssignmentExpressionSymbol.getNameOfMathValue().equals("eigenVectors")) {
for (Variable var : ComponentConverter.currentBluePrint.getMathInformationRegister().getVariables()) {
Log.info(var.getName(), "Var:");
}
}*/
String result = mathAssignmentExpressionSymbol.getNameOfMathValue();
result += generateExecuteCode(mathAssignmentExpressionSymbol.getMathMatrixAccessOperatorSymbol(), includeStrings) + " ";
result += mathAssignmentExpressionSymbol.getAssignmentOperator().getOperator() + " ";
......@@ -242,13 +249,13 @@ public class ExecuteMethodGenerator {
String result = "";
//if condition
result += ExecuteMethodGeneratorHelper.generateIfConditionCode(mathConditionalExpressionsSymbol.getIfConditionalExpression(), includeStrings);
result += generateIfConditionCode(mathConditionalExpressionsSymbol.getIfConditionalExpression(), includeStrings);
//else if condition
for (MathConditionalExpressionSymbol mathConditionalExpressionSymbol : mathConditionalExpressionsSymbol.getIfElseConditionalExpressions())
result += "else " + ExecuteMethodGeneratorHelper.generateIfConditionCode(mathConditionalExpressionSymbol, includeStrings);
result += "else " + generateIfConditionCode(mathConditionalExpressionSymbol, includeStrings);
//else block
if (mathConditionalExpressionsSymbol.getElseConditionalExpression().isPresent()) {
result += "else " + ExecuteMethodGeneratorHelper.generateIfConditionCode(mathConditionalExpressionsSymbol.getElseConditionalExpression().get(), includeStrings);
result += "else " + generateIfConditionCode(mathConditionalExpressionsSymbol.getElseConditionalExpression().get(), includeStrings);
}
return result;
}
......@@ -295,6 +302,11 @@ public class ExecuteMethodGenerator {
return generateExecuteCodeMatrixEEPowerOf(mathMatrixArithmeticExpressionSymbol, includeStrings);
} else if (mathMatrixArithmeticExpressionSymbol.getMathOperator().equals("./")) {
return generateExecuteCodeMatrixEEDivide(mathMatrixArithmeticExpressionSymbol, includeStrings);
/*} else if (mathArithmeticExpressionSymbol.getMathOperator().equals("./")) {
Log.error("reace");
result += "\"ldivide\"";
includeStrings.add("Helper");
*/
} else {
result += /*"(" +*/ generateExecuteCode(mathMatrixArithmeticExpressionSymbol.getLeftExpression(), includeStrings) + " " + mathMatrixArithmeticExpressionSymbol.getMathOperator();
......@@ -302,6 +314,9 @@ public class ExecuteMethodGenerator {
if (mathMatrixArithmeticExpressionSymbol.getRightExpression() != null)
result += " " + generateExecuteCode(mathMatrixArithmeticExpressionSymbol.getRightExpression(), includeStrings);
}
/*result += ")"*/
;
return result;
}
......@@ -386,7 +401,34 @@ public class ExecuteMethodGenerator {
}
result += mathMatrixAccessOperatorSymbol.getAccessStartSymbol();
ExecuteMethodGeneratorHelper.handleForLoopAccessFix(mathMatrixAccessOperatorSymbol, counter, ignoreCounterAt, counterSetMinusOne, includeStrings);
if (MathFunctionFixer.fixForLoopAccess(mathMatrixAccessOperatorSymbol.getMathMatrixNameExpressionSymbol(), ComponentConverter.currentBluePrint)) {
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
++counter;
} else {
result += generateExecuteCode(mathMatrixAccessSymbol, includeStrings, true);
++counter;
if (counter < mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().size() && counter != ignoreCounterAt) {
result += ", ";
}
}
}
} else {
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
++counter;
} else {
if (counter == counterSetMinusOne)
result += generateExecuteCode(mathMatrixAccessSymbol, includeStrings, true);
else
result += generateExecuteCode(mathMatrixAccessSymbol, includeStrings);
++counter;
if (counter < mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().size() && counter != ignoreCounterAt) {
result += ", ";
}
}
}
}
result += mathMatrixAccessOperatorSymbol.getAccessEndSymbol();
return result;
}
......@@ -406,4 +448,33 @@ public class ExecuteMethodGenerator {
public static String generateExecuteCode(MathMatrixAccessSymbol mathMatrixAccessSymbol, List<String> includeStrings) {
return generateExecuteCode(mathMatrixAccessSymbol, includeStrings, false);
}
/*
public static String generateExecuteCodeFixForLoopAccess(MathMatrixAccessSymbol mathMatrixAccessSymbol, List<String> includeStrings) {
String result = "";
if (mathMatrixAccessSymbol.isDoubleDot())
result += ":";
else {
MathFunctionFixer.fixMathFunctions(mathMatrixAccessSymbol.getMathExpressionSymbol().get(), currentBluePrint);
result += generateExecuteCode(mathMatrixAccessSymbol.getMathExpressionSymbol().get(), includeStrings);
//result += "-1";
}
return result;
}*/
public static String generateIfConditionCode(MathConditionalExpressionSymbol mathConditionalExpressionSymbol, List<String> includeStrings) {
String result = "";
//condition
if (mathConditionalExpressionSymbol.getCondition().isPresent()) {
result += "if(" + generateExecuteCode(mathConditionalExpressionSymbol.getCondition().get(), includeStrings) + ")";
}
//body
result += "{\n";
for (MathExpressionSymbol mathExpressionSymbol : mathConditionalExpressionSymbol.getBodyExpressions())
result += generateExecuteCode(mathExpressionSymbol, includeStrings);
result += "}\n";
return result;
}
}
package de.monticore.lang.monticar.generator.cpp.converter;
import de.monticore.lang.math.math._symboltable.expression.MathConditionalExpressionSymbol;
import de.monticore.lang.math.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math.math._symboltable.matrix.MathMatrixAccessOperatorSymbol;
import de.monticore.lang.math.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
import java.util.List;
/**
* @author Sascha Schneiders
*/
public class ExecuteMethodGeneratorHelper {
public static String generateIfConditionCode(MathConditionalExpressionSymbol mathConditionalExpressionSymbol, List<String> includeStrings) {
String result = "";
//condition
if (mathConditionalExpressionSymbol.getCondition().isPresent()) {
result += "if(" + ExecuteMethodGenerator.generateExecuteCode(mathConditionalExpressionSymbol.getCondition().get(), includeStrings) + ")";
}
//body
result += "{\n";
for (MathExpressionSymbol mathExpressionSymbol : mathConditionalExpressionSymbol.getBodyExpressions())
result += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, includeStrings);
result += "}\n";
return result;
}
public static String handleForLoopAccessFix(MathMatrixAccessOperatorSymbol mathMatrixAccessOperatorSymbol, int counter, int ignoreCounterAt, int counterSetMinusOne, List<String> includeStrings) {
String result = "";
if (MathFunctionFixer.fixForLoopAccess(mathMatrixAccessOperatorSymbol.getMathMatrixNameExpressionSymbol(), ComponentConverter.currentBluePrint)) {
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
++counter;
} else {
result += ExecuteMethodGenerator.generateExecuteCode(mathMatrixAccessSymbol, includeStrings, true);
++counter;
if (counter < mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().size() && counter != ignoreCounterAt) {
result += ", ";
}
}
}
} else {
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
++counter;
} else {
if (counter == counterSetMinusOne)
result += ExecuteMethodGenerator.generateExecuteCode(mathMatrixAccessSymbol, includeStrings, true);
else
result += ExecuteMethodGenerator.generateExecuteCode(mathMatrixAccessSymbol, includeStrings);
++counter;
if (counter < mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().size() && counter != ignoreCounterAt) {
result += ", ";
}
}
}
}
return result;
}
}
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