Implement TypeOf and ConvertType instructions

This commit is contained in:
Yoshi Askharoun
2025-08-02 21:34:17 -05:00
parent eede0200d2
commit 810fc8b802
2 changed files with 17 additions and 0 deletions
+15
View File
@@ -396,6 +396,21 @@ partial class Decompiler
)); ));
break; break;
case OpCode.TypeOf:
var typeOfSchema = _context.GetImportedType(instruction.Operands.First());
var typeOfExpr = TypeOfExpression(IrisExpression.ToSyntax(typeOfSchema, _context));
stack.Push(typeOfExpr);
break;
case OpCode.ConvertType:
var destinationTypeSchema = _context.GetImportedType(instruction.Operands.First());
var typeCastExpr = CastExpression(
IrisExpression.ToSyntax(destinationTypeSchema, _context),
Parenthesize(IrisExpression.ToSyntax(stack.Pop(), _context))
);
stack.Push(typeCastExpr);
break;
default: default:
return false; return false;
} }
+2
View File
@@ -263,6 +263,8 @@ public partial class Decompiler
case OpCode.PropertyGetPeek: case OpCode.PropertyGetPeek:
case OpCode.PropertyGetStatic: case OpCode.PropertyGetStatic:
case OpCode.Operation: case OpCode.Operation:
case OpCode.TypeOf:
case OpCode.ConvertType:
// These instructions only appear in initializers as inline expressions // These instructions only appear in initializers as inline expressions
if (!TryDecompileExpression(instruction, stack)) if (!TryDecompileExpression(instruction, stack))
throw new NotImplementedException(); throw new NotImplementedException();