Ejemplo n.º 1
0
        /// <summary>
        /// Compares two expressions.
        /// </summary>
        /// <param name="other">The other expression.</param>
        protected bool IsExpressionEqual(ICloneOfExpression other)
        {
            Debug.Assert(other != null);

            bool Result = true;

            Result &= Source == other.Source;

            return(Result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpCloneOfExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpCloneOfExpression(ICSharpContext context, ICloneOfExpression source)
            : base(context, source)
        {
            SourceExpression = Create(context, (IExpression)source.Source);

            IResultType SourceResult = SourceExpression.Source.ResolvedResult.Item;

            Debug.Assert(SourceResult.Count > 0);

            foreach (IExpressionType ExpressionType in SourceResult)
            {
                ICompiledType ClonedType = ExpressionType.ValueType;
                ICSharpType   Type       = CSharpType.Create(context, ClonedType);
                TypeList.Add(Type);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds the matching nodes of a <see cref="ICloneOfExpression"/>.
        /// </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 expression constant upon return.</param>
        public static bool ResolveCompilerReferences(ICloneOfExpression 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;

            IExpression Source = (IExpression)node.Source;
            IResultType ResolvedSourceResult = Source.ResolvedResult.Item;

            foreach (IExpressionType Item in ResolvedSourceResult)
            {
                if (Item.ValueType is IClassType AsClassType)
                {
                    IClass BaseClass = AsClassType.BaseClass;

                    if (BaseClass.Cloneable == BaseNode.CloneableStatus.Cloneable)
                    {
                        AsClassType.MarkAsUsedInCloneOf();
                    }
                    else
                    {
                        errorList.AddError(new ErrorCloningNotAllowed(node, BaseClass.ValidClassName));
                        return(false);
                    }
                }
                else
                {
                    errorList.AddError(new ErrorClassTypeRequired(node));
                    return(false);
                }
            }

            resolvedResult = ResolvedSourceResult;
            ResultException.Propagate(Source.ResolvedException, out resolvedException);

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

            return(true);
        }
 /// <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 ICSharpCloneOfExpression Create(ICSharpContext context, ICloneOfExpression source)
 {
     return(new CSharpCloneOfExpression(context, source));
 }