本文整理汇总了C#中System.CodeDom.CodeExpression.Take方法的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression.Take方法的具体用法?C# CodeExpression.Take怎么用?C# CodeExpression.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.CodeExpression
的用法示例。
在下文中一共展示了CodeExpression.Take方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSpecialNameCall
private void GenerateSpecialNameCall(Table table, HardwireCodeGenerationContext generator, bool isVoid, bool isCtor, bool isStatic, bool isExtension, CodeExpression[] arguments, CodeExpression paramThis, string declaringType, string specialName, CodeStatementCollection coll)
{
ReflectionSpecialName special = new ReflectionSpecialName(specialName);
CodeExpression exp = null;
CodeStatement stat = null;
switch (special.Type)
{
case ReflectionSpecialNameType.IndexGetter:
if (isStatic)
EmitInvalid(generator, coll, "Static indexers are not supported by hardwired descriptors.");
else
exp = new CodeIndexerExpression(paramThis, arguments);
break;
case ReflectionSpecialNameType.IndexSetter:
if (isStatic)
EmitInvalid(generator, coll, "Static indexers are not supported by hardwired descriptors.");
else
{
coll.Add(new CodeVariableDeclarationStatement(declaringType, "tmp", paramThis));
stat = new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression("tmp"),
arguments.Take(arguments.Length - 1).ToArray()), arguments.Last());
}
break;
case ReflectionSpecialNameType.ImplicitCast:
case ReflectionSpecialNameType.ExplicitCast:
exp = paramThis;
break;
case ReflectionSpecialNameType.OperatorTrue:
GenerateBooleanOperator(paramThis, coll, true);
break;
case ReflectionSpecialNameType.OperatorFalse:
generator.Minor("'false' operator is implemented in terms of 'true' operator.");
GenerateBooleanOperator(paramThis, coll, false);
break;
case ReflectionSpecialNameType.PropertyGetter:
exp = new CodePropertyReferenceExpression(paramThis, special.Argument);
break;
case ReflectionSpecialNameType.PropertySetter:
{
if (isStatic)
{
var memberExp = new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(declaringType), special.Argument);
coll.Add(new CodeAssignStatement(memberExp, arguments[0]));
}
else
{
coll.Add(new CodeVariableDeclarationStatement(declaringType, "tmp", paramThis));
var memberExp = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("tmp"), special.Argument);
coll.Add(new CodeAssignStatement(memberExp, arguments[0]));
}
coll.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null)));
}
break;
case ReflectionSpecialNameType.OperatorAdd:
exp = BinaryOperator(CodeBinaryOperatorType.Add, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorAnd:
exp = BinaryOperator(CodeBinaryOperatorType.BitwiseAnd, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorOr:
exp = BinaryOperator(CodeBinaryOperatorType.BitwiseOr, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorDec:
exp = generator.TargetLanguage.UnaryDecrement(arguments[0]);
if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support decrement operators.", generator.TargetLanguage.Name));
break;
case ReflectionSpecialNameType.OperatorDiv:
exp = BinaryOperator(CodeBinaryOperatorType.Divide, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorEq:
exp = BinaryOperator(CodeBinaryOperatorType.ValueEquality, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorXor:
exp = generator.TargetLanguage.BinaryXor(arguments[0], arguments[1]);
if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support XOR operators.", generator.TargetLanguage.Name));
break;
case ReflectionSpecialNameType.OperatorGt:
exp = BinaryOperator(CodeBinaryOperatorType.GreaterThan, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorGte:
exp = BinaryOperator(CodeBinaryOperatorType.GreaterThanOrEqual, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorInc:
exp = generator.TargetLanguage.UnaryIncrement(arguments[0]);
if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support increment operators.", generator.TargetLanguage.Name));
break;
case ReflectionSpecialNameType.OperatorNeq:
exp = BinaryOperator(CodeBinaryOperatorType.IdentityInequality, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorLt:
exp = BinaryOperator(CodeBinaryOperatorType.LessThan, paramThis, arguments);
break;
case ReflectionSpecialNameType.OperatorLte:
exp = BinaryOperator(CodeBinaryOperatorType.LessThanOrEqual, paramThis, arguments);
break;
//.........这里部分代码省略.........