Skip to content

Commit 0f8baeb

Browse files
authored
Object value added
1 parent 4acd1e1 commit 0f8baeb

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

SourceCode/ast/lib/ObjectValue.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OwnLang.ast.lib
8+
{
9+
public class ObjectValue : Value
10+
{
11+
private object value;
12+
13+
public ObjectValue(object value)
14+
{
15+
this.value = value;
16+
}
17+
18+
public object asObject()
19+
{
20+
return value;
21+
}
22+
23+
public char asChar()
24+
{
25+
return char.Parse(value.ToString());
26+
}
27+
28+
public double asDouble()
29+
{
30+
return double.Parse(value.ToString());
31+
}
32+
33+
public int asNumber()
34+
{
35+
return int.Parse(value.ToString());
36+
}
37+
38+
public string asString()
39+
{
40+
return value.ToString();
41+
}
42+
43+
public TokenType type()
44+
{
45+
return TokenType.OBJECT;
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)