Ejemplo n.º 1
0
// TODO(mjs) Right now multiple peers are not handled for a given object
// this will have to get fixed once source code archives can also be
// posted to a broker.
//
func (r *RemoteObject) Eval(s *rt.Scope) rt.Value {
	var obj *rt.Object
	var start = false
	if oid, found, _ := rt.RT.Globals.Lookup(r.Receiver); !found {
		obj = rt.CreateObject(&Global{Value: r.Receiver}, nil, r.RID)
		rt.RT.Globals.Insert(r.Receiver, r.RID)

		obj.New()
		start = true
	} else {
		obj, _ = rt.RT.Heap.Lookup(oid).(*rt.Object)
	}

	o := rt.RT.Heap.Lookup(obj.Behaviors[r.Behavior])
	if o == nil {
		obj.Behaviors[r.Behavior] = r.BID

		start = true
	}

	if start {
		r.Peers[0].New()
	}

	return obj
}
Ejemplo n.º 2
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
}