Inheritance: MidContainerDecl
Exemple #1
0
 public void ApplyToModule(MidModuleDecl module)
 {
     foreach (var p in module.Pipelines)
     {
         ApplyToPipeline(p);
     }
 }
Exemple #2
0
 public void SimplifyModule(MidModuleDecl module)
 {
     foreach (var p in module.Pipelines)
     {
         SimplifyPipeline(p);
     }
 }
Exemple #3
0
 public static void UnmarkOutputs(MidModuleDecl module)
 {
     foreach (var p in module.Pipelines)
     {
         UnmarkOutputs(p);
     }
 }
Exemple #4
0
        public MidModuleDecl EmitModule(
            IResModuleDecl resModule)
        {
            var env       = new MidGlobalEmitEnv(null, this);
            var midModule = new MidModuleDecl(null, this, env);

            _module             = midModule;
            _modules[resModule] = midModule;
            foreach (var decl in resModule.Decls)
            {
                EmitMemberDecl(midModule, decl, env);
            }
            _module.DoneBuilding();
            _module.ForceDeep();

            _lazy.Force();

            var midSimplifyContext = new Mid.MidSimplifyContext(_exps);

            midSimplifyContext.SimplifyModule(midModule);

            MidMarkOutputs.MarkOutputs(midModule);

            var midScalarizeOutputs = new Mid.MidScalarizeOutputs(_identifiers, _exps);

            midScalarizeOutputs.ApplyToModule(midModule);

            // Do cleanup tasks
            (new MidCleanup(_exps)).ApplyToModule(midModule);
            MidMarkOutputs.UnmarkOutputs(midModule);
            MidMarkOutputs.MarkOutputs(midModule);

            return(midModule);
        }
Exemple #5
0
        public static void Dump(
            this MidModuleDecl module,
            System.IO.TextWriter writer)
        {
            var span = new Span();

            module.Dump(span);
            span.Dump(writer);
        }
        public void ApplyToModule(MidModuleDecl module)
        {
            // Collect information on output attributes
            foreach (var p in module.Pipelines)
                foreach (var e in p.Elements)
                    foreach (var a in e.Attributes.ToArray()) // Copy to avoid concurrent mutation
                        Collect(p, e, a);

            // Replace uses of these attributes
            (new MidTransform( (e) => _replacePass.PreTransform((dynamic) e))).ApplyToModule(module);
        }
Exemple #7
0
        public static void Dump(
            this MidModuleDecl module,
            Span span)
        {
            span.WriteLine("module {");
            var inner = span.IndentSpan();

            foreach (var p in module.Pipelines)
            {
                p.Dump(inner);
            }
            span.WriteLine("}");
        }
Exemple #8
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);
        }
Exemple #9
0
        public void ApplyToModule(MidModuleDecl module)
        {
            // Collect information on output attributes
            foreach (var p in module.Pipelines)
            {
                foreach (var e in p.Elements)
                {
                    foreach (var a in e.Attributes.ToArray()) // Copy to avoid concurrent mutation
                    {
                        Collect(p, e, a);
                    }
                }
            }

            // Replace uses of these attributes
            (new MidTransform((e) => _replacePass.PreTransform((dynamic)e))).ApplyToModule(module);
        }
        public void ApplyToModule( MidModuleDecl module )
        {
            /*
            var transform = new MidTransform(
                null, // no pre-transform
                ( e ) => SimplifyExpImpl( (dynamic) e, env ) );

            transform.ApplyToModule( module

            return transform.Transform( exp );

            tranform

            */

            foreach( var p in module.Pipelines )
                ApplyToPipeline( p );
        }
Exemple #11
0
        public void ApplyToModule(MidModuleDecl module)
        {
            /*
             * var transform = new MidTransform(
             *  null, // no pre-transform
             *  ( e ) => SimplifyExpImpl( (dynamic) e, env ) );
             *
             * transform.ApplyToModule( module
             *
             * return transform.Transform( exp );
             *
             *
             * tranform
             *
             */

            foreach (var p in module.Pipelines)
            {
                ApplyToPipeline(p);
            }
        }
 public void SimplifyModule(MidModuleDecl module)
 {
     foreach (var p in module.Pipelines)
         SimplifyPipeline(p);
 }
 public void ApplyToModule(MidModuleDecl module)
 {
     foreach (var p in module.Pipelines)
         ApplyToPipeline(p);
 }
 public static void UnmarkOutputs( MidModuleDecl module )
 {
     foreach( var p in module.Pipelines )
         UnmarkOutputs( p );
 }