code generator progress

This commit is contained in:
rusefi 2020-04-12 23:44:14 -04:00
parent 56fcb0fb28
commit 598f90f6c9
4 changed files with 10 additions and 2 deletions

Binary file not shown.

View File

@ -26,6 +26,7 @@ public class ReaderState {
private static final String STRUCT_NO_PREFIX = "struct_no_prefix ";
private static final String STRUCT = "struct ";
private static final String DEFINE_CONSTRUCTOR = "define_constructor";
public static final char MULT_TOKEN = '*';
public Stack<ConfigStructure> stack = new Stack<>();
public Map<String, Integer> tsCustomSize = new HashMap<>();
public Map<String, String> tsCustomLine = new HashMap<>();
@ -80,7 +81,7 @@ public class ReaderState {
customSize = customSize.replaceAll("x", "*");
line = VariableRegistry.INSTANCE.applyVariables(line);
int multPosition = customSize.indexOf('*');
int multPosition = customSize.indexOf(MULT_TOKEN);
if (multPosition != -1) {
String firstPart = customSize.substring(0, multPosition);
int first;

View File

@ -57,6 +57,13 @@ public class VariableRegistry {
return;
}
value = applyVariables(value);
int multPosition = value.indexOf(MULT_TOKEN);
if (multPosition != -1) {
Integer first = Integer.valueOf(value.substring(0, multPosition));
Integer second = Integer.valueOf(value.substring(multPosition + 1));
value = String.valueOf(first * second);
}
SystemOut.println("Registering " + var + " as " + value);
data.put(var, value);

View File

@ -68,7 +68,7 @@ public class ConfigFieldParserTest {
assertEquals("#define ERROR_BUFFER_COUNT 120\n" +
"#define ERROR_BUFFER_SIZE 120\n" +
"#define RESULT 120*120\n", VariableRegistry.INSTANCE.getDefinesSection());
"#define RESULT 14400\n", VariableRegistry.INSTANCE.getDefinesSection());
}
@Test