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


C# Ast.Expression类代码示例

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


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

示例1: Throw

 public static ThrowStatement Throw(SourceSpan span, Expression value)
 {
     if (value != null) {
         Contract.Requires(TypeUtils.CanAssign(typeof(Exception), value.Type));
     }
     return new ThrowStatement(span, value);
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:ThrowStatement.cs

示例2: Apply

    public static Expression Apply(Expression[] args)
    {
      if (args.Length == 0)
      {
        return null;
      }

      Expression c = Ast.ConvertHelper(args[0], typeof(Callable));
      if (args.Length > 1)
      {
        Expression arg = Ast.ConvertHelper(args[args.Length - 1], typeof(object));
        
        if (arg.IsConstant(null)) Debugger.Break();

        for (int i = args.Length - 2; i > 0; i--)
        {
          arg = MakeCons(args[i], arg);
        }
        
        return Ast.ComplexCallHelper(c, ICallable_Call, Ast.Call(ListToVector, arg));
      }
      else
      {
        return null;
      }
    }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:26,代码来源:Control.cs

示例3: Scope

        public static ScopeStatement Scope(SourceSpan span, Expression scope, Statement body) {
            Contract.RequiresNotNull(scope, "scope");
            Contract.RequiresNotNull(body, "body");
            Contract.Requires(TypeUtils.CanAssign(typeof(IAttributesCollection), scope.Type), "scope", "Scope must be IAttributesCollection");

            return new ScopeStatement(span, scope, body);
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:ScopeStatment.cs

示例4: Switch

        public static SwitchStatement Switch(SourceSpan span, SourceLocation header, Expression value, params SwitchCase[] cases)
        {
            Contract.RequiresNotNull(value, "value");
            Contract.Requires(value.Type == typeof(int), "value", "Value must be int");
            Contract.RequiresNotEmpty(cases, "cases");
            Contract.RequiresNotNullItems(cases, "cases");

            bool @default = false;
            int max = Int32.MinValue;
            int min = Int32.MaxValue;
            foreach (SwitchCase sc in cases) {
                if (sc.IsDefault) {
                    Contract.Requires(@default == false, "cases", "Only one default clause allowed");
                    @default = true;
                } else {
                    int val = sc.Value;
                    if (val > max) max = val;
                    if (val < min) min = val;
                }
            }

            Contract.Requires(UniqueCaseValues(cases, min, max), "cases", "Case values must be unique");

            return new SwitchStatement(span, header, value, CollectionUtils.ToReadOnlyCollection(cases));
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:25,代码来源:SwitchStatement.cs

示例5: Assign

 /// <summary>
 /// Performs an assignment variable = value
 /// </summary>
 public static BoundAssignment Assign(Variable variable, Expression value)
 {
     Contract.RequiresNotNull(variable, "variable");
     Contract.RequiresNotNull(value, "value");
     Contract.Requires(TypeUtils.CanAssign(variable.Type, value.Type));
     return new BoundAssignment(variable, value);
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:10,代码来源:BoundAssignment.cs

示例6: Eqv

        public static Expression Eqv(Expression[] obj)
        {
            if (obj.Length == 2)
              {
            var o1 = Unwrap(obj[0]);
            var o2 = Unwrap(obj[1]);

            Func<Type, bool> p = t => o1.Type == t || o2.Type == t;
            bool vt = !(o1.Type.IsValueType || o2.Type.IsValueType);

            if (p(typeof(SymbolId))
              || p(typeof(bool))
              || (vt && !p(typeof(object)) && !p(typeof(Fraction)) && !p(typeof(IntX)) && !p(typeof(ComplexFraction)))
              )
            {
              return Ast.Equal(obj[0], obj[1]);
            }
            else if (p(typeof(double)))
            {
              return null;
            }
            else if (o1 is ConstantExpression || o2 is ConstantExpression)
            {
              return Ast.Call(typeof(object).GetMethod("Equals", BindingFlags.Public | BindingFlags.Static), obj);
            }
              }
              return null;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:28,代码来源:Equality.cs

示例7: Negate

        public static UnaryExpression Negate(Expression expression)
        {
            Contract.RequiresNotNull(expression, "expression");
            Contract.Requires(TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsigned(expression.Type), "expression", "Expression must be signed numeric type");

            return new UnaryExpression(AstNodeType.Negate, expression, expression.Type);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:UnaryExpression.cs

示例8: NewArrayHelper

        public static NewArrayExpression NewArrayHelper(Type type, IList<Expression> initializers)
        {
            Contract.RequiresNotNullItems(initializers, "initializers");
            Contract.RequiresNotNull(type, "type");
            Contract.Requires(type.IsArray, "type", "Not an array type");

            Type element = type.GetElementType();
            Expression[] clone = null;
            for (int i = 0; i < initializers.Count; i++) {
                Expression initializer = initializers[i];
                if (!TypeUtils.CanAssign(element, initializer.Type)) {
                    if (clone == null) {
                        clone = new Expression[initializers.Count];
                        for (int j = 0; j < i; j++) {
                            clone[j] = initializers[j];
                        }
                    }
                    initializer = Ast.Convert(initializer, element);
                }
                if (clone != null) {
                    clone[i] = initializer;
                }
            }

            return NewArray(type, clone ?? initializers);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:26,代码来源:NewArrayExpression.cs

示例9: ArrayIndexAssignment

 internal ArrayIndexAssignment(Expression /*!*/ array, Expression /*!*/ index, Expression /*!*/ value)
     : base(AstNodeType.ArrayIndexAssignment) {
     _array = array;
     _index = index;
     _value = value;
     _elementType = array.Type.GetElementType();
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:ArrayIndexAssignment.cs

示例10: Not

        public static UnaryExpression Not(Expression expression)
        {
            Contract.RequiresNotNull(expression, "expression");
            Contract.Requires(TypeUtils.IsIntegerOrBool(expression.Type), "expression", "Expression type must be integer or boolean.");

            return new UnaryExpression(AstNodeType.Not, expression, expression.Type);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:UnaryExpression.cs

示例11: While

        public DoStatement While(Expression condition)
        {
            Contract.RequiresNotNull(condition, "condition");
            Contract.Requires(condition.Type == typeof(bool), "condition", "Condition must be boolean");

            return new DoStatement(_statementSpan, _doLocation, condition, _body);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:DoStatementBuilder.cs

示例12: BindToInstance

        internal override MemberTracker BindToInstance(Expression instance) {
            if (IsStatic) {
                return this;
            }

            return new BoundMemberTracker(this, instance);
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:EventTracker.cs

示例13: MethodCallExpression

 internal MethodCallExpression(MethodInfo /*!*/ method, Expression instance, ReadOnlyCollection<Expression> /*!*/ arguments, ParameterInfo[] /*!*/ parameters)
     : base(AstNodeType.Call) {
     _method = method;
     _instance = instance;
     _arguments = new List<Expression>(arguments);
     _parameterInfos = parameters;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:MethodCallExpression.cs

示例14: ConditionalExpression

 internal ConditionalExpression(Expression/*!*/ test, Expression/*!*/ ifTrue, Expression/*!*/ ifFalse, Type/*!*/ type)
     : base(AstNodeType.Conditional) {
     _test = test;
     _true = ifTrue;
     _false = ifFalse;
     _expressionType = type;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:ConditionalExpression.cs

示例15: GetParameters

 private Expression[] GetParameters(Expression[] parameters) {
     Expression[] res = new Expression[_nameIndexes.Length];
     for (int i = 0; i < _nameIndexes.Length; i++) {
         res[i] = parameters[_nameIndexes[i] + _argIndex];
     }
     return res;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:ParamsDictArgBuilder.cs


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