本文整理汇总了C#中UniLua.ExpDesc类的典型用法代码示例。如果您正苦于以下问题:C# ExpDesc类的具体用法?C# ExpDesc怎么用?C# ExpDesc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpDesc类属于UniLua命名空间,在下文中一共展示了ExpDesc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exp2Val
public static void Exp2Val( FuncState fs, ExpDesc e )
{
if( HasJumps(e) )
Exp2AnyReg( fs, e );
else
DischargeVars( fs, e );
}
示例2: Discharge2Reg
private static void Discharge2Reg( FuncState fs, ExpDesc e, int reg )
{
DischargeVars( fs, e );
switch( e.Kind )
{
case ExpKind.VNIL: {
CodeNil( fs, reg, 1 );
break;
}
case ExpKind.VFALSE:
case ExpKind.VTRUE: {
CodeABC( fs, OpCode.OP_LOADBOOL, reg,
(e.Kind == ExpKind.VTRUE ? 1 : 0), 0 );
break;
}
case ExpKind.VK: {
CodeK( fs, reg, e.Info );
break;
}
case ExpKind.VKNUM: {
CodeK( fs, reg, NumberK( fs, e.NumberValue ) );
break;
}
case ExpKind.VRELOCABLE: {
InstructionPtr pi = fs.GetCode(e);
pi.Value = pi.Value.SETARG_A(reg);
break;
}
case ExpKind.VNONRELOC: {
if( reg != e.Info )
CodeABC( fs, OpCode.OP_MOVE, reg, e.Info, 0 );
break;
}
default: {
Utl.Assert( e.Kind == ExpKind.VVOID || e.Kind == ExpKind.VJMP );
return; // nothing to do...
}
}
e.Info = reg;
e.Kind = ExpKind.VNONRELOC;
}
示例3: Exp2Reg
private static void Exp2Reg( FuncState fs, ExpDesc e, int reg )
{
Discharge2Reg( fs, e, reg );
if( e.Kind == ExpKind.VJMP )
{
e.ExitTrue = Concat( fs, e.ExitTrue, e.Info );
}
if( HasJumps(e) )
{
int p_f = NO_JUMP;
int p_t = NO_JUMP;
if( NeedValue( fs, e.ExitTrue ) || NeedValue( fs, e.ExitFalse ) )
{
int fj = (e.Kind == ExpKind.VJMP) ? NO_JUMP : Jump( fs );
p_f = CodeLabel( fs, reg, 0, 1 );
p_t = CodeLabel( fs, reg, 1, 0 );
PatchToHere( fs, fj );
}
// position after whole expression
int final = GetLabel( fs );
PatchListAux( fs, e.ExitFalse, final, reg, p_f );
PatchListAux( fs, e.ExitTrue, final, reg, p_t );
}
e.ExitFalse = NO_JUMP;
e.ExitTrue = NO_JUMP;
e.Info = reg;
e.Kind = ExpKind.VNONRELOC;
}
示例4: Infix
public static void Infix( FuncState fs, BinOpr op, ExpDesc e )
{
// Debug.Log(">> INFIX op:" + op);
switch( op )
{
case BinOpr.AND: {
GoIfTrue( fs, e );
} break;
case BinOpr.OR: {
GoIfFalse( fs, e );
} break;
case BinOpr.CONCAT: {
Exp2NextReg( fs, e ); // operand must be on the `stack'
} break;
case BinOpr.ADD:
case BinOpr.SUB:
case BinOpr.MUL:
case BinOpr.DIV:
case BinOpr.MOD:
case BinOpr.POW: {
if( !IsNumeral(e) )
Exp2RK( fs, e );
} break;
default: {
Exp2RK( fs, e );
} break;
}
}
示例5: Indexed
public static void Indexed( FuncState fs, ExpDesc t, ExpDesc k )
{
t.Ind.T = t.Info;
t.Ind.Idx = Exp2RK( fs, k );
t.Ind.Vt = (t.Kind == ExpKind.VUPVAL) ? ExpKind.VUPVAL
: ExpKind.VLOCAL; // FIXME
t.Kind = ExpKind.VINDEXED;
}
示例6: GoIfFalse
public static void GoIfFalse( FuncState fs, ExpDesc e )
{
// Debug.Log("GoIfFalse k:" + e.Kind );
int pc; // pc of last jump
DischargeVars( fs, e );
switch( e.Kind )
{
case ExpKind.VJMP:
pc = e.Info;
break;
case ExpKind.VNIL:
case ExpKind.VFALSE:
pc = NO_JUMP;
break;
default:
pc = JumpOnCond( fs, e, true );
break;
}
// insert last jump in `t' list
e.ExitTrue = Concat( fs, e.ExitTrue, pc );
PatchToHere( fs, e.ExitFalse );
e.ExitFalse = NO_JUMP;
}
示例7: CodeComp
private static void CodeComp( FuncState fs, OpCode op, int cond,
ExpDesc e1, ExpDesc e2 )
{
int o1 = Exp2RK( fs, e1 );
int o2 = Exp2RK( fs, e2 );
FreeExp( fs, e2 );
FreeExp( fs, e1 );
// exchange args to replace by `<' or `<='
if( cond == 0 && op != OpCode.OP_EQ ) {
int temp;
temp = o1; o1 = o2; o2 = temp; // o1 <==> o2
cond = 1;
}
e1.Info = CondJump( fs, op, cond, o1, o2 );
e1.Kind = ExpKind.VJMP;
}
示例8: SetMultiRet
public static void SetMultiRet( FuncState fs, ExpDesc e )
{
SetReturns( fs, e, LuaDef.LUA_MULTRET );
}
示例9: SetOneRet
public static void SetOneRet( FuncState fs, ExpDesc e )
{
// expression is an open function call?
if( e.Kind == ExpKind.VCALL )
{
e.Kind = ExpKind.VNONRELOC;
e.Info = ( fs.GetCode( e ) ).Value.GETARG_A();
}
else if( e.Kind == ExpKind.VVARARG )
{
var pi = fs.GetCode( e );
pi.Value = pi.Value.SETARG_B( 2 );
e.Kind = ExpKind.VRELOCABLE; // can relocate its simple result
}
}
示例10: DischargeVars
public static void DischargeVars( FuncState fs, ExpDesc e )
{
switch( e.Kind )
{
case ExpKind.VLOCAL:
e.Kind = ExpKind.VNONRELOC;
break;
case ExpKind.VUPVAL:
e.Info = CodeABC( fs, OpCode.OP_GETUPVAL, 0, e.Info, 0 );
e.Kind = ExpKind.VRELOCABLE;
break;
case ExpKind.VINDEXED:
OpCode op = OpCode.OP_GETTABUP;
FreeReg( fs, e.Ind.Idx );
if( e.Ind.Vt == ExpKind.VLOCAL )
{
FreeReg( fs, e.Ind.T );
op = OpCode.OP_GETTABLE;
}
e.Info = CodeABC( fs, op, 0, e.Ind.T, e.Ind.Idx );
e.Kind = ExpKind.VRELOCABLE;
break;
case ExpKind.VVARARG:
case ExpKind.VCALL:
SetOneRet( fs, e );
break;
default: break;
}
}
示例11: SetReturns
public static void SetReturns( FuncState fs, ExpDesc e, int nResults )
{
if( e.Kind == ExpKind.VCALL ) { // expression is an open function call?
var pi = fs.GetCode(e);
pi.Value = pi.Value.SETARG_C( nResults+1 );
}
else if( e.Kind == ExpKind.VVARARG ) {
var pi = fs.GetCode(e);
pi.Value = pi.Value.SETARG_B( nResults+1 ).SETARG_A( fs.FreeReg );
ReserveRegs( fs, 1 );
}
}
示例12: Exp2AnyRegUp
public static void Exp2AnyRegUp( FuncState fs, ExpDesc e )
{
if( e.Kind != ExpKind.VUPVAL || HasJumps( e ) )
{
Exp2AnyReg( fs, e );
}
}
示例13: Exp2AnyReg
public static int Exp2AnyReg( FuncState fs, ExpDesc e )
{
// Debug.Log("Exp2AnyReg k:" + e.Kind +
// " hasjump:" + HasJumps(e) +
// " info:" + e.Info +
// " nactvar:" + fs.NumActVar);
DischargeVars( fs, e );
if( e.Kind == ExpKind.VNONRELOC )
{
// exp is already in a register
if( ! HasJumps( e ) )
return e.Info;
// reg. is not a local?
if( e.Info >= fs.NumActVar )
{
Exp2Reg( fs, e, e.Info );
return e.Info;
}
}
Exp2NextReg( fs, e ); // default
return e.Info;
}
示例14: Exp2RK
public static int Exp2RK( FuncState fs, ExpDesc e )
{
Exp2Val( fs, e );
switch( e.Kind )
{
case ExpKind.VTRUE:
case ExpKind.VFALSE:
case ExpKind.VNIL: {
// constant fits in RK operand?
if( fs.Proto.K.Count <= Instruction.MAXINDEXRK )
{
e.Info = (e.Kind == ExpKind.VNIL) ? NilK(fs)
: BoolK( fs, (e.Kind == ExpKind.VTRUE ) );
e.Kind = ExpKind.VK;
return Instruction.RKASK( e.Info );
}
else break;
}
case ExpKind.VKNUM:
case ExpKind.VK:
{
if( e.Kind == ExpKind.VKNUM )
{
e.Info = NumberK( fs, e.NumberValue );
e.Kind = ExpKind.VK;
}
if( e.Info <= Instruction.MAXINDEXRK )
return Instruction.RKASK( e.Info );
else break;
}
default: break;
}
return Exp2AnyReg( fs, e );
}
示例15: JumpOnCond
private static int JumpOnCond( FuncState fs, ExpDesc e, bool cond )
{
// Debug.Log("--------------- 2 ----------JumpOnCond k:" + e.Kind );
if( e.Kind == ExpKind.VRELOCABLE )
{
Instruction ie = fs.GetCode( e ).Value;
if( ie.GET_OPCODE() == OpCode.OP_NOT )
{
fs.Pc--; // remove previous OP_NOT
return CondJump( fs, OpCode.OP_TEST, ie.GETARG_B(), 0,
(cond ? 0 : 1) );
}
// else go through
}
Discharge2AnyReg( fs, e );
FreeExp( fs, e );
return CondJump( fs, OpCode.OP_TESTSET, NO_REG, e.Info,
(cond ? 1 : 0) );
}