CLanguage by praeclarum

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

 DereferenceExpression

using CLanguage.Compiler; using CLanguage.Interpreter; using CLanguage.Types; using System.Runtime.CompilerServices; namespace CLanguage.Syntax { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class DereferenceExpression : Expression { public Expression InnerExpression { get; } public override bool CanEmitPointer => true; public DereferenceExpression(Expression innerExpression) { InnerExpression = innerExpression; } public override CType GetEvaluatedCType(EmitContext ec) { CType evaluatedCType = InnerExpression.GetEvaluatedCType(ec); CPointerType cPointerType = evaluatedCType as CPointerType; if (cPointerType != null) return cPointerType.InnerType; ec.Report.Error(0, $"""{new object[1] { evaluatedCType }}"""); return CBasicType.SignedInt; } protected override void DoEmit(EmitContext ec) { InnerExpression.Emit(ec); ec.Emit(OpCode.LoadPointer); } protected override void DoEmitPointer(EmitContext ec) { InnerExpression.Emit(ec); } } }