Exemplo n.º 1
0
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef originalRef)
        {
            var firstRef  = (ResAttributeRef)originalRef;
            var firstDecl = firstRef.Decl;

            var result = ResAttributeDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstDecl.Name,
                (builder) =>
            {
                builder.Flags    = firstDecl.Flags;
                builder.Type     = firstRef.Type;
                builder.LazyInit =
                    builder.LazyFactory.New(() => firstRef.Init);
            });

            return(result);
        }
Exemplo n.º 2
0
        // ResMemberDecl

        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef memberRef)
        {
            var firstRef  = (ResMethodRef)memberRef;
            var firstDecl = firstRef.Decl;

            var result = ResMethodDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstDecl.Name,
                (builder) =>
            {
                // \todo: More substitution needed?
                // \todo: Add back in inheritance-related validation checks?

                /*
                 * if (firstRef.Body == null
                 *  && memberRefs.OfType<IResMethodRef>().Any((mr) => (mr.Body != null)))
                 * {
                 *  throw new NotImplementedException();
                 * }
                 */

                var subst     = new Substitution();
                var newParams = new List <ResVarDecl>();
                foreach (var oldParam in firstRef.Parameters)
                {
                    var newParam = new ResVarDecl(
                        range,
                        oldParam.Name,
                        oldParam.Type,
                        oldParam.Decl.Flags);
                    subst.Insert(oldParam.Decl, newParam);
                    newParams.Add(newParam);
                }

                builder.Parameters = newParams;
                builder.ResultType = firstRef.ResultType;
                builder.LazyBody   = resContext.LazyFactory.New(() =>
                                                                firstRef.Body == null ? null : firstRef.Body.Substitute(subst));
            });

            return(result);
        }
Exemplo n.º 3
0
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef memberRef)
        {
            var first  = (IResElementRef)memberRef;
            var result = new ResElementDecl(
                resLine,
                range,
                first.Decl.Name);

            return(result);
        }
Exemplo n.º 4
0
        /*
         *
         * TIM: the following stuff isn't accessible through IResMemberDecl, so why does it exist?
         *
         * public ResLexicalID OriginalLexicalID { get { return Line.OriginalLexicalID; } }
         * public ResLexicalID InstanceLexicalID { get { return _instanceLexicalID; } }
         * That includes the following, too:
         */

        public static IResMemberDecl CreateInheritedDecl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef memberRef)
        {
            var originalDecl = memberRef.Decl as ResMemberDecl;

            if (originalDecl == null)
            {
                throw new Exception("Unexpected class of member decl");
            }

            return(originalDecl.CreateInheritedDeclImpl(
                       resContext,
                       resContainer,
                       resLine,
                       range,
                       memberRef));
        }
Exemplo n.º 5
0
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef memberRef)
        {
            var firstRef  = (ResFieldRef)memberRef;
            var firstDecl = firstRef.Decl;

            var result = ResFieldDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstDecl.Name,
                (builder) =>
            {
                builder.Type = firstRef.Type;
                builder.Init = firstRef.Init;
            });

            return(result);
        }
Exemplo n.º 6
0
 public abstract IResMemberDecl CreateInheritedDeclImpl(
     ResolveContext resContext,
     IResContainerBuilderRef resContainer,
     ILazy <IResMemberLineDecl> resLine,
     SourceRange range,
     IResMemberRef memberRef);
Exemplo n.º 7
0
        // ResMemberDecl
        public override IResMemberDecl CreateInheritedDeclImpl(
            ResolveContext resContext,
            IResContainerBuilderRef resContainer,
            ILazy <IResMemberLineDecl> resLine,
            SourceRange range,
            IResMemberRef memberRef)
        {
            var firstRef = (IResGenericRef)memberRef;

            var result = ResGenericDecl.Build(
                resContext.LazyFactory,
                resLine,
                range,
                firstRef.Decl.Name,
                (builder) =>
            {
                var newParameters = new List <IResGenericParamDecl>();
                var subst         = new Substitution();
                foreach (var p in firstRef.Parameters)
                {
                    if (p is IResTypeParamRef)
                    {
                        var oldParameter = (IResTypeParamRef)p;
                        var newParameter = new ResTypeParamDecl(
                            oldParameter.Decl.Range,
                            oldParameter.Name,
                            oldParameter.Kind);
                        newParameters.Add(newParameter);
                        subst.Insert(oldParameter.Decl, (r) => new ResTypeVarRef(r, newParameter));
                    }
                    else if (p is IResVarSpec)
                    {
                        var oldParameter = (IResVarSpec)p;
                        var newParameter = new ResVarDecl(
                            oldParameter.Decl.Range,
                            oldParameter.Name,
                            resContext.LazyFactory.New(() => oldParameter.Type.Substitute(subst)),
                            oldParameter.Decl.Flags);
                        newParameters.Add(newParameter);
                        subst.Insert(oldParameter.Decl, (r) => new ResVarRef(r, newParameter));
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                builder.Parameters = newParameters;

                var args = (from p in newParameters
                            select p.MakeGenericArg()).ToArray();

                var innerRef = firstRef.App(range, args);


                /*
                 * var innerCategoryGroup = new ResMemberCategoryGroup(
                 *  result,
                 *  new ResMemberNameGroup(result, result.Name),
                 *  new ResMethodCategory());
                 * var innerLine = new ResMemberDeclLine(
                 *  innerCategoryGroup,
                 *  new ResLexicalID());
                 */

                var thisGenericBuilderRef = new ResGenericBuilderRef(
                    range,
                    builder,
                    resContainer);

                var innerDecl = CreateInheritedDecl(
                    resContext,
                    thisGenericBuilderRef,
                    resLine,
                    range,
                    innerRef);

                builder.InnerDecl = innerDecl;
            });

            return(result);
        }
Exemplo n.º 8
0
        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);
        }