Exemple #1
0
        public static TernaryOperatorExpression Create(
            AphidExpressionContext context_aphidExpressionContext,
            AphidTokenType operator_w,
            AphidExpression firstOperand_aphidExpression,
            AphidExpression secondOperand_aphidExpression1,
            AphidExpression thirdOperand_aphidExpression2,
            int value_i,
            int value_i1
            )
        {
            TernaryOperatorExpression ternaryOperatorExpression
                = new TernaryOperatorExpression(context_aphidExpressionContext, operator_w,
                                                firstOperand_aphidExpression,
                                                secondOperand_aphidExpression1, thirdOperand_aphidExpression2);

            ((AphidExpression)ternaryOperatorExpression).Index  = value_i;
            ((AphidExpression)ternaryOperatorExpression).Length = value_i1;
            return(ternaryOperatorExpression);

            // TODO: Edit factory method of TernaryOperatorExpression
            // This method should be able to configure the object in all possible ways.
            // Add as many parameters as needed,
            // and assign their values to each field by using the API.
        }
Exemple #2
0
        private AphidObject InterpretTernaryOperatorExpression(TernaryOperatorExpression expression)
        {
            switch (expression.Operator)
            {
                case AphidTokenType.ConditionalOperator:
                    return (AphidObject)InterpretExpression(
                        (bool)((AphidObject)InterpretExpression(expression.FirstOperand)).Value ?
                        expression.SecondOperand :
                        expression.ThirdOperand);

                default:
                    throw new InvalidOperationException();
            }
        }