• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CodeGeneration.CodeExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CodeNewArray

		public CodeNewArray (Type type, CodeExpression size)
		{
			this.elemType = type;
			this.size = size;
			if (size.GetResultType () != typeof(int))
				throw new InvalidOperationException ("Array size must be an Int32");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeNewArray.cs


示例2: CodeFieldReference

		public CodeFieldReference (CodeExpression target, FieldInfo field)
		{
			if (field.IsStatic)
				throw new InvalidOperationException ("Static member '" + field.Name + "' cannot be accessed with an instance reference.");
			this.target = target;
			this.field = field;		
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeFieldReference.cs


示例3: GetParameterTypes

		Type[] GetParameterTypes (CodeExpression[] parameters)
		{
			Type[] ts = new Type [parameters.Length];
			for (int n=0; n<ts.Length; n++)
				ts [n] = parameters[n].GetResultType ();
			return ts;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeMethodCall.cs


示例4: CodeSubstractOne

		public CodeSubstractOne (CodeExpression exp)
		{
			this.exp = exp;
			if (!exp.IsNumber) {
				decMet = exp.GetResultType ().GetMethod ("op_Decrement");
				if (decMet == null)
					throw new InvalidOperationException ("Operator '--' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeDecrement.cs


示例5: CodeArrayItem

		public CodeArrayItem (CodeExpression array, CodeExpression index)
		{
			if (array == null)
				throw new ArgumentNullException ("array");
			if (index == null)
				throw new ArgumentNullException ("index");
			this.array = array;
			this.index = index;		
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:CodeArrayItem.cs


示例6: CodeFor

		public CodeFor (CodeExpression initExp, CodeExpression conditionExp, CodeExpression nextExp)
		{
			this.initExp = initExp;	
			this.conditionExp = conditionExp;
			this.nextExp = nextExp;
			
			if (conditionExp.GetResultType () != typeof(bool))
				throw new InvalidOperationException ("Condition expression is not boolean"); 
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeFor.cs


示例7: CodeAssignment

 public CodeAssignment(CodeValueReference var, CodeExpression exp)
 {
     if (var == null)
         throw new ArgumentNullException ("var");
     if (exp == null)
         throw new ArgumentNullException ("exp");
     this.exp = exp;
     this.var = var;
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:9,代码来源:CodeAssignment.cs


示例8: CodeWhen

		public CodeWhen (CodeExpression condition, CodeExpression trueResult, CodeExpression falseResult)
		{
			this.condition = condition;
			if (condition.GetResultType () != typeof(bool))
				throw new InvalidOperationException ("Condition expression is not boolean");
			if (trueResult.GetResultType() != falseResult.GetResultType())
				throw new InvalidOperationException ("The types of the true and false expressions must be the same");
			trueBlock = trueResult;
			falseBlock = falseResult;
		}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CodeWhen.cs


示例9: CodeMethodCall

		public CodeMethodCall (CodeExpression target, string name, params CodeExpression[] parameters)
		{
			this.target = target;
			this.parameters = parameters;
			Type[] types = GetParameterTypes (parameters);
			method = target.GetResultType().GetMethod (name, types);
			if (method == null) {
				throw new InvalidOperationException ("Method " + GetSignature(target.GetResultType(), name, parameters) + " not found");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CodeMethodCall.cs


示例10: CodeAnd

		public CodeAnd (CodeExpression exp1, CodeExpression exp2)
		{
			this.exp1 = exp1;
			this.exp2 = exp2;
			
 			if (exp1.GetResultType () != typeof(bool) || exp1.GetResultType () != typeof(bool)) {
				if (t1 != t2)
					throw new InvalidOperationException ("Can't compare values of different primitive types");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CodeAnd.cs


示例11: GenerateMethodCall

		public static void GenerateMethodCall (ILGenerator gen, CodeExpression target, MethodBase method, params CodeExpression[] parameters)
		{
			Type[] ptypes = Type.EmptyTypes;
			// It could raise an error since GetParameters() on MethodBuilder is not supported.
			if (parameters.Length > 0) {
				ParameterInfo[] pars = method.GetParameters ();
				ptypes = new Type[pars.Length];
				for (int n=0; n<ptypes.Length; n++) ptypes[n] = pars[n].ParameterType;
			}
			GenerateMethodCall (gen, target, method, ptypes, parameters);
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:CodeGenerationHelper.cs


示例12: CodeForeach

		public CodeForeach (CodeExpression array, Type itemType)
		{
			this.array = array;
			this.itemType = itemType;
			
			Type t = array.GetResultType ();
			if (!t.IsArray && t.GetMethod ("GetEnumerator", Type.EmptyTypes) == null)
				throw new InvalidOperationException ("foreach statement cannot operate on variables of type `" + t + "' because that class does not provide a GetEnumerator method or it is inaccessible");
			
			itemDec = new CodeVariableDeclaration (itemType, "item");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:CodeForeach.cs


示例13: CodeAdd

		public CodeAdd (CodeExpression exp1, CodeExpression exp2)
		{
			this.symbol = "+";
			this.exp1 = exp1;
			this.exp2 = exp2;
			
			t1 = exp1.GetResultType ();
			t2 = exp2.GetResultType ();
			
			if ((!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) && (t1 != typeof(string) || t2 != typeof(string))) {
				throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CodeArithmeticOperation.cs


示例14: CodeBinaryOperation

        public CodeBinaryOperation(CodeExpression exp1, CodeExpression exp2, string symbol)
        {
            this.symbol = symbol;
            this.exp1 = exp1;
            this.exp2 = exp2;

            t1 = exp1.GetResultType ();
            t2 = exp2.GetResultType ();

            if (!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) {
                throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
            }
        }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:13,代码来源:CodeBinaryOperation.cs


示例15: CodeNotEquals

		public CodeNotEquals (CodeExpression exp1, CodeExpression exp2)
		{
			this.exp1 = exp1;
			this.exp2 = exp2;
			
			t1 = exp1.GetResultType ();
			t2 = exp2.GetResultType ();
			
			if (t1.IsValueType && t2.IsValueType) {
				if (t1 != t2)
					throw new InvalidOperationException ("Can't compare values of different primitive types");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CodeNotEquals.cs


示例16: GenerateSet

		public override void GenerateSet (ILGenerator gen, CodeExpression value)
		{
			if (field.IsStatic) {
				value.Generate (gen);
				CodeGenerationHelper.GenerateSafeConversion (gen, field.FieldType, value.GetResultType ());
				gen.Emit (OpCodes.Stsfld, field);
			}
			else {
				target.Generate (gen);
				value.Generate (gen);
				CodeGenerationHelper.GenerateSafeConversion (gen, field.FieldType, value.GetResultType ());
				gen.Emit (OpCodes.Stfld, field);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:CodeFieldReference.cs


示例17: GenerateSet

 public override void GenerateSet(ILGenerator gen, CodeExpression value)
 {
     if (type.IsByRef) {
         gen.Emit (OpCodes.Ldarg, argNum);
         value.Generate (gen);
         CodeGenerationHelper.GenerateSafeConversion (gen, type.GetElementType (), value.GetResultType ());
         CodeGenerationHelper.SaveToPtr (gen, type.GetElementType ());
     }
     else {
         value.Generate (gen);
         CodeGenerationHelper.GenerateSafeConversion (gen, type, value.GetResultType ());
         gen.Emit (OpCodes.Starg, argNum);
     }
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:14,代码来源:CodeArgumentReference.cs


示例18: NewArray

		public static CodeExpression NewArray (Type type, CodeExpression size)
		{
			return new CodeNewArray (type, size);
		}
开发者ID:nickchal,项目名称:pash,代码行数:4,代码来源:Exp.cs


示例19: CodeIs

 public CodeIs(Type type, CodeExpression exp)
 {
     this.type = type;
     this.exp = exp;
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:5,代码来源:CodeIs.cs


示例20: GenerateSet

		public override void GenerateSet (ILGenerator gen, CodeExpression value)
		{
			exp.GenerateSet (gen, value);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:CodeIncrement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeGeneration.CodeWriter类代码示例发布时间:2022-05-26
下一篇:
C# PE.Section类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap