private void CastToString(ConditionNode node, TypeNode expectedType)
 {
     if (expectedType.Type == TypeEnum.Integer)
     {
         CastFromIntegerExpression cast1 = new CastFromIntegerExpression(node.ReturnExpression, 0, 0);
         node.ReturnExpression = cast1;
     }
     else if (expectedType.Type == TypeEnum.Real)
     {
         CastFromRealExpression cast2 = new CastFromRealExpression(node.ReturnExpression, 0, 0);
         node.ReturnExpression = cast2;
     }
     else if (expectedType.Type == TypeEnum.Boolean)
     {
         CastFromBooleanExpression cast3 = new CastFromBooleanExpression(node.ReturnExpression, 0, 0);
         node.ReturnExpression = cast3;
     }
 }
        private void InsertCastNode(IExpressionNode binaryNode, int child, TypeEnum castFrom)
        {
            switch (castFrom)
            {
            case TypeEnum.Integer:
                CastFromIntegerExpression cast1 = new CastFromIntegerExpression(binaryNode.Children[child], 0, 0);
                binaryNode.Children[child] = cast1;
                break;

            case TypeEnum.Real:
                CastFromRealExpression cast2 = new CastFromRealExpression(binaryNode.Children[child], 0, 0);
                binaryNode.Children[child] = cast2;
                break;

            case TypeEnum.Boolean:
                CastFromBooleanExpression cast3 = new CastFromBooleanExpression(binaryNode.Children[child], 0, 0);
                binaryNode.Children[child] = cast3;
                break;

            default:
                throw new Exception("Invalid castFrom");
            }
        }
Ejemplo n.º 3
0
        public string CastRealToString(CastFromRealExpression node, List <Object> parameters)
        {
            double val = _interpreter.DispatchReal(node.Child, parameters);

            return(val.ToString("G", CultureInfo.InvariantCulture));
        }