Index: src/org/jruby/parser/Parser.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/parser/Parser.java,v
retrieving revision 1.11.2.3
diff -u -r1.11.2.3 Parser.java
--- src/org/jruby/parser/Parser.java	14 Feb 2006 17:44:18 -0000	1.11.2.3
+++ src/org/jruby/parser/Parser.java	3 Mar 2006 18:28:57 -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.21.2.3
diff -u -r1.21.2.3 ParserSupport.java
--- src/org/jruby/parser/ParserSupport.java	14 Feb 2006 17:44:18 -0000	1.21.2.3
+++ src/org/jruby/parser/ParserSupport.java	3 Mar 2006 18:28:59 -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.3.2.3
diff -u -r1.3.2.3 RubyParserConfiguration.java
--- src/org/jruby/parser/RubyParserConfiguration.java	14 Feb 2006 17:44:18 -0000	1.3.2.3
+++ src/org/jruby/parser/RubyParserConfiguration.java	3 Mar 2006 18:28:59 -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.44.2.13
diff -u -r1.44.2.13 ThreadContext.java
--- src/org/jruby/runtime/ThreadContext.java	3 Mar 2006 18:09:39 -0000	1.44.2.13
+++ src/org/jruby/runtime/ThreadContext.java	3 Mar 2006 18:29:00 -0000
@@ -211,6 +211,10 @@
     public Iter getCurrentIter() {
         return (Iter) iterStack.peek();
     }
+    
+    public UnsynchronizedStack getIterStack() {
+        return iterStack;
+    }
 
     public Scope getCurrentScope() {
         return getCurrentFrame().getScope();
