本文整理汇总了C#中System.Thread.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.GetTable方法的具体用法?C# Thread.GetTable怎么用?C# Thread.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Thread
的用法示例。
在下文中一共展示了Thread.GetTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SGsub
private static int SGsub( Thread l )
{
var str = (LString)l[1];
var pat = (LString)l[2];
var subst = l[3];
var subTy = subst.ValueType;
switch( subTy )
{
case LValueType.Number:
l.ConvertToString( ref subst );
break;
case LValueType.String:
case LValueType.Function:
case LValueType.Table:
break;
default:
throw new ArgumentException( "string/function/table expected" );
}
var max = l.StackTop >= 4 ? (int)l[4] : int.MaxValue;
MatchState ms;
InitMatchState( out ms, l );
ms.Str = str.InternalData;
ms.StrInit = LString.BufferDataOffset;
ms.Pat = pat.InternalData;
int patInit = LString.BufferDataOffset;
bool anchor = patInit < ms.Pat.Length && ms.Pat[patInit] == (byte)'^';
if( anchor )
patInit++;
var strBuilder = l.GetStrBuilder( str.Length * 2 );
int sPos = LString.BufferDataOffset;
int n = 0;
while( n < max )
{
ms.Level = 0;
Debug.Assert( ms.MatchDepth == MaxCCalls );
var e = SMatch( ref ms, sPos, patInit );
if( e != -1 )
{
n++;
Value substVal;
switch( subTy )
{
case LValueType.Function:
{
l.Push( subst );
var nCap = PushCaptures( ref ms, sPos, e, false );
l.Call( nCap, 1 );
substVal = l.PopValue();
}
break;
case LValueType.Table:
PushCapture( ref ms, 0, sPos, e );
substVal = l.GetTable( (Table)subst, l.PopValue() );
break;
case LValueType.Number:
//it's already been made a string
substVal = subst;
break;
case LValueType.String:
//need to handle escape sequences
{
var sb = (byte[])subst.RefVal;
for( int i = LString.BufferDataOffset; i < sb.Length; i++ )
{
var ch = sb[i];
if( ch != (byte)'%' )
{
strBuilder.Append( ch );
continue;
}
if( ++i == sb.Length )
throw new ArgumentException( "Invalid use of % in replacement string" );
ch = sb[i];
if( ch == (byte)'%' )
{
strBuilder.Append( ch );
//.........这里部分代码省略.........