SizeOfExpression
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 SizeOfExpression : Expression
{
public Expression Query { get; set; }
public SizeOfExpression(Expression query)
{
Query = query;
}
public override CType GetEvaluatedCType(EmitContext ec)
{
return CBasicType.UnsignedLongInt;
}
protected override void DoEmit(EmitContext ec)
{
Value x = Query.GetEvaluatedCType(ec).GetByteSize(ec);
ec.Emit(OpCode.LoadConstant, x);
}
}
}