/// <summary>
        /// Initializes a new instance of the <see cref="CSharpEffectiveBody"/> 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 CSharpEffectiveBody(ICSharpContext context, ICSharpFeature parentFeature, IEffectiveBody source)
            : base(context, parentFeature, source)
        {
            foreach (IInstruction Instruction in source.BodyInstructionList)
            {
                ICSharpInstruction NewInstruction = CSharpInstruction.Create(context, parentFeature, Instruction);
                BodyInstructionList.Add(NewInstruction);
            }

            ICSharpClass Owner = parentFeature.Owner;

            foreach (IEntityDeclaration Item in source.EntityDeclarationList)
            {
                ICSharpScopeAttributeFeature NewDeclaration = CSharpScopeAttributeFeature.Create(context, Owner, Item.ValidEntity.Item);
                EntityDeclarationList.Add(NewDeclaration);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpScope"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="parentFeature">The parent feature.</param>
        /// <param name="source">The Easly node from which the C# node is created.</param>
        protected CSharpScope(ICSharpContext context, ICSharpFeature parentFeature, IScope source)
            : base(source)
        {
            ParentFeature = parentFeature;

            foreach (IEntityDeclaration Declaration in source.EntityDeclarationList)
            {
                ICSharpScopeAttributeFeature NewDeclaration = CSharpScopeAttributeFeature.Create(context, parentFeature.Owner, Declaration.ValidEntity.Item);
                EntityDeclarationList.Add(NewDeclaration);
            }

            foreach (IInstruction Instruction in source.InstructionList)
            {
                ICSharpInstruction NewInstruction = CSharpInstruction.Create(context, parentFeature, Instruction);
                InstructionList.Add(NewInstruction);
            }
        }
        /// <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);
            }
        }