Disammbler und Simulator angepasst. Arrays begonnen (defunct)
This commit is contained in:
@ -46,10 +46,29 @@ class Program {
|
||||
byte tb = r.ReadByte();
|
||||
var vt = (VarType)tb;
|
||||
varTypes[i] = vt;
|
||||
if (Enum.IsDefined(typeof(VarType), vt))
|
||||
|
||||
if (vt == VarType.ARRAY) {
|
||||
// Look ahead to find array length and element type
|
||||
int arrayStart = i;
|
||||
int length = 1;
|
||||
VarType elementType = 0; // Initialize to INT as default
|
||||
|
||||
if (i + 1 < nVars) {
|
||||
elementType = (VarType)varTypes[i + 1];
|
||||
while (i + length < nVars && varTypes[i + length] == varTypes[i + 1]) {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($" Var[{i}] type = ARRAY[{length}] OF {elementType}");
|
||||
i += length - 1; // Skip array elements
|
||||
}
|
||||
else if (Enum.IsDefined(typeof(VarType), vt)) {
|
||||
Console.WriteLine($" Var[{i}] type = {vt}");
|
||||
else
|
||||
}
|
||||
else {
|
||||
Console.WriteLine($" Var[{i}] type = {tb} (unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
ushort codeLen = r.ReadUInt16();
|
||||
@ -71,6 +90,12 @@ class Program {
|
||||
case Bytecode.OpCodes.JZ: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JZ addr={target:0000}"); break; }
|
||||
case Bytecode.OpCodes.JMP: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JMP addr={target:0000}"); break; }
|
||||
case Bytecode.OpCodes.HALT: Console.WriteLine("HALT"); break;
|
||||
case Bytecode.OpCodes.ARRAY_BOUNDS_CHECK: {
|
||||
Console.WriteLine("ARRAY_BOUNDS_CHECK");
|
||||
// Skip the next byte as it's part of the array bounds check instruction
|
||||
if (ip < code.Length) ip++;
|
||||
break;
|
||||
}
|
||||
default: Console.WriteLine($"{Bytecode.OpName(op)}"); break;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec4d7dc26ee2fd96db003ab3a6c1af70e02894b9")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3cb63739152cd26ec43993953c7b93d4ab9bcce7")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Von der MSBuild WriteCodeFragment-Klasse generiert.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
124c0ad3412d8c18080f8da6f8923566217268c81c32c97108af077bc918b46f
|
||||
2175f71304910ca37c6a64a54785d953c58ecd76944c17fb6fe56c6a95a4d3e4
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user