IoObject := Object clone do( name := "IoObject Proto" newSlot("slots", Map clone) newSlot("prototypes", List clone) init := method( slots = Map clone prototypes = List clone ) rawClone := method( new := self clone new prototypes append(self) new ) rawHasLocalSlot := method(name, slots hasSlot(name) ) rawGetSlot := method(name, ancestors, if(ancestors, if(ancestors contains(self), return nil) ancestors append(self) , ancestors = list(self) ) x := slots at(name) if(x != nil, return x) prototypes foreach(proto, x = proto rawGetSlot(name, ancestors) if(x != nil, return x) ) nil ) rawHasSlot := method(name, rawGetSlot(name) != nil ) rawSetSlot := method(name, value, slots atPut(name, value) self ) evalMessage := method(locals, m, next := m while(next, attached := next while(attached, target := self if(attached cachedResult, target := IoLiteral clone setLiteral(attached cachedResult) , o := rawGetSlot(attached name) if(o == nil, writeln("Slot not found: '", attached name, "'.") debug(self) debug(slots keys) debug(prototypes) return ) debug(o, attached name, attached) target := o activate(target, locals, attached) ) attached = attached attached ) next = next next ) target ) printSlots := method( slots foreach(k, v, writeln(k alignLeft(10), v) ) self ) setupProto := method( rawSetSlot("setSlot", IoCFunction clone setImplName("___setSlot")) ) ___setSlot := method(locals, m, name := locals evalMessage(locals, m argAt(0)) literal value := locals evalMessage(locals, m argAt(1)) slots atPut(name, value) self ) )