예제 #1
0
 public void Initialize(List <string> references)
 {
     asmNames = references;
     refs     = new List <Assembly>();
     for (int i = 0; i < references.Count; i++)
     {
         refs.Add(LoadAssembly(references[i]));
     }
     Instance = this;
 }
예제 #2
0
        /// <summary>
        /// Private helper function for all parsing.  Takes in the IronPython Parser
        /// object and a filename that's used for error reports
        /// </summary>
        /// <param name="p"></param>
        private CodeCompileUnit Parse(Parser p, string filename)
        {
            Stmt            s   = p.ParseFileInput();
            CodeCompileUnit res = new CodeCompileUnit();
            CodeNamespace   defaultNamespace = new CodeNamespace();

            //!!! enable AD usage when we're strong named.
            //AppDomainSetup ads = new AppDomainSetup();
            //ads.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //AppDomain ad = AppDomain.CreateDomain("ParserReferenceDomain",null,ads);
            try {
                RemoteReferences rc = new RemoteReferences();

                /*(RemoteReferences)ad.CreateInstanceAndUnwrap(
                 *              Assembly.GetExecutingAssembly().FullName,
                 *              "IronPython.CodeDom.RemoteReferences");*/
                rc.Initialize(references);


                CodeWalker cw = new CodeWalker(filename, rc);
                s.Walk(cw);

                CodeObject      co  = cw.LastObject;
                CodeObjectSuite cos = co as CodeObjectSuite;
                if (cos == null)
                {
                    cos = new CodeObjectSuite(new CodeObject[] { co });
                }

                // walk the top-level and see if we need to create a fake top-type
                // or if we can just stick everything directly into the namespace.
                CodeTypeDeclaration topType = null;
                for (int i = 0; i < cos.Count; i++)
                {
                    topType = CheckTopLevel(cos[i], res, defaultNamespace, topType);
                }

                // if no namespaces we're added then everything's in our default namespace.
                if (res.Namespaces.Count == 0)
                {
                    res.Namespaces.Add(defaultNamespace);
                }

                UpdateTopType(topType, defaultNamespace);
            } finally {
                //AppDomain.Unload(ad);
            }

            return(res);
        }
예제 #3
0
        /// <summary>
        /// Private helper function for all parsing.  Takes in the IronPython Parser 
        /// object and a filename that's used for error reports
        /// </summary>
        /// <param name="p"></param>
        private CodeCompileUnit Parse(Parser p, string filename)
        {
            Statement s = p.ParseFileInput();
            CodeCompileUnit res = new CodeCompileUnit();
            CodeNamespace defaultNamespace = new CodeNamespace();
            defaultNamespace.UserData["Line"] = 1;
            defaultNamespace.UserData["Column"] = 1;
            defaultNamespace.UserData["EndLine"] = 1;
            defaultNamespace.UserData["EndColumn"] = 1;

            //!!! enable AD usage when we're strong named.
            //AppDomainSetup ads = new AppDomainSetup();
            //ads.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //AppDomain ad = AppDomain.CreateDomain("ParserReferenceDomain",null,ads);
            try {
                RemoteReferences rc = new RemoteReferences();
                /*(RemoteReferences)ad.CreateInstanceAndUnwrap(
                                Assembly.GetExecutingAssembly().FullName,
                                "IronPython.CodeDom.RemoteReferences");*/
                rc.Initialize(references);

                CodeWalker cw = new CodeWalker(filename, rc);
                s.Walk(cw);

                CodeObject co = cw.LastObject;
                CodeObjectSuite cos = co as CodeObjectSuite;
                if (cos == null) cos = new CodeObjectSuite(new CodeObject[] { co });

                // walk the top-level and see if we need to create a fake top-type
                // or if we can just stick everything directly into the namespace.
                CodeTypeDeclaration topType = null;
                for (int i = 0; i < cos.Count; i++) {
                    topType = CheckTopLevel(cos[i], res, defaultNamespace, topType);
                }

                // if no namespaces we're added then everything's in our default namespace.
                if (res.Namespaces.Count == 0 || defaultNamespace.Types.Count > 0) {
                    res.Namespaces.Add(defaultNamespace);
                }

                UpdateTopType(topType, defaultNamespace);
            } finally {
                //AppDomain.Unload(ad);
            }

            return res;
        }
예제 #4
0
 /// <summary> Creates a new LocalReferences that gets it's data from a RemoteReferences </summary>
 public LocalReferences(RemoteReferences backing)
 {
     refs = backing;
 }
예제 #5
0
 /// <summary> Creates a new LocalReferences that gets it's data from a RemoteReferences </summary>
 public LocalReferences(RemoteReferences backing)
 {
     refs = backing;
 }
예제 #6
0
 public void Initialize(List<string> references)
 {
     asmNames = references;
     refs = new List<Assembly>();
     for (int i = 0; i < references.Count; i++) {
         refs.Add(LoadAssembly(references[i]));
     }
     Instance = this;
 }