-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValue.cs
46 lines (36 loc) · 874 Bytes
/
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
interface IValue
{
int Size { get; set; }
string Type => GetType().Name;
object Value { get; }
}
record Number(int Value) : IValue
{
public int Size { get; set; } = 4;
object IValue.Value => Value.ToString();
}
record String(string Value) : IValue
{
public int Size { get; set; } = Value.Length;
object IValue.Value => Value.ToString();
}
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();
}
/*
int charSize = 2;
int stringSize = charSize * strLength;
*/