コード例 #1
0
func (d *Define) Eval(s *rt.Scope) rt.Value {
	body := NewBlock(d.Body, s)

	var obj *rt.Object
	if oid, found, _ := rt.RT.Globals.Lookup(d.Receiver); !found {
		obj = rt.CreateObject(&Global{Value: d.Receiver}, nil, 0)
		rt.RT.Globals.Insert(d.Receiver, obj.ID)
	} else {
		obj, _ = rt.RT.Heap.Lookup(oid).(*rt.Object)
	}

	obj.Behaviors[d.Behavior] = body.OID()

	rt.StartBehavior(body)
	obj.New()

	return obj
}
コード例 #2
0
func (b *Block) Visit(s *rt.Scope) rt.Value {
	obj := NewBlock(b, s)
	go rt.StartBehavior(obj)

	return obj
}