Beispiel #1
0
        public ResStructDeclBuilder(
            ILazyFactory lazyFactory,
            ILazy <IResMemberLineDecl> line,
            SourceRange range,
            Identifier name)
            : base(lazyFactory)
        {
            var resStructDecl = new ResStructDecl(
                line,
                range,
                name,
                NewLazy(() => _thisParameter),
                NewLazy(() => (from mngb in _memberNameGroups.Values select mngb.Value).Eager()));

            SetValue(resStructDecl);
        }
Beispiel #2
0
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef originalRef)
        {
            var firstRef  = originalRef as IResStructRef;
            var firstDecl = (IResStructDecl)firstRef.Decl;

            var result = ResStructDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstDecl.Name,
                (builder) =>
            {
                var thisStructBuilder = new ResStructBuilderRef(builder);

                var thisStruct = (IResStructRef)resContainer.CreateMemberRef(
                    range,
                    builder.Value);
                var thisParameter = new ResVarDecl(
                    range,
                    firstDecl.ThisParameter.Name,
                    thisStruct);

                builder.ThisStruct    = thisStruct;
                builder.ThisParameter = thisParameter;

                foreach (var ml in firstRef.MemberLines)
                {
                    var memberLine = ml; // Freaking C# variable capture!!!!


                    var memberNameGroupBuilder     = builder.GetMemberNameGroup(memberLine.Name);
                    var memberCategoryGroupBuilder = memberNameGroupBuilder.GetMemberCategoryGroup(memberLine.Category);

                    var newMemberLineBuilder = new ResMemberLineDeclBuilder(
                        memberCategoryGroupBuilder,
                        builder.LazyFactory,
                        memberLine.Name,
                        memberLine.OriginalLexicalID,
                        memberLine.Category);
                    memberCategoryGroupBuilder.AddLine(newMemberLineBuilder);

                    newMemberLineBuilder.AddAction(() =>
                    {
                        var memberRef = memberLine.EffectiveSpec.Bind(
                            range,
                            new ResVarRef(range, thisParameter));

                        var newMemberDecl = CreateInheritedDecl(
                            resContext,
                            thisStructBuilder,
                            newMemberLineBuilder,
                            range,
                            memberRef);
                        newMemberLineBuilder.DirectDecl = newMemberDecl;
                    });

                    builder.AddDirectMemberLine(newMemberLineBuilder);
                }
            });

            return(result);
        }