Exemplo n.º 1
0
        private IMidMemberRef EmitMemberTermImpl(ResGlobalMemberTerm resGlobal, MidEmitEnv env)
        {
            var resDecl   = resGlobal.Decl;
            var resModule = resGlobal.Module;

            var midModule = _modules[resModule];

            var midDecl = midModule.LookupMemberDecl(resDecl);

            if (midDecl == null)
            {
                if (midModule == _module)
                {
                    midDecl = EmitMemberDecl(
                        null,
                        resDecl,
                        _module.Env);
                    _module.InsertMemberDecl(resDecl, midDecl);
                    midDecl.ForceDeep();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(midDecl.CreateRef(new MidGlobalMemberTerm(midDecl)));
        }
Exemplo n.º 2
0
        private MidMemberDecl EmitMemberDeclImpl(
            MidModuleDecl midModule,
            IResPipelineDecl resPipeline,
            MidEmitEnv outerEnv)
        {
            var midPipeline = new MidPipelineDecl(
                midModule,
                resPipeline.Name,
                this,
                outerEnv,
                resPipeline.Range);

            midPipeline.IsAbstract = (resPipeline.ConcretenessMode == ResMemberConcretenessMode.Abstract);
            midPipeline.IsPrimary  = (resPipeline.MixinMode == ResMixinMode.Primary);

            MidEmitEnv env = new MidGlobalEmitEnv(outerEnv, outerEnv.Context);

            env.Insert(
                resPipeline.ThisParameter,
                (SourceRange r) =>
                new MidLit <object>(r, null, new MidPipelineRef(midPipeline, null)));
            midPipeline.Env = env;

            midPipeline.AddBuildAction(() =>
            {
                foreach (var resFacet in resPipeline.Facets)
                {
                    var originalPipeline = (MidPipelineRef)EmitMemberTerm(
                        resFacet.OriginalPipeline.MemberTerm,
                        env);
                    var midFacet = midPipeline.AddFacet(
                        originalPipeline);

                    foreach (var resLine in resFacet.MemberLines)
                    {
                        var resDecl = resLine.EffectiveDecl;
                        var midDecl = EmitMemberDecl(midFacet, resDecl, env);
                        midPipeline.InsertMemberDecl(resDecl, midDecl);
                    }
                    midFacet.DoneBuilding();
                }
            });
            midPipeline.DoneBuilding();

            midModule.AddPipeline(midPipeline);
            midModule.InsertMemberDecl(resPipeline, midPipeline);
            return(midPipeline);
        }