rubybreaker 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/NEWS +3 -0
  2. data/README.md +1 -2
  3. data/Rakefile +1 -0
  4. data/TODO +0 -8
  5. data/TUTORIAL.md +33 -7
  6. data/VERSION +1 -1
  7. data/lib/rubybreaker.rb +12 -4
  8. data/lib/rubybreaker/debug/error.rb +1 -1
  9. data/lib/rubybreaker/runtime.rb +16 -12
  10. data/lib/rubybreaker/runtime/monitor.rb +116 -84
  11. data/lib/rubybreaker/runtime/pluggable.rb +8 -2
  12. data/lib/rubybreaker/runtime/type_system.rb +77 -10
  13. data/lib/rubybreaker/task.rb +6 -0
  14. data/lib/rubybreaker/util.rb +23 -0
  15. data/test/integrated/tc_checking.rb +71 -0
  16. data/test/integrated/tc_class_methods.rb +14 -4
  17. data/test/testtask/sample.rb +1 -0
  18. data/test/testtask/tc_testtask.rb +14 -2
  19. data/test/ts_integrated.rb +1 -0
  20. data/webpage/index.html +1 -2
  21. data/webpage/rdoc/Object.html +0 -2
  22. data/webpage/rdoc/Rake.html +0 -2
  23. data/webpage/rdoc/Rake/RubyBreakerTestTask.html +19 -5
  24. data/webpage/rdoc/RubyBreaker.html +35 -3
  25. data/webpage/rdoc/RubyBreaker/Breakable.html +1 -3
  26. data/webpage/rdoc/RubyBreaker/Broken.html +1 -3
  27. data/webpage/rdoc/RubyBreaker/Context.html +0 -2
  28. data/webpage/rdoc/RubyBreaker/Errors.html +0 -2
  29. data/webpage/rdoc/RubyBreaker/Errors/InternalError.html +0 -2
  30. data/webpage/rdoc/RubyBreaker/Errors/InvalidSubtypeCheck.html +0 -2
  31. data/webpage/rdoc/RubyBreaker/Errors/InvalidTypeConstruction.html +0 -2
  32. data/webpage/rdoc/RubyBreaker/Errors/SubtypeFailure.html +0 -2
  33. data/webpage/rdoc/RubyBreaker/Errors/TypeError.html +0 -2
  34. data/webpage/rdoc/RubyBreaker/Errors/UserError.html +2 -4
  35. data/webpage/rdoc/RubyBreaker/ObjectPosition.html +0 -2
  36. data/webpage/rdoc/RubyBreaker/Position.html +0 -2
  37. data/webpage/rdoc/RubyBreaker/RDocSupport.html +0 -2
  38. data/webpage/rdoc/RubyBreaker/RubyTypeUtils.html +0 -2
  39. data/webpage/rdoc/RubyBreaker/Runtime.html +39 -6
  40. data/webpage/rdoc/RubyBreaker/Runtime/Inspector.html +0 -2
  41. data/webpage/rdoc/RubyBreaker/Runtime/MethodInfo.html +0 -2
  42. data/webpage/rdoc/RubyBreaker/Runtime/Monitor.html +295 -28
  43. data/webpage/rdoc/RubyBreaker/Runtime/MonitorInstaller.html +30 -43
  44. data/webpage/rdoc/RubyBreaker/Runtime/MonitorSwitch.html +4 -6
  45. data/webpage/rdoc/RubyBreaker/Runtime/ObjectWrapper.html +0 -2
  46. data/webpage/rdoc/RubyBreaker/Runtime/Pluggable.html +78 -18
  47. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigParser.html +0 -2
  48. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigUnparser.html +0 -2
  49. data/webpage/rdoc/RubyBreaker/Runtime/TypeSystem.html +172 -28
  50. data/webpage/rdoc/RubyBreaker/TypeComparer.html +0 -2
  51. data/webpage/rdoc/RubyBreaker/TypeDefs.html +0 -2
  52. data/webpage/rdoc/RubyBreaker/TypeDefs/AnyType.html +0 -2
  53. data/webpage/rdoc/RubyBreaker/TypeDefs/BlockType.html +0 -2
  54. data/webpage/rdoc/RubyBreaker/TypeDefs/DuckType.html +0 -2
  55. data/webpage/rdoc/RubyBreaker/TypeDefs/FusionType.html +0 -2
  56. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodListType.html +0 -2
  57. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodType.html +0 -2
  58. data/webpage/rdoc/RubyBreaker/TypeDefs/NilType.html +0 -2
  59. data/webpage/rdoc/RubyBreaker/TypeDefs/NominalType.html +0 -2
  60. data/webpage/rdoc/RubyBreaker/TypeDefs/OptionalType.html +0 -2
  61. data/webpage/rdoc/RubyBreaker/TypeDefs/OrType.html +0 -2
  62. data/webpage/rdoc/RubyBreaker/TypeDefs/SelfType.html +0 -2
  63. data/webpage/rdoc/RubyBreaker/TypeDefs/Type.html +0 -2
  64. data/webpage/rdoc/RubyBreaker/TypeDefs/VarLengthType.html +0 -2
  65. data/webpage/rdoc/RubyBreaker/TypeUnparser.html +0 -2
  66. data/webpage/rdoc/RubyBreaker/Typing.html +0 -2
  67. data/webpage/rdoc/RubyBreaker/Util.html +80 -4
  68. data/webpage/rdoc/Test.html +0 -2
  69. data/webpage/rdoc/Test/Unit.html +0 -2
  70. data/webpage/rdoc/created.rid +12 -12
  71. data/webpage/rdoc/index.html +0 -2
  72. data/webpage/rdoc/js/search_index.js +1 -1
  73. data/webpage/rdoc/table_of_contents.html +53 -34
  74. data/webpage/tutorial.html +36 -7
  75. metadata +8 -11
  76. data/webpage/rdoc/RubyBreaker/Runtime/MonitorUtils.html +0 -402
@@ -57,19 +57,7 @@
57
57
  <div id="class-metadata">
58
58
 
59
59
 
60
- <!-- Included Modules -->
61
- <nav id="includes-section" class="section">
62
- <h3 class="section-header">Included Modules</h3>
63
-
64
- <ul class="link-list">
65
-
66
-
67
- <li><a class="include" href="MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
68
-
69
-
70
- </ul>
71
- </nav>
72
-
60
+
73
61
  <!-- Method Quickref -->
74
62
  <nav id="method-list-section" class="section">
75
63
  <h3 class="section-header">Methods</h3>
@@ -80,7 +68,7 @@
80
68
 
81
69
  <li><a href="#method-c-is_module-3F">::is_module?</a>
82
70
 
83
- <li><a href="#method-c-rename_meth">::rename_meth</a>
71
+ <li><a href="#method-c-monkey_patch_meth">::monkey_patch_meth</a>
84
72
 
85
73
  </ul>
86
74
  </nav>
@@ -136,8 +124,6 @@
136
124
 
137
125
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
138
126
 
139
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
140
-
141
127
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
142
128
 
143
129
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -231,7 +217,7 @@
231
217
 
232
218
  <div class="method-heading">
233
219
  <span class="method-name">install_monitor</span><span
234
- class="method-args">(mod)</span>
220
+ class="method-args">(monitor_type, mod)</span>
235
221
  <span class="method-click-advice">click to toggle source</span>
236
222
  </div>
237
223
 
@@ -243,8 +229,8 @@
243
229
 
244
230
 
245
231
  <div class="method-source-code" id="install_monitor-source">
246
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 209</span>
247
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">install_monitor</span>(<span class="ruby-identifier">mod</span>)
232
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 238</span>
233
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">install_monitor</span>(<span class="ruby-identifier">monitor_type</span>, <span class="ruby-identifier">mod</span>)
248
234
 
249
235
  <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;Installing module monitor for #{mod}&quot;</span>)
250
236
 
@@ -254,7 +240,7 @@
254
240
  <span class="ruby-keyword">return</span>
255
241
  <span class="ruby-keyword">end</span>
256
242
 
257
- <span class="ruby-constant">MONITOR_MAP</span>[<span class="ruby-identifier">mod</span>] = <span class="ruby-constant">Monitor</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-constant">DEFAULT_TYPE_SYSTEM</span>)
243
+ <span class="ruby-constant">MONITOR_MAP</span>[<span class="ruby-identifier">mod</span>] = <span class="ruby-constant">Monitor</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">DEFAULT_TYPE_SYSTEM</span>)
258
244
 
259
245
  <span class="ruby-comment"># Create the type map if it does not exist already. Remember, this</span>
260
246
  <span class="ruby-comment"># map could have been made by typesig().</span>
@@ -264,12 +250,15 @@
264
250
  <span class="ruby-comment"># methods. Those are part of the owner's not this module.</span>
265
251
  <span class="ruby-identifier">meths</span> = <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">false</span>)
266
252
 
267
- <span class="ruby-comment"># See if any method is already broken (explicitly typesig'ed)</span>
268
- <span class="ruby-identifier">broken_mt_map</span> = <span class="ruby-constant">Inspector</span>.<span class="ruby-identifier">inspect_all</span>(<span class="ruby-identifier">mod</span>)
269
- <span class="ruby-identifier">broken_meths</span> = <span class="ruby-identifier">broken_mt_map</span>.<span class="ruby-identifier">keys</span>
253
+ <span class="ruby-comment"># See if any method is already documented (explicitly typesig'ed)</span>
254
+ <span class="ruby-identifier">doc_mt_map</span> = <span class="ruby-constant">Inspector</span>.<span class="ruby-identifier">inspect_all</span>(<span class="ruby-identifier">mod</span>)
255
+ <span class="ruby-identifier">doc_meths</span> = <span class="ruby-identifier">doc_mt_map</span>.<span class="ruby-identifier">keys</span>
270
256
 
271
257
  <span class="ruby-identifier">meths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span>
272
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">rename_meth</span>(<span class="ruby-identifier">mod</span>,<span class="ruby-identifier">m</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">broken_meths</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">m</span>)
258
+ <span class="ruby-comment"># Documented method will not be monkey-patched for &quot;breaking&quot;</span>
259
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">monitor_type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:break</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">doc_meths</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">m</span>)
260
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">monkey_patch_meth</span>(<span class="ruby-identifier">monitor_type</span>, <span class="ruby-identifier">mod</span>, <span class="ruby-identifier">m</span>)
261
+ <span class="ruby-keyword">end</span>
273
262
  <span class="ruby-keyword">end</span>
274
263
 
275
264
  <span class="ruby-keyword">end</span></pre>
@@ -287,7 +276,7 @@
287
276
 
288
277
  <div class="method-heading">
289
278
  <span class="method-name">is_module?</span><span
290
- class="method-args">(recv)</span>
279
+ class="method-args">(mod)</span>
291
280
  <span class="method-click-advice">click to toggle source</span>
292
281
  </div>
293
282
 
@@ -299,9 +288,9 @@
299
288
 
300
289
 
301
290
  <div class="method-source-code" id="is_module-3F-source">
302
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 188</span>
303
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">is_module?</span>(<span class="ruby-identifier">recv</span>)
304
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">recv</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:class</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">recv</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Module</span>)
291
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 219</span>
292
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">is_module?</span>(<span class="ruby-identifier">mod</span>)
293
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:class</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Module</span>)
305
294
  <span class="ruby-keyword">end</span></pre>
306
295
  </div><!-- is_module-3F-source -->
307
296
 
@@ -313,11 +302,11 @@
313
302
  </div><!-- is_module-3F-method -->
314
303
 
315
304
 
316
- <div id="method-c-rename_meth" class="method-detail ">
305
+ <div id="method-c-monkey_patch_meth" class="method-detail ">
317
306
 
318
307
  <div class="method-heading">
319
- <span class="method-name">rename_meth</span><span
320
- class="method-args">(recv, meth_name)</span>
308
+ <span class="method-name">monkey_patch_meth</span><span
309
+ class="method-args">(monitor_type, mod, meth_name)</span>
321
310
  <span class="method-click-advice">click to toggle source</span>
322
311
  </div>
323
312
 
@@ -329,28 +318,26 @@ monitor for the class</p>
329
318
 
330
319
 
331
320
 
332
- <div class="method-source-code" id="rename_meth-source">
333
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 194</span>
334
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">rename_meth</span>(<span class="ruby-identifier">recv</span>, <span class="ruby-identifier">meth_name</span>)
335
- <span class="ruby-identifier">alt_meth_name</span> = <span class="ruby-constant">MonitorUtils</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>)
336
- <span class="ruby-identifier">recv</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-node">&quot;alias :\&quot;#{alt_meth_name}\&quot; :\&quot;#{meth_name}\&quot;&quot;</span>)
321
+ <div class="method-source-code" id="monkey_patch_meth-source">
322
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 225</span>
323
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">monkey_patch_meth</span>(<span class="ruby-identifier">monitor_type</span>, <span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>)
324
+ <span class="ruby-identifier">alt_meth_name</span> = <span class="ruby-constant">Monitor</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>)
325
+ <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-node">&quot;alias :\&quot;#{alt_meth_name}\&quot; :\&quot;#{meth_name}\&quot;&quot;</span>)
337
326
  <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;Adding alternate method for #{meth_name}&quot;</span>)
338
- <span class="ruby-identifier">recv</span>.<span class="ruby-identifier">module_eval</span> <span class="ruby-string">&quot; def #{meth_name}(*args, &amp;blk)
339
- RubyBreaker::Runtime::MonitorUtils.route(self,
340
- &quot;#{meth_name}&quot;,
341
- *args,
342
- &amp;blk)
327
+ <span class="ruby-identifier">route_call</span> = <span class="ruby-string">&quot;RubyBreaker::Runtime::Monitor.route&quot;</span>
328
+ <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">module_eval</span> <span class="ruby-string">&quot; def #{meth_name}(*args, &amp;blk)
329
+ #{route_call}(:#{monitor_type}, self,&quot;#{meth_name}&quot;,*args,&amp;blk)
343
330
  end
344
331
  &quot;</span>
345
332
  <span class="ruby-keyword">end</span></pre>
346
- </div><!-- rename_meth-source -->
333
+ </div><!-- monkey_patch_meth-source -->
347
334
 
348
335
  </div>
349
336
 
350
337
 
351
338
 
352
339
 
353
- </div><!-- rename_meth-method -->
340
+ </div><!-- monkey_patch_meth-method -->
354
341
 
355
342
 
356
343
  </section><!-- public-class-method-details -->
@@ -132,8 +132,6 @@
132
132
 
133
133
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
134
134
 
135
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
136
-
137
135
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
138
136
 
139
137
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -261,7 +259,7 @@ otherwise, it WILL fall into an infinite loop.</p>
261
259
 
262
260
 
263
261
  <div class="method-source-code" id="new-source">
264
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 53</span>
262
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 187</span>
265
263
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(); <span class="ruby-ivar">@switch</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">end</span></pre>
266
264
  </div><!-- new-source -->
267
265
 
@@ -295,7 +293,7 @@ otherwise, it WILL fall into an infinite loop.</p>
295
293
 
296
294
 
297
295
  <div class="method-source-code" id="set_to-source">
298
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 65</span>
296
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 199</span>
299
297
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">set_to</span>(<span class="ruby-identifier">mode</span>); <span class="ruby-ivar">@switch</span> = <span class="ruby-identifier">mode</span>; <span class="ruby-keyword">end</span></pre>
300
298
  </div><!-- set_to-source -->
301
299
 
@@ -323,7 +321,7 @@ otherwise, it WILL fall into an infinite loop.</p>
323
321
 
324
322
 
325
323
  <div class="method-source-code" id="turn_off-source">
326
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 60</span>
324
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 194</span>
327
325
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">turn_off</span>();
328
326
  <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-string">&quot;Switch turned off&quot;</span>)
329
327
  <span class="ruby-ivar">@switch</span> = <span class="ruby-keyword">false</span>;
@@ -354,7 +352,7 @@ otherwise, it WILL fall into an infinite loop.</p>
354
352
 
355
353
 
356
354
  <div class="method-source-code" id="turn_on-source">
357
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 55</span>
355
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 189</span>
358
356
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">turn_on</span>();
359
357
  <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-string">&quot;Switch turned on&quot;</span>)
360
358
  <span class="ruby-ivar">@switch</span> = <span class="ruby-keyword">true</span>;
@@ -134,8 +134,6 @@
134
134
 
135
135
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
136
136
 
137
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
138
-
139
137
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
140
138
 
141
139
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -64,9 +64,13 @@
64
64
 
65
65
  <ul class="link-list">
66
66
 
67
- <li><a href="#method-i-after_method_call">#after_method_call</a>
67
+ <li><a href="#method-i-break_after_method_call">#break_after_method_call</a>
68
68
 
69
- <li><a href="#method-i-before_method_call">#before_method_call</a>
69
+ <li><a href="#method-i-break_before_method_call">#break_before_method_call</a>
70
+
71
+ <li><a href="#method-i-check_after_method_call">#check_after_method_call</a>
72
+
73
+ <li><a href="#method-i-check_before_method_call">#check_before_method_call</a>
70
74
 
71
75
  </ul>
72
76
  </nav>
@@ -122,8 +126,6 @@
122
126
 
123
127
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
124
128
 
125
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
126
-
127
129
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
128
130
 
129
131
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -218,10 +220,10 @@ href="../../RubyBreaker.html">RubyBreaker</a>.</p>
218
220
  <h3 class="section-header">Public Instance Methods</h3>
219
221
 
220
222
 
221
- <div id="method-i-after_method_call" class="method-detail ">
223
+ <div id="method-i-break_after_method_call" class="method-detail ">
222
224
 
223
225
  <div class="method-heading">
224
- <span class="method-name">after_method_call</span><span
226
+ <span class="method-name">break_after_method_call</span><span
225
227
  class="method-args">(obj, meth_info)</span>
226
228
  <span class="method-click-advice">click to toggle source</span>
227
229
  </div>
@@ -241,24 +243,24 @@ call information</p>
241
243
 
242
244
 
243
245
 
244
- <div class="method-source-code" id="after_method_call-source">
245
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 49</span>
246
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">after_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
246
+ <div class="method-source-code" id="break_after_method_call-source">
247
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 55</span>
248
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_after_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
247
249
  <span class="ruby-keyword">end</span></pre>
248
- </div><!-- after_method_call-source -->
250
+ </div><!-- break_after_method_call-source -->
249
251
 
250
252
  </div>
251
253
 
252
254
 
253
255
 
254
256
 
255
- </div><!-- after_method_call-method -->
257
+ </div><!-- break_after_method_call-method -->
256
258
 
257
259
 
258
- <div id="method-i-before_method_call" class="method-detail ">
260
+ <div id="method-i-break_before_method_call" class="method-detail ">
259
261
 
260
262
  <div class="method-heading">
261
- <span class="method-name">before_method_call</span><span
263
+ <span class="method-name">break_before_method_call</span><span
262
264
  class="method-args">(obj, meth_info)</span>
263
265
  <span class="method-click-advice">click to toggle source</span>
264
266
  </div>
@@ -278,18 +280,76 @@ call information</p>
278
280
 
279
281
 
280
282
 
281
- <div class="method-source-code" id="before_method_call-source">
282
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 40</span>
283
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">before_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
283
+ <div class="method-source-code" id="break_before_method_call-source">
284
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 46</span>
285
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_before_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
286
+ <span class="ruby-keyword">end</span></pre>
287
+ </div><!-- break_before_method_call-source -->
288
+
289
+ </div>
290
+
291
+
292
+
293
+
294
+ </div><!-- break_before_method_call-method -->
295
+
296
+
297
+ <div id="method-i-check_after_method_call" class="method-detail ">
298
+
299
+ <div class="method-heading">
300
+ <span class="method-name">check_after_method_call</span><span
301
+ class="method-args">(obj, meth_info)</span>
302
+ <span class="method-click-advice">click to toggle source</span>
303
+ </div>
304
+
305
+
306
+ <div class="method-description">
307
+
308
+
309
+
310
+
311
+
312
+ <div class="method-source-code" id="check_after_method_call-source">
313
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 37</span>
314
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_after_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
315
+ <span class="ruby-keyword">end</span></pre>
316
+ </div><!-- check_after_method_call-source -->
317
+
318
+ </div>
319
+
320
+
321
+
322
+
323
+ </div><!-- check_after_method_call-method -->
324
+
325
+
326
+ <div id="method-i-check_before_method_call" class="method-detail ">
327
+
328
+ <div class="method-heading">
329
+ <span class="method-name">check_before_method_call</span><span
330
+ class="method-args">(obj, meth_info)</span>
331
+ <span class="method-click-advice">click to toggle source</span>
332
+ </div>
333
+
334
+
335
+ <div class="method-description">
336
+
337
+
338
+
339
+
340
+
341
+ <div class="method-source-code" id="check_before_method_call-source">
342
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/pluggable.rb, line 34</span>
343
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_before_method_call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
284
344
  <span class="ruby-keyword">end</span></pre>
285
- </div><!-- before_method_call-source -->
345
+ </div><!-- check_before_method_call-source -->
286
346
 
287
347
  </div>
288
348
 
289
349
 
290
350
 
291
351
 
292
- </div><!-- before_method_call-method -->
352
+ </div><!-- check_before_method_call-method -->
293
353
 
294
354
 
295
355
  </section><!-- public-instance-method-details -->
@@ -120,8 +120,6 @@
120
120
 
121
121
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
122
122
 
123
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
124
-
125
123
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
126
124
 
127
125
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -136,8 +136,6 @@
136
136
 
137
137
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
138
138
 
139
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
140
-
141
139
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
142
140
 
143
141
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -86,9 +86,13 @@
86
86
 
87
87
  <ul class="link-list">
88
88
 
89
- <li><a href="#method-i-after_method">#after_method</a>
89
+ <li><a href="#method-i-break_after_method">#break_after_method</a>
90
90
 
91
- <li><a href="#method-i-before_method">#before_method</a>
91
+ <li><a href="#method-i-break_before_method">#break_before_method</a>
92
+
93
+ <li><a href="#method-i-check_after_method">#check_after_method</a>
94
+
95
+ <li><a href="#method-i-check_before_method">#check_before_method</a>
92
96
 
93
97
  <li><a href="#method-i-is_object_wrapped-3F">#is_object_wrapped?</a>
94
98
 
@@ -96,6 +100,8 @@
96
100
 
97
101
  <li><a href="#method-i-lub_helper">#lub_helper</a>
98
102
 
103
+ <li><a href="#method-i-type_error_msg_prefix">#type_error_msg_prefix</a>
104
+
99
105
  </ul>
100
106
  </nav>
101
107
 
@@ -150,8 +156,6 @@
150
156
 
151
157
  <li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
152
158
 
153
- <li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
154
-
155
159
  <li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
156
160
 
157
161
  <li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
@@ -244,10 +248,10 @@ be done.</p>
244
248
  <h3 class="section-header">Public Instance Methods</h3>
245
249
 
246
250
 
247
- <div id="method-i-after_method" class="method-detail ">
251
+ <div id="method-i-break_after_method" class="method-detail ">
248
252
 
249
253
  <div class="method-heading">
250
- <span class="method-name">after_method</span><span
254
+ <span class="method-name">break_after_method</span><span
251
255
  class="method-args">(obj, meth_info)</span>
252
256
  <span class="method-click-advice">click to toggle source</span>
253
257
  </div>
@@ -255,14 +259,14 @@ be done.</p>
255
259
 
256
260
  <div class="method-description">
257
261
 
258
- <p>This method occurs after every “monitored” method call. It updates the type
259
- information.</p>
262
+ <p>This method occurs after every call to a “monitored” method call of a
263
+ module/class specified for “breaking”. It updates the type information.</p>
260
264
 
261
265
 
262
266
 
263
- <div class="method-source-code" id="after_method-source">
264
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 234</span>
265
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
267
+ <div class="method-source-code" id="break_after_method-source">
268
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 301</span>
269
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
266
270
 
267
271
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
268
272
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
@@ -287,20 +291,20 @@ information.</p>
287
291
  <span class="ruby-keyword">end</span>
288
292
 
289
293
  <span class="ruby-keyword">end</span></pre>
290
- </div><!-- after_method-source -->
294
+ </div><!-- break_after_method-source -->
291
295
 
292
296
  </div>
293
297
 
294
298
 
295
299
 
296
300
 
297
- </div><!-- after_method-method -->
301
+ </div><!-- break_after_method-method -->
298
302
 
299
303
 
300
- <div id="method-i-before_method" class="method-detail ">
304
+ <div id="method-i-break_before_method" class="method-detail ">
301
305
 
302
306
  <div class="method-heading">
303
- <span class="method-name">before_method</span><span
307
+ <span class="method-name">break_before_method</span><span
304
308
  class="method-args">(obj, meth_info)</span>
305
309
  <span class="method-click-advice">click to toggle source</span>
306
310
  </div>
@@ -308,15 +312,18 @@ information.</p>
308
312
 
309
313
  <div class="method-description">
310
314
 
311
- <p>This method occurs before every “monitored” method call. It wraps each
312
- argument with the object wrapper.</p>
315
+ <p>This method occurs before every call to a “monitored” method in a
316
+ module/class specified for breaking. It wraps each argument with the object
317
+ wrapper so it can be tracked of the method calls.</p>
313
318
 
314
319
 
315
320
 
316
- <div class="method-source-code" id="before_method-source">
317
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 174</span>
318
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
321
+ <div class="method-source-code" id="break_before_method-source">
322
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 238</span>
323
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
319
324
 
325
+ <span class="ruby-comment"># Use the eigen class if the object is a module/class and use the</span>
326
+ <span class="ruby-comment"># object's class otherwise.</span>
320
327
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
321
328
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
322
329
 
@@ -345,7 +352,7 @@ argument with the object wrapper.</p>
345
352
  <span class="ruby-comment"># This means the method type has been created previously.</span>
346
353
  <span class="ruby-keyword">unless</span> (<span class="ruby-identifier">blk</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">blk_type</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>) <span class="ruby-operator">&amp;&amp;</span>
347
354
  (<span class="ruby-operator">!</span><span class="ruby-identifier">blk</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">blk</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">blk_type</span>.<span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">length</span>)
348
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span>(<span class="ruby-string">&quot;Block usage is inconsistent&quot;</span>)
355
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Block usage is inconsistent&quot;</span>)
349
356
  <span class="ruby-keyword">end</span>
350
357
  <span class="ruby-keyword">else</span>
351
358
  <span class="ruby-comment"># No method type has been created for this method yet. Create a</span>
@@ -354,7 +361,7 @@ argument with the object wrapper.</p>
354
361
  <span class="ruby-comment">#</span>
355
362
  <span class="ruby-comment"># First, use the orignal method's arity to find out # of</span>
356
363
  <span class="ruby-comment"># arguments. </span>
357
- <span class="ruby-identifier">meth_obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">method</span>(<span class="ruby-constant">MonitorUtils</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>))
364
+ <span class="ruby-identifier">meth_obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">method</span>(<span class="ruby-constant">Monitor</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>))
358
365
  <span class="ruby-identifier">arity</span> = <span class="ruby-identifier">meth_obj</span>.<span class="ruby-identifier">arity</span>
359
366
  <span class="ruby-identifier">arg_types</span> = [<span class="ruby-keyword">nil</span>] * <span class="ruby-identifier">meth_obj</span>.<span class="ruby-identifier">arity</span>.<span class="ruby-identifier">abs</span>
360
367
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">blk</span>
@@ -372,14 +379,118 @@ argument with the object wrapper.</p>
372
379
  <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>
373
380
 
374
381
  <span class="ruby-keyword">end</span></pre>
375
- </div><!-- before_method-source -->
382
+ </div><!-- break_before_method-source -->
376
383
 
377
384
  </div>
378
385
 
379
386
 
380
387
 
381
388
 
382
- </div><!-- before_method-method -->
389
+ </div><!-- break_before_method-method -->
390
+
391
+
392
+ <div id="method-i-check_after_method" class="method-detail ">
393
+
394
+ <div class="method-heading">
395
+ <span class="method-name">check_after_method</span><span
396
+ class="method-args">(obj, meth_info)</span>
397
+ <span class="method-click-advice">click to toggle source</span>
398
+ </div>
399
+
400
+
401
+ <div class="method-description">
402
+
403
+ <p>This method is invoked after the original method is executed.</p>
404
+
405
+
406
+
407
+ <div class="method-source-code" id="check_after_method-source">
408
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 211</span>
409
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
410
+ <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
411
+ <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
412
+
413
+ <span class="ruby-identifier">meth_type_map</span> = <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>]
414
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">meth_type_map</span>
415
+
416
+ <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
417
+ <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
418
+ <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
419
+ <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
420
+ <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
421
+
422
+ <span class="ruby-comment"># Get the registered method type for this method</span>
423
+ <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
424
+
425
+ <span class="ruby-identifier">ret_type</span> = <span class="ruby-constant">NominalType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ret</span>.<span class="ruby-identifier">class</span>)
426
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">ret_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">ret_type</span>)
427
+ <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
428
+ <span class="ruby-node">&quot; return value does not have type #{ret_type.unparse()}.&quot;</span>
429
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
430
+ <span class="ruby-keyword">end</span>
431
+ <span class="ruby-keyword">end</span></pre>
432
+ </div><!-- check_after_method-source -->
433
+
434
+ </div>
435
+
436
+
437
+
438
+
439
+ </div><!-- check_after_method-method -->
440
+
441
+
442
+ <div id="method-i-check_before_method" class="method-detail ">
443
+
444
+ <div class="method-heading">
445
+ <span class="method-name">check_before_method</span><span
446
+ class="method-args">(obj, meth_info)</span>
447
+ <span class="method-click-advice">click to toggle source</span>
448
+ </div>
449
+
450
+
451
+ <div class="method-description">
452
+
453
+ <p>This method is invoked before the original method is executed.</p>
454
+
455
+
456
+
457
+ <div class="method-source-code" id="check_before_method-source">
458
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 182</span>
459
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
460
+ <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
461
+ <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
462
+
463
+ <span class="ruby-identifier">meth_type_map</span> = <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>]
464
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">meth_type_map</span>
465
+
466
+ <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
467
+ <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
468
+ <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
469
+ <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
470
+ <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
471
+
472
+ <span class="ruby-comment"># Get the registered method type for this method</span>
473
+ <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
474
+
475
+ <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
476
+ <span class="ruby-identifier">arg_type</span> = <span class="ruby-constant">NominalType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">arg</span>.<span class="ruby-identifier">class</span>)
477
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">arg_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>[<span class="ruby-identifier">i</span>])
478
+ <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
479
+ <span class="ruby-node">&quot;'s #{Util.ordinalize(i+1)} argument &quot;</span> <span class="ruby-operator">+</span>
480
+ <span class="ruby-node">&quot;does not have type #{arg_type.unparse()}.&quot;</span>
481
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
482
+ <span class="ruby-keyword">end</span>
483
+ <span class="ruby-keyword">end</span>
484
+
485
+ <span class="ruby-keyword">end</span></pre>
486
+ </div><!-- check_before_method-source -->
487
+
488
+ </div>
489
+
490
+
491
+
492
+
493
+ </div><!-- check_before_method-method -->
383
494
 
384
495
 
385
496
  </section><!-- public-instance-method-details -->
@@ -404,7 +515,7 @@ argument with the object wrapper.</p>
404
515
 
405
516
 
406
517
  <div class="method-source-code" id="is_object_wrapped-3F-source">
407
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 30</span>
518
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 31</span>
408
519
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">is_object_wrapped?</span>(<span class="ruby-identifier">obj</span>)
409
520
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-constant">WRAPPED_INDICATOR</span>)
410
521
  <span class="ruby-keyword">end</span></pre>
@@ -477,13 +588,13 @@ method list type.</p>
477
588
 
478
589
 
479
590
  <div class="method-source-code" id="lub-source">
480
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 115</span>
591
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 116</span>
481
592
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">lub</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_type_map</span>, <span class="ruby-identifier">meth_name</span>, <span class="ruby-identifier">retval</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
482
593
 
483
594
  <span class="ruby-identifier">exist_meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>.<span class="ruby-identifier">to_sym</span>]
484
595
 
485
596
  <span class="ruby-comment"># Again, find the arity</span>
486
- <span class="ruby-identifier">meth_obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">method</span>(<span class="ruby-constant">MonitorUtils</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>))
597
+ <span class="ruby-identifier">meth_obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">method</span>(<span class="ruby-constant">Monitor</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>))
487
598
  <span class="ruby-identifier">arity</span> = <span class="ruby-identifier">meth_obj</span>.<span class="ruby-identifier">arity</span>
488
599
 
489
600
  <span class="ruby-comment"># Construct the newly observed method type first</span>
@@ -531,6 +642,7 @@ method list type.</p>
531
642
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">resolved</span>
532
643
  <span class="ruby-identifier">exist_meth_type</span>.<span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">new_meth_type</span>
533
644
  <span class="ruby-keyword">end</span>
645
+
534
646
  <span class="ruby-keyword">end</span></pre>
535
647
  </div><!-- lub-source -->
536
648
 
@@ -561,7 +673,7 @@ false.</p>
561
673
 
562
674
 
563
675
  <div class="method-source-code" id="lub_helper-source">
564
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 38</span>
676
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 39</span>
565
677
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">lub_helper</span>(<span class="ruby-identifier">exist_meth_type</span>, <span class="ruby-identifier">new_meth_type</span>)
566
678
 
567
679
  <span class="ruby-comment"># most restrictive for the given test cases. </span>
@@ -615,6 +727,38 @@ false.</p>
615
727
  </div><!-- lub_helper-method -->
616
728
 
617
729
 
730
+ <div id="method-i-type_error_msg_prefix" class="method-detail ">
731
+
732
+ <div class="method-heading">
733
+ <span class="method-name">type_error_msg_prefix</span><span
734
+ class="method-args">(mod, meth_name)</span>
735
+ <span class="method-click-advice">click to toggle source</span>
736
+ </div>
737
+
738
+
739
+ <div class="method-description">
740
+
741
+ <p>This method creates the prefix for the type error message.</p>
742
+
743
+
744
+
745
+ <div class="method-source-code" id="type_error_msg_prefix-source">
746
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 173</span>
747
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>)
748
+ <span class="ruby-identifier">result</span> = <span class="ruby-node">%r#&lt;Class:(.+)&gt;/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">&quot;#{mod}&quot;</span>)
749
+ <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">result</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{result[1]}.&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{mod}#&quot;</span>
750
+ <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;#{prefix}#{meth_name}&quot;</span>
751
+ <span class="ruby-keyword">end</span></pre>
752
+ </div><!-- type_error_msg_prefix-source -->
753
+
754
+ </div>
755
+
756
+
757
+
758
+
759
+ </div><!-- type_error_msg_prefix-method -->
760
+
761
+
618
762
  </section><!-- protected-instance-method-details -->
619
763
 
620
764
  </section><!-- 5Buntitled-5D -->