Module: Police::DataFlow::Gating
- Defined in:
- lib/police/dataflow/gating.rb
Overview
Gating logic.
Class Method Summary collapse
-
.gate_class_method(module_object, method) ⇒ Object
Sets up a label-propagating gate around a native method.
-
.gate_instance_method(module_object, method) ⇒ Object
Sets up a label-propagating gate around a native method.
-
.setup_gates ⇒ Object
Sets up label-propagating gates around all the native methods in the VM.
-
.setup_gates! ⇒ Object
Sets up label-propagating gates around all the native methods in Ruby.
Class Method Details
.gate_class_method(module_object, method) ⇒ Object
Sets up a label-propagating gate around a native method.
47 48 49 |
# File 'lib/police/dataflow/gating.rb', line 47 def self.gate_class_method(module_object, method) gate_instance_method module_object.singleton_class, method end |
.gate_instance_method(module_object, method) ⇒ Object
Sets up a label-propagating gate around a native method.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/police/dataflow/gating.rb', line 56 def self.gate_instance_method(module_object, method) alias_name = :"__police_gated__#{method.name}" if module_object.public_method_defined?(alias_name) || module_object.private_method_defined?(alias_name) || module_object.protected_method_defined?(alias_name) raise RuntimeError, "#{method.inspect} was already gated" end # TODO(pwnall): finish this code end |
.setup_gates ⇒ Object
Sets up label-propagating gates around all the native methods in the VM.
This method is idempotent, so it is safe to call it multiple times.
18 19 20 21 22 |
# File 'lib/police/dataflow/gating.rb', line 18 def self.setup_gates return if @gates_set setup_gates! @gates_set = true end |
.setup_gates! ⇒ Object
Sets up label-propagating gates around all the native methods in Ruby.
Call setup_gates instead of calling this method directly.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/police/dataflow/gating.rb', line 29 def self.setup_gates! Police::VmInfo.named_modules do |module_object| Police::VmInfo.class_methods(module_object).each do |method| next unless Police::VmInfo.method_source(method) == :native gate_class_method module_object, method end Police::VmInfo.instance_methods(module_object).each do |method| next unless Police::VmInfo.method_source(method) == :native gate_instance_method module_object, method end end end |