コード例 #1
0
        public override void OnBinaryExpression(BinaryExpression node)
        {
            if (node.ContainsAnnotation("AssignsAreAttributes_visited"))
                return;
            if (node.Operator == BinaryOperatorType.Assign)
            {
                var name = node.Left.expand();
                var value = node.Right.expand();

                Element.SetAttributeValue(name,value.Replace("_QUOTED_USD_","$"));
            }
            else{
                base.OnBinaryExpression(node);
            }
            node.Annotate("AssignsAreAttributes_visited");
        }
コード例 #2
0
ファイル: ProcessMethodBodies.cs プロジェクト: stuman08/boo
        bool BindPointerArithmeticOperator(BinaryExpression node, IType left, IType right)
        {
            if (!left.IsPointer || !TypeSystemServices.IsPrimitiveNumber(right))
                return false;

            switch (node.Operator)
            {
                case BinaryOperatorType.Addition:
                case BinaryOperatorType.Subtraction:
                    if (node.ContainsAnnotation("pointerSizeNormalized"))
                        return true;

                    BindExpressionType(node, left);

                    int size = TypeSystemServices.SizeOf(left);
                    if (size == 1)
                        return true; //no need for normalization

                    //normalize RHS wrt size of pointer
                    IntegerLiteralExpression literal = node.Right as IntegerLiteralExpression;
                    Expression normalizedRhs = (null != literal)
                        ? (Expression)
                            new IntegerLiteralExpression(literal.Value * size)
                        : (Expression)
                            new BinaryExpression(BinaryOperatorType.Multiply,
                                node.Right,
                                new IntegerLiteralExpression(size));
                    node.Replace(node.Right, normalizedRhs);
                    Visit(node.Right);
                    node.Annotate("pointerSizeNormalized", size);
                    return true;
            }

            return false;
        }