Revert "fixed bug in lib/thread Queue"
[rbx.git] / kernel / bootstrap / sendsite.rb
blob60fdef7ce84c5208af8ae813f7a68e59a4e4f5db
1 ##
2 # A SendSite exists in the InstructionSequence wherever you would call a
3 # method (send a message).  When searching for an Executable to run, the
4 # SendSite is examined first.  If there is an Executable stored inside it, it
5 # is used.  Otherwise the MethodTable is consulted (see MethodTable) and the
6 # SendSite is filled in with that Executable.
8 class SendSite
9   def self.new(name)
10     SendSite.create name
11   end
13   def self.create(name)
14     Ruby.primitive :sendsite_create
15     raise PrimitiveFailure, "primitive failed"
16   end
18   def at(index)
19     Ruby.primitive :sendsite_at
20     raise PrimitiveFailure, "primitive failed"
21   end
23   def name
24     at(0)
25   end
27   def selector
28     at(1)
29   end
31   def receiver
32     at(2)
33   end
35   def hits
36     at(6)
37   end
39   def misses
40     at(7)
41   end
43   def data(which)
44     at(1 + which)
45   end
47   def sender
48     at(8)
49   end
51   ##
52   # Sets the sender field on the SendSite.
53   # +cm+ must be a CompiledMethod object
54   def sender=(cm)
55     Ruby.primitive :sendsite_set_sender
56     raise PrimitiveFailure, "primitive failed"
57   end
59   def inspect
60     "#<SendSite:0x#{object_id.to_s(16)} name=#{name} hits=#{hits} misses=#{misses}>"
61   end
62 end