Commit 7e9166b2 authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

refactoring

parent 1826d29d
......@@ -66,7 +66,7 @@ public class ComponentConverter {
public static void addVariables(ExpandedComponentInstanceSymbol componentSymbol, BluePrintCPP bluePrint) {
//add parameters as variables
for (EMAVariable variable : componentSymbol.getParameters()) {
System.out.println("EMAVAR: " + variable.getName() + " " + variable.getType().toString());
Log.debug("EMAVAR: " + variable.getName() + " " + variable.getType().toString(), "ComponentConverter");
Variable var = new Variable();
var.setName(variable.getName());
var.setTypeNameMontiCar(variable.getType());
......@@ -106,7 +106,7 @@ public class ComponentConverter {
for (ExpandedComponentInstanceSymbol subComponent : componentSymbol.getSubComponents()) {
String parameterString = "";
for (ASTExpression var : subComponent.getArguments()) {
System.out.println(var.toString());
Log.debug(var.toString(),"ComponentConverter");
parameterString += getExpressionParameterConversion(var);
}
String result = "";
......
......@@ -93,7 +93,7 @@ public class ComponentConverterMethodGeneration {
TargetCodeMathInstruction instruction = new TargetCodeMathInstruction(result, mathExpressionSymbol);
method.addInstruction(instruction);
visitedMathExpressionSymbol.add(mathExpressionSymbol);
System.out.println("lastIndex: " + lastIndex + " current: " + currentGenerationIndex);
Log.debug("lastIndex: " + lastIndex + " current: " + currentGenerationIndex,"ComponentConverterMethodGeneration");
lastIndex = currentGenerationIndex;
}
if (swapNextInstructions) {
......
......@@ -65,10 +65,10 @@ public class MathConverter {
String result = "";
int column = 0;
for (MathMatrixAccessOperatorSymbol symbol : mathExpressionSymbol.getVectors()) {
System.out.println(symbol.getTextualRepresentation());
Log.debug(symbol.getTextualRepresentation(),"Symbol:");
int row = 0;
for (MathMatrixAccessSymbol symbolAccess : symbol.getMathMatrixAccessSymbols()) {
System.out.println(symbolAccess.getTextualRepresentation());
Log.debug("symbolAccess: "+symbolAccess.getTextualRepresentation(),"MathConverter");
result += matrixName + "(" + column + "," + row + ") = ";
result += symbolAccess.getTextualRepresentation();
result += ";\n";
......
......@@ -9,6 +9,7 @@ import de.monticore.lang.math.math._symboltable.expression.MathNameExpressionSym
import de.monticore.lang.math.math._symboltable.matrix.MathMatrixExpressionSymbol;
import de.monticore.lang.math.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverterMethodGeneration;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -36,7 +37,7 @@ public class MathAssignmentPartResultReuse implements MathOptimizationRule {
} else if (mathExpressionSymbol.isMatrixExpression()) {
optimize((MathMatrixExpressionSymbol) mathExpressionSymbol, precedingExpressions);
} else {
System.out.println("Symbol not handled: " + mathExpressionSymbol.getClass().getName() + " " + mathExpressionSymbol.getTextualRepresentation());
Log.debug(mathExpressionSymbol.getClass().getName() + " " + mathExpressionSymbol.getTextualRepresentation(), "Symbol not handled");
}
}
......@@ -62,13 +63,13 @@ public class MathAssignmentPartResultReuse implements MathOptimizationRule {
if (mathExpressionSymbol.isMatrixNameExpression()) {
optimize((MathMatrixNameExpressionSymbol) mathExpressionSymbol, precedingExpressions);
} else {
System.out.println("Symbol not handled: " + mathExpressionSymbol.getClass().getName() + " " + mathExpressionSymbol.getTextualRepresentation());
Log.debug(mathExpressionSymbol.getClass().getName() + " " + mathExpressionSymbol.getTextualRepresentation(), "Symbol not handled");
}
}
public void optimize(MathMatrixNameExpressionSymbol mathExpressionSymbol, List<MathExpressionSymbol> precedingExpressions) {
if (encounteredSymbolInstances.contains(mathExpressionSymbol)) {
System.out.println("Found Same Symbol");
Log.debug("Found Same Symbol", "MathAssignmentPartResuktReuses");
String name = "";
if (!symbolMap.containsKey(mathExpressionSymbol)) {
symbolMap.put(mathExpressionSymbol, name = getReplacementName(currentId++));
......@@ -81,7 +82,7 @@ public class MathAssignmentPartResultReuse implements MathOptimizationRule {
--ComponentConverterMethodGeneration.currentGenerationIndex;
} else {
encounteredSymbolInstances.add(mathExpressionSymbol);
System.out.println("Added " + mathExpressionSymbol.getTextualRepresentation() + " to encounterSymbolInstances");
Log.debug("Added " + mathExpressionSymbol.getTextualRepresentation() + " to encounterSymbolInstances", "MathAssignmentPartResultReuse");
optimize(mathExpressionSymbol.getMathMatrixAccessOperatorSymbol(), precedingExpressions);
}
}
......
......@@ -72,7 +72,7 @@ public class MathDiagonalMatrixInversionOptimization implements MathOptimization
public void optimize(MathMatrixNameExpressionSymbol mathExpressionSymbol, List<MathExpressionSymbol> precedingExpressions) {
if (mathExpressionSymbol.getNameToAccess().equals("inv")) {
//ComponentConverter.currentBluePrint.getMathInformationRegister().isDiagonalMatrix()
boolean invertsDiagonalMatrix = invertsDiagonalMatrix();
boolean invertsDiagonalMatrix = invertsDiagonalMatrix(mathExpressionSymbol);
if (invertsDiagonalMatrix) {
mathExpressionSymbol.setNameToAccess("invdiag");
}
......
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