obfuz/Editor/Emit/DataNodes/DataNodeBase.cs

55 lines
1.1 KiB
C#
Raw Normal View History

2025-04-22 19:34:46 +08:00
using dnlib.DotNet;
namespace Obfuz.Emit
2025-04-20 14:23:40 +08:00
{
public abstract class DataNodeBase : IDataNode
{
2025-04-22 08:13:58 +08:00
public DataNodeType Type { get; set; }
2025-04-20 14:23:40 +08:00
2025-04-22 08:13:58 +08:00
public abstract object Value { get; set; }
2025-04-20 14:23:40 +08:00
2025-04-22 10:42:58 +08:00
public int IntValue => (int)Value;
public long LongValue => (long) Value;
public float FloatValue => (float)Value;
public double DoubleValue => (double)Value;
public string StringValue => (string)Value;
public byte[] BytesValue => (byte[])Value;
2025-04-22 19:34:46 +08:00
public virtual void Init(CreateExpressionOptions options)
{
}
2025-04-20 14:23:40 +08:00
public abstract void Compile(CompileContext ctx);
}
public abstract class DataNodeBase<T> : DataNodeBase
{
2025-04-22 08:13:58 +08:00
public T Value2 { get; set; }
2025-04-20 14:23:40 +08:00
public override object Value
{
get => Value2;
2025-04-22 08:13:58 +08:00
set => Value2 = (T)value;
2025-04-20 14:23:40 +08:00
}
}
public abstract class DataNodeAny : DataNodeBase
{
private object _value;
2025-04-20 15:20:13 +08:00
2025-04-20 14:23:40 +08:00
public override object Value
{
get => _value;
2025-04-22 08:13:58 +08:00
set => _value = value;
2025-04-20 14:23:40 +08:00
}
}
}