/// <summary>
        /// Initializes a new instance of the <see cref="CSharpOverLoopInstruction"/> 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 CSharpOverLoopInstruction(ICSharpContext context, ICSharpFeature parentFeature, IOverLoopInstruction source)
            : base(context, parentFeature, source)
        {
            OverList         = CSharpExpression.Create(context, (IExpression)source.OverList);
            LoopInstructions = CSharpScope.Create(context, parentFeature, (IScope)source.LoopInstructions);

            foreach (IName Name in source.IndexerList)
            {
                string IndexerName = Name.ValidText.Item;
                IScopeAttributeFeature IndexerFeature = Source.InnerLoopScope[IndexerName];

                ICSharpScopeAttributeFeature NewIndexer = CSharpScopeAttributeFeature.Create(context, ParentFeature.Owner, IndexerFeature);
                IndexerList.Add(NewIndexer);
            }

            if (source.ExitEntityName.IsAssigned)
            {
                ExitEntityName = ((IIdentifier)source.ExitEntityName.Item).ValidText.Item;
            }

            foreach (IAssertion Item in Source.InvariantList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Item);
                InvariantList.Add(NewAssertion);
            }
        }
Exemplo 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.ResolvedEntityType.Item);

            foreach (IAssertion Assertion in Source.EnsureList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Assertion);
                EnsureList.Add(NewAssertion);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpBody"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="parentFeature">The parent feature.</param>
        /// <param name="source">The Easly body from which the C# body is created.</param>
        protected CSharpBody(ICSharpContext context, ICSharpFeature parentFeature, IBody source)
        {
            Debug.Assert(source != null);

            ParentFeature = parentFeature;
            Source        = source;

            foreach (IAssertion Assertion in source.RequireList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Assertion);
                RequireList.Add(NewAssertion);
            }

            foreach (IAssertion Assertion in source.EnsureList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Assertion);
                EnsureList.Add(NewAssertion);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpForLoopInstruction"/> 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 CSharpForLoopInstruction(ICSharpContext context, ICSharpFeature parentFeature, IForLoopInstruction source)
            : base(context, parentFeature, source)
        {
            foreach (IEntityDeclaration Declaration in source.EntityDeclarationList)
            {
                ICSharpScopeAttributeFeature NewDeclaration = CSharpScopeAttributeFeature.Create(context, parentFeature.Owner, Declaration.ValidEntity.Item);
                EntityDeclarationList.Add(NewDeclaration);
            }

            foreach (IInstruction Instruction in source.InitInstructionList)
            {
                ICSharpInstruction NewInstruction = Create(context, parentFeature, Instruction);
                InitInstructionList.Add(NewInstruction);
            }

            WhileCondition = CSharpExpression.Create(context, (IExpression)source.WhileCondition);

            foreach (IInstruction Instruction in source.LoopInstructionList)
            {
                ICSharpInstruction NewInstruction = Create(context, parentFeature, Instruction);
                LoopInstructionList.Add(NewInstruction);
            }

            foreach (IInstruction Instruction in source.IterationInstructionList)
            {
                ICSharpInstruction NewInstruction = Create(context, parentFeature, Instruction);
                IterationInstructionList.Add(NewInstruction);
            }

            if (source.Variant.IsAssigned)
            {
                VariantExpression = CSharpExpression.Create(context, (IExpression)source.Variant.Item);
            }

            foreach (IAssertion Item in Source.InvariantList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Item);
                InvariantList.Add(NewAssertion);
            }
        }