当前位置: 首页>>代码示例>>C#>>正文


C# IProject.AddFile方法代码示例

本文整理汇总了C#中IProject.AddFile方法的典型用法代码示例。如果您正苦于以下问题:C# IProject.AddFile方法的具体用法?C# IProject.AddFile怎么用?C# IProject.AddFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProject的用法示例。


在下文中一共展示了IProject.AddFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public void Initialize(IProject project, DesignContext context)
        {
            SubprogramsDontDriveSignals sdds = new SubprogramsDontDriveSignals();
            sdds.ApplyTo(context);

            foreach (VHDLib lib in _stdLibraries)
            {
                foreach (VHDPkg pkg in lib.Packages)
                {
                    if (pkg.FileContent == null)
                        continue;
                    string fname = MakeVHDSourceFileName(pkg.Name);
                    string path = project.AddFile(fname);
                    FileStream fs = new FileStream(path, FileMode.Create);
                    fs.Write(pkg.FileContent, 0, pkg.FileContent.Length);
                    fs.Close();
                }
            }
        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:19,代码来源:VHDLGen.cs

示例2: GeneratePackage

        public void GeneratePackage(IProject project, PackageDescriptor pd)
        {
            string name = MakeIDName(pd.PackageName, pd);
            string fname = MakeVHDSourceFileName(name);
            string path = project.AddFile(fname);
            project.AddFileAttribute(fname, pd);
            if (pd.Library != null)
                project.SetFileLibrary(fname, pd.Library);
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            IndentedTextWriter tw = new IndentedTextWriter(sw, "  ");
            ClearDependencies();
            tw.WriteLine("package " + name + " is");
            tw.Indent++;
            GenerateTypeDecls(pd, tw);
            foreach (MethodDescriptor md in pd.GetActiveMethods())
            {
                GenerateMethodDecl(md, tw);
            }
            foreach (FieldDescriptor fd in pd.GetConstants())
            {
                DeclareField(fd, tw);
            }
            tw.Indent--;
            tw.WriteLine("end;");
            tw.WriteLine();
            tw.WriteLine("package body " + name + " is");
            tw.Indent++;
            foreach (MethodDescriptor md in pd.GetActiveMethods())
            {
                GenerateMethodImpl(md, tw);
                tw.WriteLine();
            }
            tw.Indent--;
            tw.WriteLine("end package body;");
            tw.Flush();

            sw = new StreamWriter(path);
            tw = new IndentedTextWriter(sw, "  ");
            CreateFileHeader(new GeneratorInfo(name), tw);
            GenerateDependencies(pd, tw);
            tw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            ms.CopyTo(sw.BaseStream);
            ms.Close();
            tw.Close();
            sw.Close();
        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:48,代码来源:VHDLGen.cs

示例3: GenerateComponent

        public void GenerateComponent(IProject project, IComponentDescriptor cd)
        {
            string name = GetComponentName(cd);
            string fname = MakeVHDSourceFileName(name);
            string path = project.AddFile(fname);
            project.AddFileAttribute(fname, cd);
            if (cd.Library != null)
                project.SetFileLibrary(fname, cd.Library);
            _sim.PushScope();
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            IndentedTextWriter tw = new IndentedTextWriter(sw, "  ");
            _curComponent = cd;
            ClearDependencies();
            DeclareEntity(cd, tw);
            tw.WriteLine();
            GenerateArchitecture(cd, tw);
            tw.Flush();
            sw = new StreamWriter(path);
            tw = new IndentedTextWriter(sw, "  ");

            CreateFileHeader(new GeneratorInfo(name), tw);
            GenerateDependencies((IPackageOrComponentDescriptor)cd, tw);
            tw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            ms.CopyTo(sw.BaseStream);
            ms.Close();
            tw.Close();
            sw.Close();
            _curComponent = null;
            _sim.PopScope();

            InstanceDescriptor icd = cd as InstanceDescriptor;
            if (icd != null)
            {
                object[] attrs = icd.Instance.GetType().GetCustomAttributes(typeof(ComponentPurpose), true);
                if (attrs.Length > 0)
                {
                    ComponentPurpose purpose = (ComponentPurpose)attrs.First();
                    project.AddFileAttribute(fname, purpose.Purpose);
                }
            }

            var gi = new VHDLGenInfo(name, "inst_" + name, "behavioral", fname);
            var d = (DescriptorBase)cd;
            d.AddAttribute(gi);
        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:47,代码来源:VHDLGen.cs

示例4: GenerateMainFile

        //      ADDED
        private void GenerateMainFile(IProject project, IComponentDescriptor cd)
        {
            string fname = MakeSysCSourceFileName("main");
            string path = project.AddFile(fname);
            StreamWriter sw = new StreamWriter(path);
            IndentedTextWriter tw = new IndentedTextWriter(sw, "  ");
            string SimTimeUnit;

            CreateFileHeader(new GeneratorInfo(fname), tw);
            GenerateDependencies(null, tw, GetComponentName(cd));

            //  Get Simulation Time
            switch (SimTime.Unit)
            {
                case ETimeUnit.fs:
                    SimTimeUnit = "SC_FS";
                    break;
                case ETimeUnit.ps:
                    SimTimeUnit = "SC_PS";
                    break;
                case ETimeUnit.ns:
                    SimTimeUnit = "SC_NS";
                    break;
                case ETimeUnit.us:
                    SimTimeUnit = "SC_US";
                    break;
                case ETimeUnit.ms:
                    SimTimeUnit = "SC_MS";
                    break;
                case ETimeUnit.sec:
                    SimTimeUnit = "SC_SEC";
                    break;
                default:
                    throw new NotImplementedException();
            }

            tw.WriteLine();
            tw.WriteLine("int sc_main(int argc, char* argv[])");
            tw.WriteLine("{");
            tw.Indent++;
            tw.WriteLine("sc_report_handler::set_actions (SC_WARNING, SC_DO_NOTHING);");
            tw.WriteLine();
            tw.WriteLine(GetComponentName(cd) + " "
                + GetComponentName(((ComponentDescriptor)cd).Instance.Representant.Descriptor)
                + "(\"" + GetComponentName(cd) + "\");");

            tw.WriteLine();
            tw.WriteLine("sc_start(" + SimTime.Value + ", " + SimTimeUnit + ");");
            tw.WriteLine();
            tw.WriteLine("return 0;");
            tw.Indent--;
            tw.WriteLine("}");

            tw.Flush();
            tw.Close();
            sw.Close();
        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:58,代码来源:SystemCGen.cs

示例5: GeneratePackage

        // TODO
        public void GeneratePackage(IProject project, PackageDescriptor pd)
        {
            string name = MakeIDName(pd.PackageName, pd);

            string fname = MakeSysCHeaderFileName(name);
            string path = project.AddFile(fname);
            project.AddFileAttribute(fname, pd);
            if (pd.Library != null)
                project.SetFileLibrary(fname, pd.Library);
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            IndentedTextWriter tw = new IndentedTextWriter(sw, "  ");

            string cfname = MakeSysCSourceFileName(name);
            string path1 = project.AddFile(cfname);
            project.AddFileAttribute(cfname, pd);
            if (pd.Library != null)
                project.SetFileLibrary(cfname, pd.Library);
            MemoryStream ms1 = new MemoryStream();
            StreamWriter sw1 = new StreamWriter(ms1);
            IndentedTextWriter tw1 = new IndentedTextWriter(sw1, "  ");

            ClearDependencies();

            //tw.Indent++;
            tw1.WriteLine("#include \"" + fname + "\"");
            tw1.WriteLine();

            GenerateTypeDecls(pd, tw);

            foreach (MethodDescriptor md in pd.GetMethods())
            {
                GenerateMethodDecl(md, tw);
                tw.WriteLine();
                GenerateMethodImpl(md, tw1);
                tw1.WriteLine();
            }

            foreach (FieldDescriptor fd in pd.GetConstants())
            {
                DeclareField(fd, tw);
            }
            tw.Indent--;
            //tw.Indent++;
            tw.WriteLine("#endif");

            tw.Flush();
            sw = new StreamWriter(path);
            tw = new IndentedTextWriter(sw, "  ");

            tw1.Flush();
            sw1 = new StreamWriter(path1);
            tw1 = new IndentedTextWriter(sw1, "  ");

            CreateFileHeader(new GeneratorInfo(fname), tw);
            CreateFileHeader(new GeneratorInfo(cfname), tw1);
            GeneratePreProcDir(pd, tw);
            GenerateDependencies(pd, tw);
            //_extraLibraries.Add(new SysCLib(fname));

            tw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            ms.CopyTo(sw.BaseStream);
            ms.Close();
            tw.Close();
            sw.Close();

            tw1.Flush();
            ms1.Seek(0, SeekOrigin.Begin);
            ms1.CopyTo(sw1.BaseStream);
            ms1.Close();
            tw1.Close();
            sw1.Close();

        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:76,代码来源:SystemCGen.cs

示例6: GenerateComponent

        //      ALTERADA
        public void GenerateComponent(IProject project, IComponentDescriptor cd)
        {
            string name = GetComponentName(cd);
            string fname = MakeSysCHeaderFileName(name);
            string path = project.AddFile(fname);
            bool IsTopComponent = (name == "top0") ? true : false;
            project.AddFileAttribute(fname, cd);
            if (cd.Library != null)
                project.SetFileLibrary(fname, cd.Library);
            _sim.PushScope();
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            IndentedTextWriter tw = new IndentedTextWriter(sw, "  ");
            _curComponent = cd;
            ClearDependencies();
            DeclareAndGenerateModule(cd, tw);

            tw.Flush();
            sw = new StreamWriter(path);
            tw = new IndentedTextWriter(sw, "  ");

            CreateFileHeader(new GeneratorInfo(fname), tw);
            GeneratePreProcDir(cd, tw);
            GenerateDependencies(cd, tw, null);
            tw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            ms.CopyTo(sw.BaseStream);
            ms.Close();
            tw.Close();
            sw.Close();
            _curComponent = null;
            _sim.PopScope();

            InstanceDescriptor icd = cd as InstanceDescriptor;
            if (icd != null)
            {
                object[] attrs = icd.Instance.GetType().GetCustomAttributes(typeof(ComponentPurpose), true);
                if (attrs.Length > 0)
                {
                    ComponentPurpose purpose = (ComponentPurpose)attrs.First();
                    project.AddFileAttribute(fname, purpose.Purpose);
                }
            }

            if (IsTopComponent)
            {
                GenerateMainFile(project, cd);
            }

        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:51,代码来源:SystemCGen.cs


注:本文中的IProject.AddFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。