コード例 #1
0
ファイル: ResConceptClassDecl.cs プロジェクト: kzyg/spark
        public ResConceptClassDeclBuilder(
            ILazyFactory lazyFactory,
            ILazy <IResMemberLineDecl> line,
            SourceRange range,
            Identifier name)
            : base(lazyFactory)
        {
            var resConceptClassDecl = new ResConceptClassDecl(
                line,
                range,
                name,
                NewLazy(() => _thisParameter),
                NewLazy(() => (from mngb in _memberNameGroups.Values select mngb.Value).Eager()));

            SetValue(resConceptClassDecl);
        }
コード例 #2
0
ファイル: ResConceptClassDecl.cs プロジェクト: kzyg/spark
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef originalRef)
        {
            var firstRef  = originalRef as IResConceptClassRef;
            var firstDecl = (IResConceptClassDecl)firstRef.Decl;

            var result = ResConceptClassDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstDecl.Name,
                (builder) =>
            {
                var thisConceptClassBuilder = new ResConceptClassBuilderRef(
                    range,
                    builder);

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

                builder.ThisConceptClass = thisConceptClass;
                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,
                            thisConceptClassBuilder,
                            newMemberLineBuilder,
                            range,
                            memberRef);
                        newMemberLineBuilder.DirectDecl = newMemberDecl;
                    });

                    builder.AddDirectMemberLine(newMemberLineBuilder);
                }
            });

            return(result);
        }