当前位置: 首页>>代码示例>>C#>>正文


C# UniLua.FuncState类代码示例

本文整理汇总了C#中UniLua.FuncState的典型用法代码示例。如果您正苦于以下问题:C# FuncState类的具体用法?C# FuncState怎么用?C# FuncState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FuncState类属于UniLua命名空间,在下文中一共展示了FuncState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: ReserveRegs

		public static void ReserveRegs( FuncState fs, int n )
		{
			// Debug.Log("===================================== FREEREG + " + n);
			CheckStack( fs, n );
			fs.FreeReg += n;
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:6,代码来源: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: 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

示例5: 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

示例6: NumberK

		public static int NumberK( FuncState fs, double r )
		{
			var o = new TValue();
			o.SetNValue(r);
			return AddK( fs, ref o, ref o );
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:6,代码来源:Coder.cs

示例7: NilK

		private static int NilK( FuncState fs )
		{
			// // cannot use nil as key;
			// // instead use table itself to represent nil
			// var k = fs.H;
			// var o = new LuaNil();
			// return AddK( fs, k, o );

			var o = new TValue();
			o.SetNilValue();
			return AddK( fs, ref o, ref o );
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:12,代码来源:Coder.cs

示例8: 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

示例9: Posfix

		public static void Posfix( FuncState fs, BinOpr op,
			ExpDesc e1, ExpDesc e2, int line )
		{
			// Debug.Log(">> POSFIX op:" + op);
			switch( op )
			{
				case BinOpr.AND: {
					Utl.Assert( e1.ExitTrue == NO_JUMP );
					DischargeVars( fs, e2 );
					e2.ExitFalse = Concat( fs, e2.ExitFalse, e1.ExitFalse );
					e1.CopyFrom( e2 );
					break;
				}
				case BinOpr.OR: {
					Utl.Assert( e1.ExitFalse == NO_JUMP );
					DischargeVars( fs, e2 );
					e2.ExitTrue = Concat( fs, e2.ExitTrue, e1.ExitTrue );
					e1.CopyFrom( e2 );
					break;
				}
				case BinOpr.CONCAT: {
					Exp2Val( fs, e2 );
					var pe2 = fs.GetCode( e2 );
					if( e2.Kind == ExpKind.VRELOCABLE &&
						pe2.Value.GET_OPCODE() == OpCode.OP_CONCAT )
					{
						Utl.Assert( e1.Info == pe2.Value.GETARG_B()-1 );
						FreeExp( fs, e1 );
						pe2.Value = pe2.Value.SETARG_B( e1.Info );
						e1.Kind = ExpKind.VRELOCABLE;
						e1.Info = e2.Info;
					}
					else
					{
						// operand must be on the `stack'
						Exp2NextReg( fs, e2 );
						CodeArith( fs, OpCode.OP_CONCAT, e1, e2, line );
					}
					break;
				}
				case BinOpr.ADD: {
					CodeArith( fs, OpCode.OP_ADD, e1, e2, line);
					break;
				}
				case BinOpr.SUB: {
					CodeArith( fs, OpCode.OP_SUB, e1, e2, line);
					break;
				}
				case BinOpr.MUL: {
					CodeArith( fs, OpCode.OP_MUL, e1, e2, line);
					break;
				}
				case BinOpr.DIV: {
					CodeArith( fs, OpCode.OP_DIV, e1, e2, line);
					break;
				}
				case BinOpr.MOD: {
					CodeArith( fs, OpCode.OP_MOD, e1, e2, line);
					break;
				}
				case BinOpr.POW: {
					CodeArith( fs, OpCode.OP_POW, e1, e2, line);
					break;
				}
				case BinOpr.EQ: {
					CodeComp( fs, OpCode.OP_EQ, 1, e1, e2 );
					break;
				}
				case BinOpr.LT: {
					CodeComp( fs, OpCode.OP_LT, 1, e1, e2 );
					break;
				}
				case BinOpr.LE: {
					CodeComp( fs, OpCode.OP_LE, 1, e1, e2 );
					break;
				}
				case BinOpr.NE: {
					CodeComp( fs, OpCode.OP_EQ, 0, e1, e2 );
					break;
				}
				case BinOpr.GT: {
					CodeComp( fs, OpCode.OP_LT, 0, e1, e2 );
					break;
				}
				case BinOpr.GE: {
					CodeComp( fs, OpCode.OP_LE, 0, e1, e2 );
					break;
				}
				default: Utl.Assert(false); break;
			}
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:91,代码来源:Coder.cs

示例10: 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

示例11: Prefix

		public static void Prefix( FuncState fs, UnOpr op, ExpDesc e, int line )
		{
			ExpDesc e2 = new ExpDesc();
			e2.ExitTrue = NO_JUMP;
			e2.ExitFalse = NO_JUMP;
			e2.Kind = ExpKind.VKNUM;
			e2.NumberValue = 0.0;

			switch( op )
			{
				case UnOpr.MINUS: {
					if( IsNumeral( e ) ) // minus constant?
					{
						e.NumberValue = -e.NumberValue;
					}
					else
					{
						Exp2AnyReg( fs, e );
						CodeArith( fs, OpCode.OP_UNM, e, e2, line );
					}
				} break;

				case UnOpr.NOT: {
					CodeNot( fs, e );
				} break;

				case UnOpr.LEN: {
					Exp2AnyReg( fs, e ); // cannot operate on constants
					CodeArith( fs, OpCode.OP_LEN, e, e2, line );
				} break;

				default:
					throw new Exception("[Coder]Prefix Unknown UnOpr:" + op);
			}
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:35,代码来源:Coder.cs

示例12: 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

示例13: 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

示例14: 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

示例15: Concat

		public static int Concat( FuncState fs, int l1, int l2 )
		{
			// Debug.Log("======== Concat l1:" + l1 + " l2:" + l2);
			if( l2 == NO_JUMP )
				return l1;
			else if( l1 == NO_JUMP )
				return l2;
			else
			{
				int list = l1;
				// Debug.Log("Concat list:" + list);
				int next = GetJump( fs, list );

				// find last element
				while( next != NO_JUMP )
				{
					list = next;
					// Debug.Log("Concat list:" + list);
					next = GetJump( fs, list );
				}
				FixJump( fs, list, l2 );
				return l1;
			}
		}
开发者ID:xuxiandi,项目名称:UniLua,代码行数:24,代码来源:Coder.cs


注:本文中的UniLua.FuncState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。