本文整理汇总了C#中ICompiler.EmitRange方法的典型用法代码示例。如果您正苦于以下问题:C# ICompiler.EmitRange方法的具体用法?C# ICompiler.EmitRange怎么用?C# ICompiler.EmitRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICompiler
的用法示例。
在下文中一共展示了ICompiler.EmitRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
public override void Compile (ICompiler cmp, bool reverse) {
// create the meta-collection
IntervalCollection meta =
intervals.GetMetaCollection (new IntervalCollection.CostDelegate (GetIntervalCost));
// count ops
int count = meta.Count;
for (int i = 0; i < pos_cats.Length; ++ i) {
if (pos_cats[i] || neg_cats [i])
++ count;
}
if (count == 0)
return;
// emit in op for |meta| > 1
LinkRef tail = cmp.NewLink ();
if (count > 1)
cmp.EmitIn (tail);
// emit character/range/sets from meta-collection
// we emit these first so that any 'ignore' flags will be noticed by the evaluator
foreach (Interval a in meta) {
if (a.IsDiscontiguous) { // Set
BitArray bits = new BitArray (a.Size);
foreach (Interval b in intervals) {
if (a.Contains (b)) {
for (int i = b.low; i <= b.high; ++ i)
bits[i - a.low] = true;
}
}
cmp.EmitSet ((char)a.low, bits, negate, ignore, reverse);
}
else if (a.IsSingleton) // Character
cmp.EmitCharacter ((char)a.low, negate, ignore, reverse);
else // Range
cmp.EmitRange ((char)a.low, (char)a.high, negate, ignore, reverse);
}
// emit categories
for (int i = 0; i < pos_cats.Length; ++ i) {
if (pos_cats[i]) {
if (neg_cats [i])
cmp.EmitCategory (Category.AnySingleline, negate, reverse);
else
cmp.EmitCategory ((Category)i, negate, reverse);
} else if (neg_cats[i]) {
cmp.EmitNotCategory ((Category)i, negate, reverse);
}
}
// finish up
if (count > 1) {
if (negate)
cmp.EmitTrue ();
else
cmp.EmitFalse ();
cmp.ResolveLink (tail);
}
}
示例2: Compile
public override void Compile (ICompiler cmp, bool reverse) {
// create the meta-collection
IntervalCollection meta =
intervals.GetMetaCollection (new IntervalCollection.CostDelegate (GetIntervalCost));
// count ops
int count = meta.Count;
for (int i = 0; i < pos_cats.Length; ++ i) {
// use BitArray.Get instead of indexer for speedups
//if (pos_cats[i]) ++ count;
//if (neg_cats[i]) ++ count;
if (pos_cats.Get(i)) ++ count;
if (neg_cats.Get(i)) ++ count;
}
if (count == 0)
return;
// emit in op for |meta| > 1
LinkRef tail = cmp.NewLink ();
if (count > 1)
cmp.EmitIn (tail);
// emit categories
for (int i = 0; i < pos_cats.Length; ++ i) {
// use BitArray.Get instead of indexer for speedups
//if (pos_cats[i]) {
if (pos_cats.Get(i)) {
//if (neg_cats [i])
if (neg_cats.Get(i))
cmp.EmitCategory (Category.AnySingleline, negate, reverse);
else
cmp.EmitCategory ((Category)i, negate, reverse);
// } else if (neg_cats[i]) {
} else if (neg_cats.Get(i)) {
cmp.EmitCategory ((Category)i, !negate, reverse);
}
}
// emit character/range/sets from meta-collection
foreach (Interval a in meta) {
if (a.IsDiscontiguous) { // Set
BitArray bits = new BitArray (a.Size);
foreach (Interval b in intervals) {
if (a.Contains (b)) {
for (int i = b.low; i <= b.high; ++ i)
// use BitArray.Get instead of indexer for speedups : bits[i - a.low] = true;
bits.Set( i - a.low, true );
}
}
cmp.EmitSet ((char)a.low, bits, negate, ignore, reverse);
}
else if (a.IsSingleton) // Character
cmp.EmitCharacter ((char)a.low, negate, ignore, reverse);
else // Range
cmp.EmitRange ((char)a.low, (char)a.high, negate, ignore, reverse);
}
// finish up
if (count > 1) {
if (negate)
cmp.EmitTrue ();
else
cmp.EmitFalse ();
cmp.ResolveLink (tail);
}
}