Inheritance: MidContainerDecl
示例#1
0
        public MidFacetDecl AddFacet(MidPipelineRef originalPipeline)
        {
            var facet = new MidFacetDecl(
                this,
                this.EmitContext,
                this.Env,
                this,
                originalPipeline);

            _facets.Add(facet);
            return(facet);
        }
示例#2
0
        private MidMemberDecl EmitMemberDeclImpl(
            MidFacetDecl midFacet,
            IResElementDecl resElement,
            MidEmitEnv env)
        {
            var midElement = new MidElementDecl(midFacet, resElement.Name);

            midElement.DoneBuilding();

            midFacet.AddElement(midElement);

            return(midElement);
        }
 public MidFacetDecl AddFacet(MidPipelineRef originalPipeline)
 {
     var facet = new MidFacetDecl(
         this,
         this.EmitContext,
         this.Env,
         this,
         originalPipeline);
     _facets.Add(facet);
     return facet;
 }
示例#4
0
        private MidMemberDecl EmitMemberDeclImpl(
            MidFacetDecl midFacet,
            IResAttributeDecl resAttrib,
            MidEmitEnv env)
        {
            var midAttrWrap = new MidAttributeWrapperDecl(midFacet, resAttrib.Name, resAttrib.Range);

            midAttrWrap.AddBuildAction(() =>
            {
                var fqType = resAttrib.Type;
                var freq   = fqType.Freq;
                var type   = fqType.Type;

                var midElement = (MidElementDecl)midFacet.Pipeline.LookupMemberDecl(freq.MemberTerm.Decl);
                var midType    = EmitTypeExp(type, env);

                MidAttributeDecl midAttr = null;
                if (resAttrib.Init == null)
                {
                    midAttr = new MidAttributeDecl(
                        resAttrib.Name,
                        midElement,
                        midType,
                        null);
                    midElement.AddAttribute(midAttr);
                    if (resAttrib.Line.ConcretenessMode == ResMemberConcretenessMode.Abstract)
                    {
                        midAttr.IsAbstract = true;
                    }
                    else if (resAttrib.IsInput())
                    {
                        midAttr.IsInput = true;
                    }
                    else if (resAttrib.IsOptional())
                    {
                        midAttr.IsOptional = true;
                    }
                    else if (resAttrib.Line.Tags.Any((t) => t is ResBuiltinTag))
                    {
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }

                    // Eventually:
//                    else
//                        midAttr.IsInput = true;
                }
                else
                {
                    var initEnv = new MidDummyEmitEnv(env);

                    var inheritedDecls = resAttrib.Line.InheritedDecls;
                    if (inheritedDecls != null)
                    {
                        // Skip first decl if we are already using an inherited decl:
                        if (resAttrib.Line.MemberDeclMode != ResMemberDeclMode.Inherited)
                        {
                            initEnv.InheritedDecls = inheritedDecls.Cast <IResAttributeDecl>();
                        }
                        else
                        {
                            initEnv.InheritedDecls = inheritedDecls.Cast <IResAttributeDecl>().Skip(1);
                        }
                    }

                    var midExp = EmitAttrExp(midElement, midType, resAttrib.Init, initEnv);

                    if (midExp is MidAttributeRef &&
                        ((MidAttributeRef)midExp).Decl.IsOptional)
                    {
                        midAttr = ((MidAttributeRef)midExp).Decl;
                    }
                    else if (resAttrib.IsOutput())
                    {
                        midAttr = new MidAttributeDecl(
                            resAttrib.Name,
                            midElement,
                            midType,
                            midExp);
                        midElement.AddAttribute(midAttr);
                    }
                    else
                    {
                        midAttr = midElement.CacheAttr(midExp, midType);
                        midAttr.TrySetName(resAttrib.Name, resAttrib.Range);
                    }
                }
                if (resAttrib.IsOutput() && !midAttr.IsOptional)
                {
                    midAttr.IsForcedOutput = true;
                }

                midAttrWrap.Attribute = midAttr;
                midElement.AddAttributeWrapper(midAttrWrap);
            });
            midAttrWrap.DoneBuilding();

            midFacet.AddAttribute(midAttrWrap);
            return(midAttrWrap);

            /*
             *
             * var midAttrib = new MidAttributeDecl(midFacet, resAttrib.Name);
             *
             * if (resAttrib.Line.ConcretenessMode == ResMemberConcretenessMode.Abstract)
             *  midAttrib.IsAbstract = true;
             *
             * if( resAttrib.IsOutput )
             *  midAttrib.IsOutput = true;
             *
             * midAttrib.AddBuildAction(() =>
             * {
             *  var fqType = resAttrib.Type;
             *  var freq = fqType.Freq;
             *  var type = fqType.Type;
             *
             *  var midElement = (MidElementDecl)midFacet.Pipeline.LookupMemberDecl(freq.MemberTerm.Decl);
             *
             *  midAttrib.Type = EmitTypeExp(resAttrib.Type, env);
             *
             *  if (resAttrib.Init != null)
             *  {
             *      var savedElement = _currentElement;
             *      _currentElement = midElement;
             *
             *      midAttrib.Exp = EmitLocalExp(resAttrib.Init, env);
             *
             *      _currentElement = savedElement;
             *  }
             *
             *  midAttrib.Element = midElement;
             *  midElement.AddAttribute(midAttrib);
             * });
             *
             * midAttrib.DoneBuilding();
             *
             * midFacet.AddAttribute(midAttrib);
             * return midAttrib;
             * */
        }