本文整理汇总了C#中Context.StackItem方法的典型用法代码示例。如果您正苦于以下问题:C# Context.StackItem方法的具体用法?C# Context.StackItem怎么用?C# Context.StackItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.StackItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _intOnSetIndex
public virtual int _intOnSetIndex( Context ctx, bool isprop )
{
return OnSetIndex( ctx, ctx.StackItem( 0 ), ctx.StackItem( 1 ), isprop ) ? RC.SUCCESS : RC.ENOTFND;
}
示例2: _intOnGetIndex
public virtual int _intOnGetIndex( Context ctx, bool isprop )
{
Variable v = OnGetIndex( ctx, ctx.StackItem( 0 ), isprop );
if( v != null )
{
ctx.Push( v );
return RC.SUCCESS;
}
return RC.ENOTFND;
}
示例3: sgsSetPropertyByName
public bool sgsSetPropertyByName( Variable key, Context ctx, bool isprop, int valueOnStack )
{
SGSClassInfo cinfo = GetClassInfo();
SGSPropInfo propinfo;
if( !cinfo.props.TryGetValue( key, out propinfo ) || !propinfo.canWrite )
{
if( backingStore != null )
return backingStore.SetSubItem( key, ctx.StackItem( valueOnStack ), isprop );
return false;
}
if( propinfo.parseVarMethod == null )
throw new SGSException( RC.ENOTFND, string.Format(
"Property cannot be set - no Context.ParseVar method exists that supports this type ({0})", propinfo.propType ) );
object[] args = new object[]{ null, ctx.StackItem( valueOnStack ) };
propinfo.parseVarMethod.Invoke( ctx, args );
if( propinfo.info is FieldInfo )
(propinfo.info as FieldInfo).SetValue( this, args[0] );
else // PropertyInfo
(propinfo.info as PropertyInfo).SetValue( this, args[0], null );
return true;
}
示例4: _intOnExpr
public virtual int _intOnExpr( Context ctx, ExprOp op )
{
Variable rv = null;
switch( op )
{
case ExprOp.Add: rv = OnAdd( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Sub: rv = OnSub( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Mul: rv = OnMul( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Div: rv = OnDiv( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Mod: rv = OnMod( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Compare: rv = OnCompare( ctx.StackItem( 0 ), ctx.StackItem( 1 ) ); break;
case ExprOp.Negate: rv = OnNegate(); break;
}
if( rv != null )
{
ctx.Push( rv );
return RC.SUCCESS;
}
return RC.ENOTSUP;
}
示例5: OnCall
public override int OnCall( Context ctx )
{
NI.FuncName( ctx.ctx, name );
bool gotthis = ctx.Method();
if( !gotthis && !thisMethodInfo.IsStatic )
{
// if 'this' was not passed but the method is not static, error
ctx.Msg( MsgLevel.ERROR, "Expected 'this' for non-static method" );
return RC.EINVAL;
}
object thisvar = null;
if( gotthis )
{
parseVarParams[ 0 ] = null;
parseVarParams[ 1 ] = ctx.StackItem( 0 );
parseVarThis.Invoke( ctx, parseVarParams );
thisvar = parseVarParams[ 0 ];
}
int outArg = 0;
int inArg = gotthis ? 1 : 0;
foreach( MethodInfo pva in parseVarArgs )
{
if( pva.Name == "_ParseVar_CallingThread" )
{
callArgs[ outArg ] = ctx;
}
else
{
parseVarParams[ 0 ] = null;
parseVarParams[ 1 ] = ctx.StackItem( inArg++ );
pva.Invoke( ctx, parseVarParams );
callArgs[ outArg ] = parseVarParams[ 0 ];
}
outArg++;
}
ctx.PushObj( thisMethodInfo.Invoke( thisvar, callArgs ) );
// pooled resource cleanup
parseVarParams[0] = null;
parseVarParams[1] = null;
for( int i = 0; i < parseVarArgs.Length; ++i )
callArgs[ i ] = null;
return 1;
}