Module: RubyBreaker::Runtime

Included in:
RubyBreaker
Defined in:
lib/rubybreaker/runtime.rb,
lib/rubybreaker/runtime/util.rb,
lib/rubybreaker/runtime/monitor.rb,
lib/rubybreaker/runtime/inspector.rb,
lib/rubybreaker/runtime/overrides.rb,
lib/rubybreaker/runtime/pluggable.rb,
lib/rubybreaker/runtime/type_system.rb,
lib/rubybreaker/runtime/object_wrapper.rb,
lib/rubybreaker/runtime/typesig_parser.rb,
lib/rubybreaker/runtime/typesig_unparser.rb

Overview

This module contains things that are needed at runtime.

Defined Under Namespace

Modules: Inspector, MonitorInstaller, Pluggable, TypeSigParser, TypeSigUnparser Classes: MethodInfo, Monitor, MonitorSwitch, ObjectWrapper, TypeSystem

Constant Summary collapse

BREAKABLES =

This set keeps track of modules/classes that will be monitored. DEPRECATED : Use breakable method instead.

Set.new
TYPE_MAP =

This hash maps a module to a nested hash that maps a method name to a method type. This hash is shared between breakable modules/classes and non-breakable modules/classes.

{}
MONITOR_MAP =

This hash maps a (breakable) module to a type monitor

{}
DEFAULT_TYPE_SYSTEM =

The default type system for RubyBreaker

TypeSystem.new
GLOBAL_MONITOR_SWITCH =

TODO:For now, we use a global switch; but in future, a switch per object should be used for multi-process apps. However, there is still a concern for module tracking in which case, there isn’t really a way to do this unless we track with the process or some unique id for that process.

MonitorSwitch.new
CONTEXT =

This context is used for keeping track of context in the user code. This will ignore the context within the RubyBreaker code, so it is easy to pinpoint program locations without distraction from the RubyBreaker code.

Context.new(ObjectPosition.new(self,"main"))
OVERRIDE_PREFIX =

This constant holds the string used internally by RubyBreaker to indicate overridden methods.

"__rubybreaker"
BLACKLIST =

Prohibit these module/class+method from being overriden.

{
  String => [:to_s, :<<, :concat, :gsub],
}
WHITELIST =

Allow certain methods of these classes/modules to be overrriden. That is, they will take unwrapped arguments whatsoever.

{
  Kernel => [:puts, :putc, :gets, :print, :printf, :raise],
  IO => [:getc, :gets, :putc, :puts, :print, :printf, 
         :readlines, :readline, :read],
  Object     => [:"==", :equal?, :eql?, :"!="], 
  Enumerable => [:"==", :equal?, :eql?, :"!="], 
  Array      => [:"==", :equal?, :eql?, :"!=", :[], :[]=], 
  Hash       => [:"==", :equal?, :eql?, :"!=", :[], :[]=],
}
WRAPPED_INDICATOR =

This constant is used to determine if an object is a wrapped object.

:"__is_wrapped?__"

Class Method Summary collapse

Class Method Details

.break(*mods) ⇒ Object

This method instruments the specified modules/classes at the time of the call so they are monitored for type documentation.



54
55
56
# File 'lib/rubybreaker/runtime.rb', line 54

def self.break(*mods)
  self.install(:break, *mods)
end

.breakable(*mods) ⇒ Object

This method modifies specified modules/classes at the very moment (instead of registering them for later). DEPRECATED: Use break() method instead



76
77
78
# File 'lib/rubybreaker/runtime.rb', line 76

def self.breakable(*mods)
  self.install(:break, *mods)
end

.check(*mods) ⇒ Object

This method instruments the specified modules/classes at the time of the call so that they are type checked during runtime.



60
61
62
# File 'lib/rubybreaker/runtime.rb', line 60

def self.check(*mods)
  self.install(:check, *mods)
end

.instrumentObject

This method installs a monitor for each breakable module. DEPRECATED: Use breakable() method instead.



66
67
68
69
70
71
# File 'lib/rubybreaker/runtime.rb', line 66

def self.instrument() 
  BREAKABLES.each do |mod|
    # Duplicate checks in place in these calls.
    MonitorInstaller.install_monitor(:break, mod)
  end
end