本文整理汇总了C#中UniLua.ExpDesc类的典型用法代码示例。如果您正苦于以下问题:C# ExpDesc类的具体用法?C# ExpDesc怎么用?C# ExpDesc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpDesc类属于UniLua命名空间,在下文中一共展示了ExpDesc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Exp2Val
public static void Exp2Val( FuncState fs, ExpDesc e )
{
if( HasJumps(e) )
Exp2AnyReg( fs, e );
else
DischargeVars( fs, e );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:7,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:41,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:31,代码来源:Coder.cs
示例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;
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:32,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:8,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:26,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:17,代码来源:Coder.cs
示例8: SetMultiRet
public static void SetMultiRet( FuncState fs, ExpDesc e )
{
SetReturns( fs, e, LuaDef.LUA_MULTRET );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:4,代码来源:Coder.cs
示例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
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:15,代码来源:Coder.cs
示例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;
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:33,代码来源:Coder.cs
示例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 );
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:12,代码来源:Coder.cs
示例12: Exp2AnyRegUp
public static void Exp2AnyRegUp( FuncState fs, ExpDesc e )
{
if( e.Kind != ExpKind.VUPVAL || HasJumps( e ) )
{
Exp2AnyReg( fs, e );
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:7,代码来源:Coder.cs
示例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;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:23,代码来源:Coder.cs
示例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 );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:37,代码来源:Coder.cs
示例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) );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:19,代码来源:Coder.cs
示例16: StoreVar
public static void StoreVar( FuncState fs, ExpDesc v, ExpDesc e )
{
switch( v.Kind )
{
case ExpKind.VLOCAL: {
FreeExp( fs, e );
Exp2Reg( fs, e, v.Info );
break;
}
case ExpKind.VUPVAL: {
int c = Exp2AnyReg( fs, e );
// Debug.Log("SETUPVAL " + c + " " + v.Info);
CodeABC( fs, OpCode.OP_SETUPVAL, c, v.Info, 0 );
break;
}
case ExpKind.VINDEXED: {
OpCode op = (v.Ind.Vt == ExpKind.VLOCAL)
? OpCode.OP_SETTABLE
: OpCode.OP_SETTABUP;
int c = Exp2RK( fs, e );
CodeABC( fs, op, v.Ind.T, v.Ind.Idx, c );
break;
}
default:
{
throw new NotImplementedException("invalid var kind to store");
}
}
FreeExp( fs, e );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:33,代码来源:Coder.cs
示例17: GoIfTrue
public static void GoIfTrue( FuncState fs, ExpDesc e )
{
// Debug.Log("--------------- 1 ----------GoIfTrue k:" + e.Kind );
int pc; // pc of last jump
DischargeVars( fs, e );
switch( e.Kind )
{
case ExpKind.VJMP:
InvertJump( fs, e );
pc = e.Info;
break;
case ExpKind.VK:
case ExpKind.VKNUM:
case ExpKind.VTRUE:
pc = NO_JUMP;
break;
default:
pc = JumpOnCond( fs, e, false );
break;
}
// insert last jump in `f' list
e.ExitFalse = Concat( fs, e.ExitFalse, pc );
PatchToHere( fs, e.ExitTrue );
e.ExitTrue = NO_JUMP;
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:28,代码来源:Coder.cs
示例18: Self
public static void Self( FuncState fs, ExpDesc e, ExpDesc key )
{
Exp2AnyReg( fs, e );
int ereg = e.Info; // register where `e' is placed
FreeExp( fs, e );
e.Info = fs.FreeReg; // base register for op_self
e.Kind = ExpKind.VNONRELOC;
ReserveRegs( fs, 2 );
CodeABC( fs, OpCode.OP_SELF, e.Info, ereg, Coder.Exp2RK(fs, key) );
FreeExp( fs, key );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:11,代码来源:Coder.cs
示例19: CodeNot
private static void CodeNot( FuncState fs, ExpDesc e )
{
DischargeVars( fs, e );
switch( e.Kind )
{
case ExpKind.VNIL:
case ExpKind.VFALSE:
e.Kind = ExpKind.VTRUE;
break;
case ExpKind.VK:
case ExpKind.VKNUM:
case ExpKind.VTRUE:
e.Kind = ExpKind.VFALSE;
break;
case ExpKind.VJMP:
InvertJump( fs, e );
break;
case ExpKind.VRELOCABLE:
case ExpKind.VNONRELOC:
Discharge2AnyReg( fs, e );
FreeExp( fs, e );
e.Info = CodeABC( fs, OpCode.OP_NOT, 0, e.Info, 0 );
e.Kind = ExpKind.VRELOCABLE;
break;
default:
throw new Exception("CodeNot unknown e.Kind:" + e.Kind);
}
// interchange true and false lists
{ int temp = e.ExitFalse; e.ExitFalse = e.ExitTrue; e.ExitTrue = temp; }
RemoveValues( fs, e.ExitFalse );
RemoveValues( fs, e.ExitTrue );
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:38,代码来源:Coder.cs
示例20: FreeExp
private static void FreeExp( FuncState fs, ExpDesc e )
{
// Debug.Log("--------------- 3 ----------FreeExp k:" + e.Kind );
if( e.Kind == ExpKind.VNONRELOC )
{
FreeReg( fs, e.Info );
}
}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:8,代码来源:Coder.cs
注:本文中的UniLua.ExpDesc类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论