當前位置: 首頁>>代碼示例>>C#>>正文


C# UniLua.ExpDesc類代碼示例

本文整理匯總了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 );
		}
開發者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


注:本文中的UniLua.ExpDesc類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。