-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValue.cs
49 lines (39 loc) · 1.06 KB
/
Value.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
interface IValue
{
public int Size { get; set; }
public string Type => GetType().Name;
public object Value { get; }
}
record Number(int Value) : IValue
{
public int Size { get; set; } = 4;
object IValue.Value => Value.ToString();
}
record Obj(object Value, int Size, int Pointer) : IValue
{
public int Pointer { get; set; } = Pointer;
int IValue.Size { get; set; } = Size;
object IValue.Value => Value;
}
record String(string Val, int Pointer) : Obj(Val, Val.Length, Pointer)
{
public new int Pointer = Pointer;
public new int Size { get; set; } = Val.Length;
public new object Value => Value;
}
record Char(char Value) : IValue
{
public int Size { get; set; } = 1;
object IValue.Value => Value.ToString();
}
record Nil() : IValue
{
public int Size { get; set; } = 0;
object IValue.Value => "Nil";
}
record Boolean(bool Value) : IValue
{
// Since bools are converted to ints : )
public int Size { get; set; } = 4;
object IValue.Value => Value.ToString();
}