Esempio n. 1
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);
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes the feature overloads and bodies.
        /// </summary>
        /// <param name="context">The initialization context.</param>
        public override void InitOverloadsAndBodies(ICSharpContext context)
        {
            Type = CSharpType.Create(context, Source.ResolvedEffectiveType.Item);

            if (Source.DefaultValue.IsAssigned)
            {
                DefaultValue = CSharpExpression.Create(context, Source.DefaultValue.Item);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the feature overloads and bodies.
        /// </summary>
        /// <param name="context">The initialization context.</param>
        public override void InitOverloadsAndBodies(ICSharpContext context)
        {
            Type = CSharpType.Create(context, Source.ResolvedEntityType.Item);

            foreach (IAssertion Assertion in Source.EnsureList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Assertion);
                EnsureList.Add(NewAssertion);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpAttachment"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="parentInstruction">The parent instruction.</param>
        /// <param name="source">The Easly node from which the C# node is created.</param>
        protected CSharpAttachment(ICSharpContext context, ICSharpAttachmentInstruction parentInstruction, IAttachment source)
            : base(source)
        {
            ParentInstruction = parentInstruction;

            foreach (IScopeAttributeFeature Entity in source.ResolvedLocalEntitiesList)
            {
                ICSharpType NewType = CSharpType.Create(context, Entity.ResolvedEffectiveType.Item);
                AttachTypeList.Add(NewType);
            }

            Instructions = CSharpScope.Create(context, parentInstruction.ParentFeature, (IScope)source.Instructions);
        }
        /// <summary>
        /// Initializes the feature overloads and bodies.
        /// </summary>
        /// <param name="context">The initialization context.</param>
        public override void InitOverloadsAndBodies(ICSharpContext context)
        {
            EntityType = CSharpType.Create(context, Source.ResolvedEntityType.Item);

            if (Source.GetterBody.IsAssigned)
            {
                GetterBody = CSharpBody.Create(context, this, (ICompiledBody)Source.GetterBody.Item);
            }

            if (Source.SetterBody.IsAssigned)
            {
                SetterBody = CSharpBody.Create(context, this, (ICompiledBody)Source.SetterBody.Item);
            }
        }
        /// <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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes the feature overloads and bodies.
        /// </summary>
        /// <param name="context">The initialization context.</param>
        public override void InitOverloadsAndBodies(ICSharpContext context)
        {
            EntityType = CSharpType.Create(context, Source.ResolvedEntityType.Item);

            foreach (IParameter Parameter in Source.ParameterTable)
            {
                ICSharpParameter NewParameter = CSharpParameter.Create(context, Parameter, Owner);
                IndexParameterList.Add(NewParameter);
            }

            if (Source.GetterBody.IsAssigned)
            {
                GetterBody = CSharpBody.Create(context, this, (ICompiledBody)Source.GetterBody.Item);
            }

            if (Source.SetterBody.IsAssigned)
            {
                SetterBody = CSharpBody.Create(context, this, (ICompiledBody)Source.SetterBody.Item);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpAgentExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpAgentExpression(ICSharpContext context, IAgentExpression source)
            : base(context, source)
        {
            string DelegatedName = ((IIdentifier)Source.Delegated).ValidText.Item;

            if (source.BaseType.IsAssigned)
            {
                IObjectType   SourceBaseType   = (IObjectType)source.BaseType.Item;
                ICompiledType ResolvedBaseType = SourceBaseType.ResolvedType.Item;
                BaseType = CSharpType.Create(context, ResolvedBaseType) as ICSharpTypeWithFeature;
                Debug.Assert(BaseType != null);

                EffectiveBaseType = BaseType;

                foreach (ICSharpClassType ClassType in BaseType.ConformingClassTypeList)
                {
                    foreach (KeyValuePair <IFeatureName, IFeatureInstance> Entry in ClassType.Source.FeatureTable)
                    {
                        if (Entry.Key.Name == DelegatedName)
                        {
                            Debug.Assert(Delegated == null);

                            ICompiledFeature Feature = Entry.Value.Feature;
                            Delegated = context.GetFeature(Feature) as ICSharpFeatureWithName;

                            if (ResolvedBaseType is IFormalGenericType)
                            {
                                EffectiveBaseType = ClassType;
                            }
                        }
                    }
                }
            }
            else
            {
                Delegated = context.GetFeature(source.ResolvedFeature.Item) as ICSharpFeatureWithName;
            }

            Debug.Assert(Delegated != null);
        }
        /// <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;
        }
 /// <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);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpTypedef"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly node from which the C# node is created.</param>
 /// <param name="embeddingClass">The class where the C# node is created.</param>
 protected CSharpTypedef(ICSharpContext context, ITypedef source, ICSharpClass embeddingClass)
     : base(source)
 {
     Name = ((IName)source.EntityName).ValidText.Item;
     Type = CSharpType.Create(context, source.ResolvedDefinedType.Item);
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSharpConstraint"/> class.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly node from which the C# node is created.</param>
 protected CSharpConstraint(ICSharpContext context, IConstraint source)
     : base(source)
 {
     Type           = CSharpType.Create(context, source.ResolvedConformingType.Item);
     TypeWithRename = CSharpType.Create(context, source.ResolvedTypeWithRename.Item);
 }
 /// <summary>
 /// Initializes the feature overloads and bodies.
 /// </summary>
 /// <param name="context">The initialization context.</param>
 public override void InitOverloadsAndBodies(ICSharpContext context)
 {
     Type = CSharpType.Create(context, Source.ResolvedEntityType.Item);
     ConstantExpression = CSharpExpression.Create(context, (IExpression)Source.ConstantValue);
 }