コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpUnaryOperatorExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpUnaryOperatorExpression(ICSharpContext context, IUnaryOperatorExpression source)
            : base(context, source)
        {
            RightExpression = Create(context, (IExpression)source.RightExpression);

            Operator = context.GetFeature(source.SelectedFeature.Item) as ICSharpFunctionFeature;
            Debug.Assert(Operator != null);

            FeatureCall = new CSharpFeatureCall(context, new FeatureCall());

            IResultType     ResolvedRightResult  = RightExpression.Source.ResolvedResult.Item;
            IExpressionType PreferredRightResult = ResolvedRightResult.Preferred;

            Debug.Assert(PreferredRightResult != null);

            if (PreferredRightResult.ValueType is IClassType AsClassType)
            {
                if (AsClassType.BaseClass.ClassGuid == LanguageClasses.Number.Guid)
                {
                    IsCallingNumberFeature = true;
                }
            }

            if (IsCallingNumberFeature)
            {
                Debug.Assert(ResolvedRightResult.Count == 1);
            }

            Debug.Assert(Source.SelectedOverload.IsAssigned);
            IQueryOverload     Overload = Source.SelectedOverload.Item;
            IQueryOverloadType ResolvedAssociatedType = Overload.ResolvedAssociatedType.Item;

            SelectedOverloadType = CSharpQueryOverloadType.Create(context, ResolvedAssociatedType, Operator.Owner);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpIndexAssignmentInstruction"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="parentFeature">The parent feature.</param>
 /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
 protected CSharpIndexAssignmentInstruction(ICSharpContext context, ICSharpFeature parentFeature, IIndexAssignmentInstruction source)
     : base(context, parentFeature, source)
 {
     Destination      = CSharpQualifiedName.Create(context, (IQualifiedName)source.Destination, parentFeature, null, false);
     FeatureCall      = new CSharpFeatureCall(context, source.FeatureCall.Item);
     SourceExpression = CSharpExpression.Create(context, (IExpression)source.Source);
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpCreateInstruction"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="parentFeature">The parent feature.</param>
 /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
 protected CSharpCreateInstruction(ICSharpContext context, ICSharpFeature parentFeature, ICreateInstruction source)
     : base(context, parentFeature, source)
 {
     EntityType          = CSharpType.Create(context, source.ResolvedEntityType.Item);
     CreatedObjectName   = ((IIdentifier)source.EntityIdentifier).ValidText.Item;
     CreationRoutineName = ((IIdentifier)source.CreationRoutineIdentifier).ValidText.Item;
     FeatureCall         = new CSharpFeatureCall(context, source.FeatureCall.Item);
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpPrecursorIndexExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpPrecursorIndexExpression(ICSharpContext context, IPrecursorIndexExpression source)
            : base(context, source)
        {
            ParentFeature = context.GetFeature((ICompiledFeature)source.EmbeddingFeature) as ICSharpIndexerFeature;
            Debug.Assert(ParentFeature != null);

            FeatureCall = new CSharpFeatureCall(context, source.FeatureCall.Item);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpQueryExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpQueryExpression(ICSharpContext context, IQueryExpression source)
            : base(context, source)
        {
            FeatureCall = new CSharpFeatureCall(context, source.FeatureCall.Item);

            if (Source.ResolvedFinalFeature.IsAssigned)
            {
                ICompiledFeature ResolvedFeature = Source.ResolvedFinalFeature.Item;
                if (ResolvedFeature is IScopeAttributeFeature AsScopeAttributeFeature)
                {
                    ICSharpClass Owner = context.GetClass(source.EmbeddingClass);
                    Feature = CSharpScopeAttributeFeature.Create(context, Owner, AsScopeAttributeFeature);
                }
                else
                {
                    Feature = context.GetFeature(Source.ResolvedFinalFeature.Item);
                }
            }

            if (Source.ResolvedFinalDiscrete.IsAssigned)
            {
                DiscreteOwner = context.GetClass(Source.ResolvedFinalDiscrete.Item.EmbeddingClass);

                foreach (ICSharpDiscrete Item in DiscreteOwner.DiscreteList)
                {
                    if (Item.Source == Source.ResolvedFinalDiscrete.Item)
                    {
                        Debug.Assert(Discrete == null);
                        Discrete = Item;
                    }
                }
            }

            Debug.Assert((Feature != null && Discrete == null) || (Feature == null && Discrete != null));

            if (Source.SelectedOverloadType.IsAssigned)
            {
                Debug.Assert(Feature != null);

                SelectedOverloadType = CSharpQueryOverloadType.Create(context, Source.SelectedOverloadType.Item, Feature.Owner);
            }
            else
            {
                SelectedOverloadType = null;
            }

            Query = CSharpQualifiedName.Create(context, (IQualifiedName)Source.Query, Feature, Discrete, source.InheritBySideAttribute);
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpPrecursorExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpPrecursorExpression(ICSharpContext context, IPrecursorExpression source)
            : base(context, source)
        {
            PrecursorFeature = context.GetFeature(source.ResolvedPrecursor.Item.Feature) as ICSharpFeatureWithName;
            Debug.Assert(PrecursorFeature != null);

            ParentFeature = context.GetFeature((ICompiledFeature)source.EmbeddingFeature) as ICSharpFeatureWithName;
            Debug.Assert(ParentFeature != null);

            FeatureCall = new CSharpFeatureCall(context, source.FeatureCall.Item);

            if (Source.SelectedOverloadType.IsAssigned)
            {
                SelectedOverloadType = CSharpQueryOverloadType.Create(context, Source.SelectedOverloadType.Item, PrecursorFeature.Owner);
            }
            else
            {
                SelectedOverloadType = null;
            }
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpCommandInstruction"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="parentFeature">The parent feature.</param>
        /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
        protected CSharpCommandInstruction(ICSharpContext context, ICSharpFeature parentFeature, ICommandInstruction source)
            : base(context, parentFeature, source)
        {
            Command     = CSharpQualifiedName.Create(context, (IQualifiedName)source.Command, parentFeature, null, false);
            FeatureCall = new CSharpFeatureCall(context, source.FeatureCall.Item);

            ICompiledFeature SourceFeature = source.SelectedFeature.Item;

            if (SourceFeature is IScopeAttributeFeature AsScopeAttributeFeature)
            {
                FinalFeature = CSharpScopeAttributeFeature.Create(null, AsScopeAttributeFeature);
            }
            else
            {
                FinalFeature = context.GetFeature(SourceFeature);
            }

            ICompiledTypeWithFeature ResolvedBaseType = Source.CommandFinalType.Item.ResolvedBaseType.Item;

            FinalType = CSharpType.Create(context, ResolvedBaseType) as ICSharpTypeWithFeature;
            Debug.Assert(FinalType != null);

            IList <ICSharpClassType> ConformingClassTypeList = FinalType.ConformingClassTypeList;

            bool InheritFromDotNetEvent = false;
            bool IsNumberType           = false;

            foreach (ICSharpClassType Item in ConformingClassTypeList)
            {
                ICSharpClass CallClass = Item.Class;
                InheritFromDotNetEvent |= CallClass.InheritFromDotNetEvent;

                IsNumberType = Item.IsNumberType;
            }

            SkipLastInPath         = InheritFromDotNetEvent;
            IsCallingNumberFeature = IsNumberType;
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpThrowInstruction"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="parentFeature">The parent feature.</param>
 /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
 protected CSharpThrowInstruction(ICSharpContext context, ICSharpFeature parentFeature, IThrowInstruction source)
     : base(context, parentFeature, source)
 {
     ExceptionType = CSharpType.Create(context, source.ResolvedType.Item);
     FeatureCall   = new CSharpFeatureCall(context, source.FeatureCall.Item);
 }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpBinaryOperatorExpression"/> class.
        /// </summary>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        /// <param name="context">The creation context.</param>
        protected CSharpBinaryOperatorExpression(ICSharpContext context, IBinaryOperatorExpression source)
            : base(context, source)
        {
            LeftExpression  = Create(context, (IExpression)source.LeftExpression);
            RightExpression = Create(context, (IExpression)source.RightExpression);

            Operator = context.GetFeature(source.SelectedFeature.Item) as ICSharpFunctionFeature;
            Debug.Assert(Operator != null);

            IResultType     ResolvedLeftResult  = LeftExpression.Source.ResolvedResult.Item;
            IExpressionType PreferredLeftResult = ResolvedLeftResult.Preferred;

            Debug.Assert(PreferredLeftResult != null);

            if (PreferredLeftResult.ValueType is IClassType AsClassType)
            {
                if (AsClassType.BaseClass.ClassGuid == LanguageClasses.Number.Guid || AsClassType.BaseClass.ClassGuid == LanguageClasses.Integer.Guid)
                {
                    IsCallingNumberFeature = true;
                }
            }

            if (IsCallingNumberFeature)
            {
                IResultType ResolvedRightResult = RightExpression.Source.ResolvedResult.Item;
                Debug.Assert(ResolvedRightResult.Count == 1);
            }
            else
            {
                if (!LeftExpression.IsSingleResult)
                {
                    IResultType LeftResultType = LeftExpression.Source.ResolvedResult.Item;
                    LeftNameList        = new List <string>();
                    LeftResultNameIndex = LeftResultType.ResultNameIndex;

                    for (int i = 0; i < LeftResultType.Count; i++)
                    {
                        IExpressionType DestinationType = LeftResultType.At(i);
                        string          Text            = DestinationType.Name;
                        LeftNameList.Add(Text);
                    }
                }

                if (!RightExpression.IsSingleResult)
                {
                    IResultType RightResultType = RightExpression.Source.ResolvedResult.Item;
                    RightNameList        = new List <string>();
                    RightResultNameIndex = RightResultType.ResultNameIndex;

                    for (int i = 0; i < RightResultType.Count; i++)
                    {
                        IExpressionType DestinationType = RightResultType.At(i);
                        string          Text            = DestinationType.Name;
                        RightNameList.Add(Text);
                    }
                }
            }

            FeatureCall = new CSharpFeatureCall(context, Source.FeatureCall.Item);

            Debug.Assert(Source.SelectedOverload.IsAssigned);
            IQueryOverload     Overload = Source.SelectedOverload.Item;
            IQueryOverloadType ResolvedAssociatedType = Overload.ResolvedAssociatedType.Item;

            SelectedOverloadType = CSharpQueryOverloadType.Create(context, ResolvedAssociatedType, Operator.Owner);
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpIndexQueryExpression"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly expression from which the C# expression is created.</param>
 protected CSharpIndexQueryExpression(ICSharpContext context, IIndexQueryExpression source)
     : base(context, source)
 {
     IndexedExpression = Create(context, (IExpression)source.IndexedExpression);
     FeatureCall       = new CSharpFeatureCall(context, source.FeatureCall.Item);
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpPrecursorInstruction"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="parentFeature">The parent feature.</param>
 /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
 protected CSharpPrecursorInstruction(ICSharpContext context, ICSharpFeature parentFeature, IPrecursorInstruction source)
     : base(context, parentFeature, source)
 {
     FeatureCall = new CSharpFeatureCall(context, source.FeatureCall.Item);
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpPrecursorIndexAssignmentInstruction"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="parentFeature">The parent feature.</param>
 /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
 protected CSharpPrecursorIndexAssignmentInstruction(ICSharpContext context, ICSharpFeature parentFeature, IPrecursorIndexAssignmentInstruction source)
     : base(context, parentFeature, source)
 {
     FeatureCall      = new CSharpFeatureCall(context, source.FeatureCall.Item);
     SourceExpression = CSharpExpression.Create(context, (IExpression)source.Source);
 }