Exemplo n.º 1
0
        public static IdentifierExpression GetDeclaredIdentifier(AphidExpression expression)
        {
            switch (expression.Type)
            {
            case AphidExpressionType.ForEachExpression:
                var element = expression.ToForEach().Element;

                if (element.Type == AphidExpressionType.IdentifierExpression)
                {
                    return(element.ToIdentifier());
                }

                break;

            case AphidExpressionType.BinaryOperatorExpression:
                var binOpExp = expression.ToBinaryOperator();

                if (binOpExp.Operator == AphidTokenType.AssignmentOperator &&
                    binOpExp.LeftOperand.Type == AphidExpressionType.IdentifierExpression)
                {
                    return(binOpExp.LeftOperand.ToIdentifier());
                }

                break;
            }

            return(null);
        }
Exemplo n.º 2
0
        protected override void Visit(AphidExpression expression)
        {
            switch (expression.Type)
            {
            case AphidExpressionType.ForEachExpression:
                var element = expression.ToForEach().Element;

                if (element.Type == AphidExpressionType.IdentifierExpression)
                {
                    _locals.Add(element.ToIdentifier());
                }

                break;

            case AphidExpressionType.BinaryOperatorExpression:
                var binOpExp = expression.ToBinaryOperator();

                if (binOpExp.Operator == AphidTokenType.AssignmentOperator &&
                    binOpExp.LeftOperand.Type == AphidExpressionType.IdentifierExpression)
                {
                    _locals.Add(binOpExp.LeftOperand.ToIdentifier());
                }

                break;

            case AphidExpressionType.FunctionExpression:
                IgnoreChildren();
                break;
            }
        }