blob: d6107aa7e5a48d22949d5550334f3ed32c539a4c (
plain)
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
|
import System
import Boo.Lang.Interpreter from Boo.Lang.Interpreter
class ObjectInterpreter(AbstractInterpreter):
_context as object
[getter(Value)]
_value as object
def constructor(context):
_context = context
self.RememberLastValue = true
override def Lookup(name as string):
property = _context.GetType().GetProperty(name)
return property.PropertyType if property is not null
override def GetValue(name as string):
return _context.GetType().GetProperty(name).GetValue(
_context, null)
override def SetLastValue(value):
_value = value
override def SetValue(name as string, value):
raise InvalidOperationException()
override def Declare(name as string, type as Type):
raise InvalidOperationException()
class Person:
[property(FirstName)]
_fname as string = ""
p = Person(FirstName: "Homer")
i = ObjectInterpreter(p)
i.Eval('"Hello, ${FirstName.ToUpper()}!"')
print i.Value
|