V2 funktioniert
This commit is contained in:
@ -622,12 +622,12 @@ public class BytecodeEmitter {
|
||||
syms[v.Name]=new Symbol{Name=v.Name,Type=v.Type,Index=idx++};
|
||||
|
||||
foreach(var v in p.Vars)
|
||||
if(v.Init!=null){EmitExpr(v.Init);EmitByte(0x03);EmitU16((ushort)syms[v.Name].Index);}
|
||||
if(v.Init!=null){EmitExpr(v.Init);EmitByte(Bytecode.OpCodes.STORE_VAR);EmitU16((ushort)syms[v.Name].Index);}
|
||||
|
||||
foreach(var s in p.Stmts)
|
||||
EmitStmt(s);
|
||||
|
||||
EmitByte(0xF0); // Program End
|
||||
EmitByte(Bytecode.OpCodes.HALT); // Program End
|
||||
}
|
||||
|
||||
// Operationscodes für verschiedene Datentypen
|
||||
@ -779,14 +779,14 @@ public class BytecodeEmitter {
|
||||
int ci = AddConst(ie.Value);
|
||||
EmitByte(Bytecode.OpCodes.PUSH_CONST); // PUSH_CONST
|
||||
EmitU16((ushort)ci);
|
||||
EmitByte((byte)ie.Type); // Typ der Konstante
|
||||
// removed emitting the type byte into code stream; type is stored with constant table
|
||||
break;
|
||||
|
||||
case RealExpr re:
|
||||
int cri = AddConst(re.Value);
|
||||
EmitByte(Bytecode.OpCodes.PUSH_REAL_CONST); // PUSH_REAL_CONST
|
||||
EmitU16((ushort)cri);
|
||||
EmitByte((byte)re.Type); // REAL oder LREAL
|
||||
// removed emitting the type byte into code stream; type is stored with constant table
|
||||
break;
|
||||
|
||||
case VarExpr ve:
|
||||
@ -808,10 +808,11 @@ public class BytecodeEmitter {
|
||||
}
|
||||
|
||||
// Wenn nötig, Typenkonvertierung vor der Operation
|
||||
if (be.L.Type != be.Type)
|
||||
EmitByte((byte)(0x50 + (int)be.Type)); // CONVERT_TO_*
|
||||
if (be.R.Type != be.Type)
|
||||
EmitByte((byte)(0x50 + (int)be.Type)); // CONVERT_TO_*
|
||||
// Conversion opcodes removed - runtime will handle type differences using constant type markers and operation opcodes
|
||||
// if (be.L.Type != be.Type)
|
||||
// EmitByte((byte)(0x50 + (int)be.Type)); // CONVERT_TO_*
|
||||
// if (be.R.Type != be.Type)
|
||||
// EmitByte((byte)(0x50 + (int)be.Type)); // CONVERT_TO_*
|
||||
|
||||
EmitByte(opCodes[key]);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user