Пример #1
0
        private bool TryImportExternal(string baseName, string name, out Inferred inferred)
        {
            string path = Path.GetDirectoryName(baseName);
            string file = Path.Combine(path, name + ".py");

            Module module;

            if (!modules.TryGetValue(file, out module))
            {
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(file);
                }
                catch
                {
                    inferred = null;
                    return(false);
                }

                using (sr)
                {
                    string text = sr.ReadToEnd();
                    module = AnalyzeModule(new QuietCompilerSink(), file, text);
                }
            }

            inferred = new InferredModule(module.ModuleScope);
            return(true);
        }
Пример #2
0
        internal bool TryImport(string baseName, string name, out Inferred inferred)
        {
            if (TryImportExternal(baseName, name, out inferred))
            {
                return(true);
            }

            ReflectedModule reflectedScope;

            if (global.TryGetNamespace(name, out reflectedScope))
            {
                inferred = reflectedScope;
                return(true);
            }

            ReflectedType reflectedType;

            if (global.TryGetBuiltin(name, out reflectedType))
            {
                inferred = reflectedType;
                return(true);
            }

            inferred = null;
            return(false);
        }
 public InferredInstance(Inferred type)
 {
     if (null == type)
     {
         throw new ArgumentNullException("type");
     }
     Debug.Assert(!type.IsInstance);
     this.type = type;
 }
Пример #4
0
        public override IList <Inferred> Resolve(Engine engine, Scope scope)
        {
            Inferred         import   = engine.Import(name.Names[0]);
            IList <Inferred> previous = null;

            if (import != null)
            {
                previous = Engine.MakeList(import);

                for (int i = 1; i < name.Names.Count; i++)
                {
                    IList <Inferred> next = null;
                    foreach (Inferred inf in previous)
                    {
                        IList <Inferred> n2 = inf.InferName(name.Names[i], engine);
                        next = Engine.Union(next, n2);
                    }
                    previous = next;
                }
            }
            return(previous);
        }
        private bool TryImportExternal(string baseName, string name, out Inferred inferred)
        {
            string path = Path.GetDirectoryName(baseName);
            string file = Path.Combine(path, name + ".py");

            Module module;
            if (!modules.TryGetValue(file, out module))
            {
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(file);
                }
                catch
                {
                    inferred = null;
                    return false;
                }

                using (sr)
                {
                    string text = sr.ReadToEnd();
                    module = AnalyzeModule(new QuietCompilerSink(), file, text);
                }
            }

            inferred = new InferredModule(module.ModuleScope);
            return true;
        }
        internal bool TryImport(string baseName, string name, out Inferred inferred)
        {
            if (TryImportExternal(baseName, name, out inferred))
            {
                return true;
            }

            ReflectedModule reflectedScope;
            if (global.TryGetNamespace(name, out reflectedScope))
            {
                inferred = reflectedScope;
                return true;
            }

            ReflectedType reflectedType;
            if (global.TryGetBuiltin(name, out reflectedType))
            {
                inferred = reflectedType;
                return true;
            }

            inferred = null;
            return false;
        }
 public bool TryImport(string name, out Inferred inferred)
 {
     return references.TryImport(this.name, name, out inferred);
 }
 public InferredInstance(Inferred type)
 {
     if (null == type)
     {
         throw new ArgumentNullException("type");
     }
     Debug.Assert(!type.IsInstance);
     this.type = type;
 }
Пример #9
0
 public bool TryImport(string name, out Inferred inferred)
 {
     return(references.TryImport(this.name, name, out inferred));
 }