1import System 2import Boo.Lang.Interpreter from Boo.Lang.Interpreter 3 4class ObjectInterpreter(AbstractInterpreter): 5 6 _context as object 7 8 [getter(Value)] 9 _value as object 10 11 def constructor(context): 12 _context = context 13 self.RememberLastValue = true 14 15 override def Lookup(name as string): 16 property = _context.GetType().GetProperty(name) 17 return property.PropertyType if property is not null 18 19 override def GetValue(name as string): 20 return _context.GetType().GetProperty(name).GetValue( 21 _context, null) 22 23 override def SetLastValue(value): 24 _value = value 25 26 override def SetValue(name as string, value): 27 raise InvalidOperationException() 28 29 override def Declare(name as string, type as Type): 30 raise InvalidOperationException() 31 32class Person: 33 [property(FirstName)] 34 _fname as string = "" 35 36p = Person(FirstName: "Homer") 37i = ObjectInterpreter(p) 38i.Eval('"Hello, ${FirstName.ToUpper()}!"') 39print i.Value 40