Index: src/org/jruby/parser/Parser.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/parser/Parser.java,v
retrieving revision 1.21
diff -u -r1.21 Parser.java
--- src/org/jruby/parser/Parser.java	14 Feb 2006 17:44:29 -0000	1.21
+++ src/org/jruby/parser/Parser.java	20 Feb 2006 15:48:49 -0000
@@ -32,6 +32,7 @@
 
 import java.io.Reader;
 import java.io.StringReader;
+import java.util.Iterator;
 import java.util.List;
 
 import org.jruby.IRuby;
@@ -39,6 +40,7 @@
 import org.jruby.ast.Node;
 import org.jruby.lexer.yacc.LexerSource;
 import org.jruby.lexer.yacc.SyntaxException;
+import org.jruby.runtime.Iter;
 import org.jruby.util.collections.SinglyLinkedList;
 
 /**
@@ -68,6 +70,14 @@
         SinglyLinkedList cref) {
         config.setLocalVariables(runtime.getCurrentContext().getCurrentScope().getLocalNames());
         
+        // search for an ITER_CUR; this lets us know we're parsing from within a block and should bring dvars along
+        for (Iterator iter = runtime.getCurrentContext().getIterStack().iterator(); iter.hasNext();) {
+            if ((Iter)iter.next() == Iter.ITER_CUR) {
+                config.setDynamicVariables(runtime.getCurrentContext().getCurrentDynamicVars().names());
+                break;
+            }
+        }
+        
         DefaultRubyParser parser = null;
         RubyParserResult result = null;
         try {
Index: src/org/jruby/parser/ParserSupport.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/parser/ParserSupport.java,v
retrieving revision 1.30
diff -u -r1.30 ParserSupport.java
--- src/org/jruby/parser/ParserSupport.java	14 Feb 2006 17:44:29 -0000	1.30
+++ src/org/jruby/parser/ParserSupport.java	20 Feb 2006 15:48:50 -0000
@@ -177,7 +177,8 @@
         	return new TrueNode(position);
         } else if (id.equals("false")) {
         	return new FalseNode(position);
-        } /*else if (id == k__FILE__) {
+        } /* TODO: add __FILE__ and __LINE__ support?
+        else if (id == k__FILE__) {
         	return NEW_STR(rb_str_new2(ruby_sourcefile));
             }
             else if (id == k__LINE__) {
@@ -586,15 +587,20 @@
     *  Description of the RubyMethod
     */
     public void initTopLocalVariables() {
-        localNamesStack.push(new LocalNamesElement());
+        LocalNamesElement localNames = new LocalNamesElement();
+        localNamesStack.push(localNames);
 
         String[] names = configuration.getLocalVariables();
         if (names != null && names.length > 0) {
-			LocalNamesElement localNames = (LocalNamesElement) localNamesStack.peek();
-            List namesList = new ArrayList(names.length);
+			List namesList = new ArrayList(names.length);
             for (int i = 0; i < names.length; i++) namesList.add(names[i]);
             localNames.setNames(namesList);
         }
+        
+        if (configuration.getDynamicVariables() != null) {
+            localNames.changeBlockLevel(1);
+            getBlockNames().push(new BlockNamesElement(configuration.getDynamicVariables()));
+        }
     }
 
     /**
Index: src/org/jruby/parser/RubyParserConfiguration.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/parser/RubyParserConfiguration.java,v
retrieving revision 1.7
diff -u -r1.7 RubyParserConfiguration.java
--- src/org/jruby/parser/RubyParserConfiguration.java	14 Feb 2006 17:44:29 -0000	1.7
+++ src/org/jruby/parser/RubyParserConfiguration.java	20 Feb 2006 15:48:50 -0000
@@ -29,9 +29,12 @@
  ***** END LICENSE BLOCK *****/
 package org.jruby.parser;
 
+import java.util.List;
+
 
 public class RubyParserConfiguration {
     private String[] localVariables;
+    private List dynamicVariables;
 
     /**
      * Gets the localVariables.
@@ -48,4 +51,12 @@
     public void setLocalVariables(String[] localVariables) {
         this.localVariables = localVariables;
     }
+
+    public List getDynamicVariables() {
+        return dynamicVariables;
+    }
+
+    public void setDynamicVariables(List dynamicVariables) {
+        this.dynamicVariables = dynamicVariables;
+    }
 }
Index: src/org/jruby/runtime/ThreadContext.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/runtime/ThreadContext.java,v
retrieving revision 1.80
diff -u -r1.80 ThreadContext.java
--- src/org/jruby/runtime/ThreadContext.java	14 Feb 2006 21:41:28 -0000	1.80
+++ src/org/jruby/runtime/ThreadContext.java	20 Feb 2006 15:48:50 -0000
@@ -211,6 +211,10 @@
     public Iter getCurrentIter() {
         return (Iter) iterStack.peek();
     }
+    
+    public UnsynchronizedStack getIterStack() {
+        return iterStack;
+    }
 
     public Scope getCurrentScope() {
         return getCurrentFrame().getScope();
Index: test.rb
===================================================================
RCS file: test.rb
diff -N test.rb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test.rb	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+def foo
+  yield
+end
+
+foo { x = "bar"; eval("puts x", binding) }
Index: test_binding_in_block.rb
===================================================================
RCS file: test_binding_in_block.rb
diff -N test_binding_in_block.rb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test_binding_in_block.rb	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,14 @@
+def goo
+  yield
+end
+
+def moo
+  y = "bar"
+  goo do
+    x = "foo"
+    eval("puts y.to_s", binding)
+    eval("puts x.to_s", binding)
+  end
+end
+
+moo
