2007-10-22 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System / System.Text.RegularExpressions / compiler.cs
index a5443ff69f84c73aed2ccd663d0072875ddfdede..9173edcd5a42c04f3be4fc77e1da1894f927154e 100644 (file)
@@ -48,6 +48,7 @@ namespace System.Text.RegularExpressions {
 
                void EmitCharacter (char c, bool negate, bool ignore, bool reverse);
                void EmitCategory (Category cat, bool negate, bool reverse);
+               void EmitNotCategory (Category cat, bool negate, bool reverse);
                void EmitRange (char lo, char hi, bool negate, bool ignore, bool reverse);
                void EmitSet (char lo, BitArray set, bool negate, bool ignore, bool reverse);
 
@@ -93,7 +94,7 @@ namespace System.Text.RegularExpressions {
                }
 
                public int GroupCount {
-                       get { return pattern[0]; }
+                       get { return pattern[1]; }
                }
 
                public IDictionary Mapping {
@@ -140,6 +141,13 @@ namespace System.Text.RegularExpressions {
                        Emit (OpCode.True);
                }
 
+               void EmitCount (int count)
+               {
+                       uint ucount = (uint) count;
+                       Emit ((ushort) (ucount & 0xFFFF)); // lo 16bits
+                       Emit ((ushort) (ucount >> 16));    // hi
+               }
+
                public void EmitCharacter (char c, bool negate, bool ignore, bool reverse) {
                        Emit (OpCode.Character, MakeFlags (negate, ignore, reverse, false));
 
@@ -154,6 +162,11 @@ namespace System.Text.RegularExpressions {
                        Emit ((ushort)cat);
                }
 
+               public void EmitNotCategory (Category cat, bool negate, bool reverse) {
+                       Emit (OpCode.NotCategory, MakeFlags (negate, false, reverse, false));
+                       Emit ((ushort)cat);
+               }
+
                public void EmitRange (char lo, char hi, bool negate, bool ignore, bool reverse) {
                        Emit (OpCode.Range, MakeFlags (negate, ignore, reverse, false));
                        Emit ((ushort)lo);
@@ -266,8 +279,8 @@ namespace System.Text.RegularExpressions {
                        BeginLink (until);
                        Emit (OpCode.Repeat, MakeFlags (false, false, false, lazy));
                        EmitLink (until);
-                       Emit ((ushort)min);
-                       Emit ((ushort)max);
+                       EmitCount (min);
+                       EmitCount (max);
                }
 
                public void EmitUntil (LinkRef repeat) {
@@ -279,8 +292,8 @@ namespace System.Text.RegularExpressions {
                        BeginLink (tail);
                        Emit (OpCode.FastRepeat, MakeFlags (false, false, false, lazy));
                        EmitLink (tail);
-                       Emit ((ushort)min);
-                       Emit ((ushort)max);
+                       EmitCount (min);
+                       EmitCount (max);
                }
 
                public void EmitIn (LinkRef tail) {
@@ -298,9 +311,9 @@ namespace System.Text.RegularExpressions {
 
                public void EmitInfo (int count, int min, int max) {
                        Emit (OpCode.Info);
-                       Emit ((ushort)count);
-                       Emit ((ushort)min);
-                       Emit ((ushort)max);
+                       EmitCount (count);
+                       EmitCount (min);
+                       EmitCount (max);
                }
 
                public LinkRef NewLink () {