/// <summary>
        /// Finds the matching nodes of a <see cref="IManifestNumberExpression"/>.
        /// </summary>
        /// <param name="node">The agent expression to check.</param>
        /// <param name="errorList">The list of errors found.</param>
        /// <param name="resolvedResult">The expression result types upon return.</param>
        /// <param name="resolvedException">Exceptions the expression can throw upon return.</param>
        /// <param name="constantSourceList">Sources of the constant expression upon return, if any.</param>
        /// <param name="expressionConstant">The constant type upon return.</param>
        public static bool ResolveCompilerReferences(IManifestNumberExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant)
        {
            resolvedResult     = null;
            resolvedException  = null;
            constantSourceList = new SealableList <IExpression>();
            expressionConstant = NeutralLanguageConstant.NotConstant;

            IClass EmbeddingClass = node.EmbeddingClass;
            string NumberText     = node.ValidText.Item;
            ISealableDictionary <ITypeName, ICompiledType> TypeTable = EmbeddingClass.TypeTable;

            if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Number.Guid, node, out ITypeName NumberTypeName, out ICompiledType NumberType))
            {
                errorList.AddError(new ErrorNumberTypeMissing(node));
                return(false);
            }

            resolvedResult    = new ResultType(NumberTypeName, NumberType, string.Empty);
            resolvedException = new ResultException();

            FormattedNumber FormattedNumber = FormattedNumber.Parse(NumberText);

            Debug.Assert(string.IsNullOrEmpty(FormattedNumber.InvalidText));

            expressionConstant = new NumberLanguageConstant(FormattedNumber.Value);

#if COVERAGE
            Debug.Assert(!node.IsComplex);
#endif

            return(true);
        }
        /// <summary>
        /// Compares two expressions.
        /// </summary>
        /// <param name="other">The other expression.</param>
        protected bool IsExpressionEqual(IManifestNumberExpression other)
        {
            Debug.Assert(other != null);

            bool Result = true;

            Result &= ValidText.Item == other.ValidText.Item;

            return(Result);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpManifestNumberExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpManifestNumberExpression(ICSharpContext context, IManifestNumberExpression source)
            : base(context, source)
        {
            FormattedNumber FormattedNumber = FormattedNumber.Parse(Source.ValidText.Item);

            Debug.Assert(FormattedNumber.IsValid);

            NumberType = FormattedNumber.Value.IsInteger ? CSharpNumberTypes.Integer : CSharpNumberTypes.Real;

            Debug.Assert(NumberType != CSharpNumberTypes.NotApplicable && NumberType != CSharpNumberTypes.Unknown);
        }
Пример #4
0
 /// <summary>
 /// Creates a new C# expression.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly expression from which the C# expression is created.</param>
 public static ICSharpManifestNumberExpression Create(ICSharpContext context, IManifestNumberExpression source)
 {
     return(new CSharpManifestNumberExpression(context, source));
 }