* MonoTouch/MonoPInvokeCallbackAttribute.cs: Added.
[mono.git] / mcs / class / System / System.Text.RegularExpressions / compiler.cs
index ee8b6cbc2a2deacd9e79e2c13b698a1c8a82a3e1..dab38d8c1a099c6145021ac4191f9d8b729ae526 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);
 
@@ -96,13 +97,25 @@ namespace System.Text.RegularExpressions {
                        get { return pattern[1]; }
                }
 
+               public int Gap {
+                       get { return gap; }
+                       set { gap = value; }
+               }
+
                public IDictionary Mapping {
                        get { return mapping; }
                        set { mapping = value; }
                }
 
+               public string [] NamesMapping {
+                       get { return namesMapping; }
+                       set { namesMapping = value; }
+               }
+
                private IDictionary mapping;
                private ushort[] pattern;
+               private string [] namesMapping;
+               private int gap;
        }
 
        class PatternCompiler : ICompiler {
@@ -140,6 +153,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 +174,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 +291,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 +304,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 +323,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 () {