List<InstructionBase> instructionsLooping = InstructionParser.ParseInstructions([
"STR 1 5.5225",
"LDR 1",
"ADD 1",
]);
InstructionExecutorContext context = new(instructionsLooping);
context.Execute();
There seems to be a problem with handling floats/singles in the instructions. The code enters an infinite loop, which I assume is caused by an attempt to cast an object of type Value to Value, which clearly fails since they are different types.
The root cause appears to be that ArithmeticInstructionBase defaults to typeof(int) for operations,
private static Type? DetermineGenericTypeFromPrefix(string prefix, string[] parts) {
Type? genericTypeFromValue = null;
switch (prefix) {
case "STR":
if (parts.Length == 3) { // "STR address value"
string value = parts[2];
genericTypeFromValue = value.ParseNumberTypeAsType(); // value => Type?
}
genericTypeFromValue ??= typeof(int); // if number could not be parsed as specific type for STR we can always refer to typeof(int)
break;
case "ADD":
case "DIV":
case "MUL":
case "SUB":
case "CMP":
case "LDR":
genericTypeFromValue = typeof(int);
break;
}
as there is no logic for getting the actual generic type that should be used.
There seems to be a problem with handling floats/singles in the instructions. The code enters an infinite loop, which I assume is caused by an attempt to cast an object of type Value to Value, which clearly fails since they are different types.
The root cause appears to be that ArithmeticInstructionBase defaults to typeof(int) for operations,
as there is no logic for getting the actual generic type that should be used.