Ejemplo n.º 1
0
 /// <summary>
 /// Creates a copy of the given RegExp object. All properties except <see cref="lastIndex"/>
 /// will be copied.
 /// </summary>
 /// <param name="re">The RegExp object of which to create a copy.</param>
 public ASRegExp(ASRegExp re)
 {
     m_internalRegex = re.m_internalRegex;
     m_auxFlags      = re.m_auxFlags;
     m_groupNames    = re.m_groupNames;
     m_groupCount    = re.m_groupCount;
     m_source        = re.m_source;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Used for lazily constructing a RegExp instance with constant pattern and flags
        /// strings in code generated by the ABC compiler.
        /// </summary>
        ///
        /// <param name="pattern">The regular expression pattern string.</param>
        /// <param name="flags">The flags string of the regular expression.</param>
        /// <param name="location">A reference that holds the lazily constructed object.</param>
        ///
        /// <returns>If the value at <paramref name="location"/> is not null, returns a new
        /// <see cref="ASRegExp"/> that uses the same pattern and flags as that object.
        /// Otherwise, constructs a new instance from <paramref name="pattern"/> and
        /// <paramref name="flags"/>, stores it in <paramref name="location"/> and
        /// returns it.</returns>
        public static ASRegExp lazyConstructRegExp(string pattern, string flags, ref ASRegExp location)
        {
            ASRegExp value = Volatile.Read(ref location);

            if (value == null)
            {
                value = new ASRegExp(pattern, flags);
                Volatile.Write(ref location, value);
            }
            else
            {
                value = new ASRegExp(value);
            }

            return(value);
        }