📄 queryimpl.cs
字号:
namespace Perst.Impl
{
using System;
#if USE_GENERICS
using System.Collections.Generic;
#endif
using System.Collections;
using System.Reflection;
using Perst.Impl;
#if USE_GENERICS
class FilterIterator
{
#else
class FilterIterator : IEnumerable, IEnumerator
{
internal IEnumerator enumerator;
#endif
internal QueryImpl query;
internal object currObj;
internal Node condition;
internal int[] indexVar;
internal long[] intAggragateFuncValue;
internal double[] realAggragateFuncValue;
internal object[] containsArray;
internal object containsElem;
internal const int maxIndexVars = 32;
#if USE_GENERICS
}
class FilterIterator<T> : FilterIterator, IEnumerable<T>, IEnumerator<T>, IEnumerable, IEnumerator
{
internal IEnumerator<T> enumerator;
public void Dispose()
{
enumerator.Dispose();
}
void IEnumerator.Reset()
{
throw new InvalidOperationException("Reset not supported");
}
#endif
public bool MoveNext()
{
while (enumerator.MoveNext())
{
currObj = enumerator.Current;
try
{
if (condition.evaluateBool(this))
{
return true;
}
}
catch (JSQLRuntimeException x)
{
query.ReportRuntimeError(x);
}
currObj = null;
}
return false;
}
#if USE_GENERICS
IEnumerator IEnumerable.GetEnumerator()
{
return this;
}
public IEnumerator<T> GetEnumerator()
{
return this;
}
object IEnumerator.Current
{
get
{
return getCurrent();
}
}
public T Current
{
get
{
return (T)getCurrent();
}
}
private object getCurrent()
{
if (currObj == null)
{
throw new InvalidOperationException();
}
return (T)currObj;
}
#else
public IEnumerator GetEnumerator()
{
return this;
}
public object Current
{
get
{
if (currObj == null)
{
throw new InvalidOperationException();
}
return currObj;
}
}
#endif
#if !USE_GENERICS
public void Reset()
{
enumerator.Reset();
currObj = null;
}
#endif
#if USE_GENERICS
internal FilterIterator(QueryImpl<T> query, IEnumerable<T> enumeration, Node condition)
#else
internal FilterIterator(QueryImpl query, IEnumerable enumeration, Node condition)
#endif
{
this.query = query;
this.enumerator = enumeration.GetEnumerator();
this.condition = condition;
indexVar = new int[maxIndexVars];
}
}
internal enum NodeType
{
tpBool,
tpInt,
tpReal,
tpFreeVar,
tpList,
tpObj,
tpStr,
tpArrayBool,
tpArrayChar,
tpArrayInt1,
tpArrayInt2,
tpArrayInt4,
tpArrayInt8,
tpArrayUInt1,
tpArrayUInt2,
tpArrayUInt4,
tpArrayUInt8,
tpArrayReal4,
tpArrayReal8,
tpArrayStr,
tpArrayObj,
tpCollection,
tpUnknown,
tpAny
};
internal enum NodeTag
{
opNop,
opIntAdd,
opIntSub,
opIntMul,
opIntDiv,
opIntAnd,
opIntOr,
opIntNeg,
opIntNot,
opIntAbs,
opIntPow,
opIntEq,
opIntNe,
opIntGt,
opIntGe,
opIntLt,
opIntLe,
opIntBetween,
opRealEq,
opRealNe,
opRealGt,
opRealGe,
opRealLt,
opRealLe,
opRealBetween,
opStrEq,
opStrNe,
opStrGt,
opStrGe,
opStrLt,
opStrLe,
opStrBetween,
opStrLike,
opStrLikeEsc,
opBoolEq,
opBoolNe,
opObjEq,
opObjNe,
opRealAdd,
opRealSub,
opRealMul,
opRealDiv,
opRealNeg,
opRealAbs,
opRealPow,
opIntToReal,
opRealToInt,
opIntToStr,
opRealToStr,
opIsNull,
opStrGetAt,
opGetAtBool,
opGetAtChar,
opGetAtInt1,
opGetAtInt2,
opGetAtInt4,
opGetAtInt8,
opGetAtUInt1,
opGetAtUInt2,
opGetAtUInt4,
opGetAtUInt8,
opGetAtReal4,
opGetAtReal8,
opGetAtStr,
opGetAtObj,
opLength,
opExists,
opIndexVar,
opFalse,
opTrue,
opNull,
opCurrent,
opIntConst,
opRealConst,
opStrConst,
opInvoke,
opScanArrayBool,
opScanArrayChar,
opScanArrayInt1,
opScanArrayInt2,
opScanArrayInt4,
opScanArrayInt8,
opScanArrayUInt1,
opScanArrayUInt2,
opScanArrayUInt4,
opScanArrayUInt8,
opScanArrayReal4,
opScanArrayReal8,
opScanArrayStr,
opScanArrayObj,
opInString,
opRealSin,
opRealCos,
opRealTan,
opRealAsin,
opRealAcos,
opRealAtan,
opRealSqrt,
opRealExp,
opRealLog,
opRealCeil,
opRealFloor,
opBoolAnd,
opBoolOr,
opBoolNot,
opStrLower,
opStrUpper,
opStrConcat,
opStrLength,
opLoad,
opLoadAny,
opInvokeAny,
opContains,
opElement,
opAvg,
opCount,
opMax,
opMin,
opSum,
opParameter,
opAnyAdd,
opAnySub,
opAnyMul,
opAnyDiv,
opAnyAnd,
opAnyOr,
opAnyNeg,
opAnyNot,
opAnyAbs,
opAnyPow,
opAnyEq,
opAnyNe,
opAnyGt,
opAnyGe,
opAnyLt,
opAnyLe,
opAnyBetween,
opAnyLength,
opInAny,
opAnyToStr,
opConvertAny,
opResolve,
opScanCollection
};
internal enum Token
{
tknNone,
tknIdent,
tknLpar,
tknRpar,
tknLbr,
tknRbr,
tknDot,
tknComma,
tknPower,
tknIconst,
tknSconst,
tknFconst,
tknAdd,
tknSub,
tknMul,
tknDiv,
tknAnd,
tknOr,
tknNot,
tknNull,
tknNeg,
tknEq,
tknNe,
tknGt,
tknGe,
tknLt,
tknLe,
tknBetween,
tknEscape,
tknExists,
tknLike,
tknIn,
tknLength,
tknLower,
tknUpper,
tknAbs,
tknIs,
tknInteger,
tknReal,
tknString,
tknFirst,
tknLast,
tknCurrent,
tknCol,
tknTrue,
tknFalse,
tknWhere,
tknOrder,
tknAsc,
tknDesc,
tknEof,
tknSin,
tknCos,
tknTan,
tknAsin,
tknAcos,
tknAtan,
tknSqrt,
tknLog,
tknExp,
tknCeil,
tknFloor,
tknBy,
tknHaving,
tknGroup,
tknAvg,
tknCount,
tknMax,
tknMin,
tknSum,
tknWith,
tknParam,
tknContains
};
class Node
{
virtual internal string FieldName
{
get
{
return null;
}
}
virtual internal Type Type
{
get
{
return null;
}
}
internal NodeType type;
internal NodeTag tag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -