Esempio n. 1
0
 System.Linq.Expressions.BinaryExpression analyzeOrElseExpression(BinaryExpression node, Expression rvalue)
 {
     return Expression.OrElse(RuntimeHelpers.EnsureBoolResult(Analyze(_analysisContext, node.LeftValue)), RuntimeHelpers.EnsureBoolResult(rvalue));
 }
Esempio n. 2
0
        Expression analyzeMemberGetOperation(BinaryExpression node)
        {
            Expression lvalue = Analyze(_analysisContext, node.LeftValue);
            switch (node.RightValue.NodeKind)
            {
                case AstNodeKind.IdentifierExpression:
                    string propName = ((IdentifierExpressionNode)node.RightValue).Identifier.Text;
                    return _analysisContext.PropertyOrFieldGet(propName, lvalue);
                case AstNodeKind.FunctionCallExpression:
                    FunctionCallExpressionNodeBase funcCallExpr = (FunctionCallExpressionNodeBase)node.RightValue;
                    List<Expression> args = funcCallExpr.Arguments.Select(arg => Analyze(_analysisContext, arg)).ToList();

                    args.Insert(0, lvalue);
                    return Expression.Dynamic(
                        _analysisContext.LanguageContext.CreateCallBinder(funcCallExpr.Identifier.Text, false, new CallInfo(args.Count)), typeof(object), args);
                default:
                    throw new InternalException("NodeKind " + node.RightValue.NodeKind + " not allowed here (DCL thinks)");
            }
        }
Esempio n. 3
0
 DynamicExpression analyzeBinaryExpression(BinaryExpression node, ExpressionType expType, Expression rvalue)
 {
     return Expression.Dynamic(_analysisContext.LanguageContext.CreateBinaryOperationBinder(expType), typeof(object), Analyze(_analysisContext, node.LeftValue), rvalue);
 }
Esempio n. 4
0
 Expression analyzeIndexExpression(BinaryExpression node)
 {
     ArgumentList argList = (ArgumentList)node.RightValue;
     List<Expression> args = argList.Arguments.Select(arg => Analyze(_analysisContext, arg)).ToList();
     args.Insert(0, Analyze(_analysisContext, node.LeftValue));
     return Expression.Dynamic(_analysisContext.LanguageContext.CreateGetIndexBinder(new CallInfo(args.Count)), typeof(object), args);
 }
Esempio n. 5
0
        Expression analyzeAssignmentExpression(BinaryExpression node, Expression rvalue)
        {
            if (node.LeftValue.NodeKind == AstNodeKind.BinaryExpression)
            {
                BinaryExpression leftBinary = (BinaryExpression)node.LeftValue;
                switch (leftBinary.Operator.Operation)
                {
                    case OperationKind.MemberSet:
                        IdentifierExpressionNode memberExpressionNodeBase = leftBinary.RightValue as IdentifierExpressionNode;
                        if (memberExpressionNodeBase == null)
                        {
                            _analysisContext.ErrorCollector.InvalidLValueForAssignment(leftBinary.Location);
                            return Expression.Empty();

                        }
                        return _analysisContext.PropertyOrFieldSet(memberExpressionNodeBase.Identifier.Text, Analyze(_analysisContext, leftBinary.LeftValue), rvalue);
                    case OperationKind.Index:
                        ArgumentList argList = (ArgumentList)leftBinary.RightValue;
                        List<Expression> args = argList.Arguments.Select(arg => Analyze(_analysisContext, arg)).ToList();
                        args.Insert(0, Analyze(_analysisContext, leftBinary.LeftValue));
                        args.Add(rvalue);
                        return Expression.Dynamic(_analysisContext.LanguageContext.CreateSetIndexBinder(new CallInfo(args.Count)), typeof(object), args);
                }
                _analysisContext.ErrorCollector.InvalidLValueForAssignment(leftBinary.Location);
                return Expression.Empty();
            }

            if (node.LeftValue.NodeKind == AstNodeKind.IdentifierExpression)
            {
                return this.Analyze((IdentifierExpressionNode)node.LeftValue, rvalue);
            }

            throw new UnhandledCaseException();
        }