<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -24,6 +24,6 @@ RubyValue eval_hook(RubyEnvironment &amp;_e, linked_ptr&lt;Binding&gt; _binding, RubyValue
   Reader reader(iss);
 
   Context *c = new Context(_binding);
-  return process(_e, reader, c);
+  return process(_e, reader, c, NULL);
 }
 </diff>
      <filename>ruby/eval.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -49,7 +49,7 @@ int irb(int, char **)
     std::istringstream iss(bytecode.str());
     Reader reader(iss);
 
-    RubyValue result = process(e, reader, c);
+    RubyValue result = process(e, reader, c, NULL);
     std::cout &lt;&lt; &quot;=&gt; &quot;;
     RubyValue inspection = result.call(c-&gt;binding, &quot;inspect&quot;);
     std::cout &lt;&lt; dynamic_cast&lt;RubyString *&gt;(inspection.object)-&gt;string_value</diff>
      <filename>ruby/irb.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@ int twophase(int, char **)
   Reader reader(iss);
   Context *c = new Context(e, RubyValue::from_object(e.main));
 
-  process(e, reader, c);
+  process(e, reader, c, NULL);
 
   return 0;
 }</diff>
      <filename>ruby/twophase.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -43,10 +43,30 @@ RubyValue Block::call(linked_ptr&lt;Binding&gt; &amp;_b, const std::vector&lt;RubyValue&gt; &amp;_ar
   for (unsigned int i = given_args_to_add; i &lt; this-&gt;args.size(); ++i)
     c-&gt;assign(this-&gt;args[i], _b-&gt;environment.NIL);
 
-  RubyValue ret_val = process(_b-&gt;environment, r, c);
+  RubyValue ret_val = process(_b-&gt;environment, r, c, NULL);
 
   delete c;
 
   return ret_val;
 }
 
+RubyValue Block::call(linked_ptr&lt;Binding&gt; &amp;_b, const std::vector&lt;RubyValue&gt; &amp;_args, Block &amp;_block)
+{
+  std::istringstream iss(this-&gt;code);
+  Reader r = Reader(iss);
+
+  Context *c = new Context(_b-&gt;environment, _b-&gt;context);
+
+  unsigned int given_args_to_add = std::min(this-&gt;args.size(), _args.size());
+  for (unsigned int i = 0; i &lt; given_args_to_add; ++i)
+    c-&gt;assign(this-&gt;args[i], _args[i]);
+  
+  for (unsigned int i = given_args_to_add; i &lt; this-&gt;args.size(); ++i)
+    c-&gt;assign(this-&gt;args[i], _b-&gt;environment.NIL);
+
+  RubyValue ret_val = process(_b-&gt;environment, r, c, &amp;_block);
+
+  delete c;
+  return ret_val;
+}
+</diff>
      <filename>vm/block.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ int main(int argc, char **argv)
   Reader r(std::cin);
   Context *c = new Context(e, RubyValue::from_object(e.main));
 
-  process(e, r, c);
+  process(e, r, c, NULL);
 
   return 0;
 }</diff>
      <filename>vm/main.cxx</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 #include &quot;rnumeric.h&quot;
 #include &quot;rmethod.h&quot;
 
-RubyValue process(RubyEnvironment &amp;e, Reader &amp;r, Context *context)
+RubyValue process(RubyEnvironment &amp;e, Reader &amp;r, Context *context, Block *yield_block)
 {
   Stack s;
   RubyValue last_value = e.NIL;
@@ -100,10 +100,18 @@ RubyValue process(RubyEnvironment &amp;e, Reader &amp;r, Context *context)
       }
 
       case I_YIELD: {
-	std::cerr &lt;&lt; &quot;YIELD&quot; &lt;&lt; std::endl;
+	if (!yield_block) {
+	  std::cerr &lt;&lt; &quot;I_YIELD: LocalJumpError: no block given&quot; &lt;&lt; std::endl;	// XXX LocalJumpError
+	  throw;
+	}
 
 	uint32 arg_count = r.read_uint32();
-	std::cerr &lt;&lt; arg_count &lt;&lt; &quot; arg(s)&quot; &lt;&lt; std::endl;
+
+	std::vector&lt;RubyValue&gt; arguments;
+	while (arg_count--)
+	  arguments.push_back(s.pop_value(context));
+
+	last_value = yield_block-&gt;call(context-&gt;binding, arguments);
 
 	break;
       }</diff>
      <filename>vm/process.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,6 @@
 #include &quot;reader.h&quot;
 #include &quot;context.h&quot;
 
-RubyValue process(RubyEnvironment &amp;, Reader &amp;, Context *);
+RubyValue process(RubyEnvironment &amp;, Reader &amp;, Context *, Block *);
 
 #endif</diff>
      <filename>vm/process.h</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ void RubyNumericEI::init(RubyEnvironment &amp;_e)
 {
   // TODO: the whole Numeric, Fixnum, Bignum, etc. class hierarchy.
   RubyClass *rb_cFixnum = RubyClass::create_class(_e, &quot;Fixnum&quot;);
-  // TODO: undefine Fixnum's `new'?
+  // TODO: undefine Fixnum's `new'? or just redefine Numeric#new to throw a method not found error?
   rb_cFixnum-&gt;add_method(&quot;+&quot;, RubyMethod::Create(fixnum_add, 1));
   rb_cFixnum-&gt;add_method(&quot;*&quot;, RubyMethod::Create(fixnum_multiply, 1));
 </diff>
      <filename>vm/rnumeric.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1044fbfddd6e3b67075a4e996bfc0ba7a6e7b505</id>
    </parent>
  </parents>
  <author>
    <name>Arlen Cuss</name>
    <email>celtic@sairyx.org</email>
  </author>
  <url>http://github.com/celtic/rubyex/commit/11cd81b8a67665f4ef4f799bf30a7e4d8ae9d985</url>
  <id>11cd81b8a67665f4ef4f799bf30a7e4d8ae9d985</id>
  <committed-date>2008-08-21T23:49:29-07:00</committed-date>
  <authored-date>2008-08-21T23:49:29-07:00</authored-date>
  <message>Implementing I_YIELD.</message>
  <tree>97d721d64f15c437f168f23ba850830d7bf9621b</tree>
  <committer>
    <name>Arlen Cuss</name>
    <email>celtic@sairyx.org</email>
  </committer>
</commit>
