internal RegexCode RegexCodeFromRegexTree(RegexTree tree)
{
int length;
RegexBoyerMoore moore;
if ((tree._capnumlist == null) || (tree._captop == tree._capnumlist.Length))
{
length = tree._captop;
this._caps = null;
}
else
{
length = tree._capnumlist.Length;
this._caps = tree._caps;
for (int i = 0; i < tree._capnumlist.Length; i++)
{
this._caps[tree._capnumlist[i]] = i;
}
}
this._counting = true;
Label_0076:
if (!this._counting)
{
this._emitted = new int[this._count];
}
RegexNode node = tree._root;
int curIndex = 0;
this.Emit(0x17, 0);
Label_00A1:
if (node._children == null)
{
this.EmitFragment(node._type, node, 0);
}
else if (curIndex < node._children.Count)
{
this.EmitFragment(node._type | 0x40, node, curIndex);
node = (RegexNode)node._children[curIndex];
this.PushInt(curIndex);
curIndex = 0;
goto Label_00A1;
}
if (!this.EmptyStack())
{
curIndex = this.PopInt();
node = node._next;
this.EmitFragment(node._type | 0x80, node, curIndex);
curIndex++;
goto Label_00A1;
}
this.PatchJump(0, this.CurPos());
this.Emit(40);
if (this._counting)
{
this._counting = false;
goto Label_0076;
}
RegexPrefix fcPrefix = RegexFCD.FirstChars(tree);
if ((fcPrefix != null) && (RegexCharClass.SetSize(fcPrefix.Prefix) > 0))
{
fcPrefix = null;
}
RegexPrefix scPrefix = null;
RegexPrefix prefix3 = RegexFCD.Prefix(tree);
bool rightToLeft = (tree._options & RegexOptions.RightToLeft) != RegexOptions.None;
CultureInfo culture = ((tree._options & RegexOptions.CultureInvariant) != RegexOptions.None) ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture;
if ((prefix3 != null) && (prefix3.Prefix.Length > 0))
{
moore = new RegexBoyerMoore(prefix3.Prefix, prefix3.CaseInsensitive, rightToLeft, culture);
}
else
{
moore = null;
}
return(new RegexCode(this._emitted, this._stringtable, this._trackcount, this._caps, length, moore, fcPrefix, scPrefix, RegexFCD.Anchors(tree), rightToLeft));
}