CLanguage by praeclarum

<PackageReference Include="CLanguage" Version="0.9.145" />

 CastExpression

public class CastExpression : Expression
using CLanguage.Compiler; using CLanguage.Types; namespace CLanguage.Syntax { public class CastExpression : Expression { public TypeName TypeName { get; } public Expression InnerExpression { get; } public CastExpression(TypeName typeName, Expression innerExpression) { TypeName = typeName; InnerExpression = innerExpression; } public override CType GetEvaluatedCType(EmitContext ec) { return ec.ResolveTypeName(TypeName) ?? CBasicType.SignedInt; } protected override void DoEmit(EmitContext ec) { CType evaluatedCType = GetEvaluatedCType(ec); CType evaluatedCType2 = InnerExpression.GetEvaluatedCType(ec); InnerExpression.Emit(ec); ec.EmitCast(evaluatedCType2, evaluatedCType); } } }