コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpEntityExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpEntityExpression(ICSharpContext context, IEntityExpression source)
            : base(context, source)
        {
            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)
            {
                ICSharpClass Class = context.GetClass(Source.ResolvedFinalDiscrete.Item.EmbeddingClass);

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

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

            Query = CSharpQualifiedName.Create(context, (IQualifiedName)Source.Query, Feature, Discrete, false);
        }
コード例 #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="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);
        }
コード例 #4
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;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpAssignmentInstruction"/> 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 CSharpAssignmentInstruction(ICSharpContext context, ICSharpFeature parentFeature, IAssignmentInstruction source)
            : base(context, parentFeature, source)
        {
            SourceExpression = CSharpExpression.Create(context, (IExpression)Source.Source);

            foreach (IQualifiedName Destination in source.DestinationList)
            {
                ICompiledFeature SourceFeature = source.FinalFeatureTable[Destination];

                ICSharpFeature FinalFeature;

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

                ICSharpQualifiedName NewDestination = CSharpQualifiedName.Create(context, Destination, FinalFeature, null, false);
                DestinationList.Add(NewDestination);
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpReleaseInstruction"/> 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 CSharpReleaseInstruction(ICSharpContext context, ICSharpFeature parentFeature, IReleaseInstruction source)
     : base(context, parentFeature, source)
 {
     ReleasedEntity = CSharpQualifiedName.Create(context, (IQualifiedName)source.EntityName, ParentFeature, null, false);
 }