예제 #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);
        }
예제 #3
0
 public InferredInstance(Inferred type)
 {
     if (null == type)
     {
         throw new ArgumentNullException("type");
     }
     Debug.Assert(!type.IsInstance);
     this.type = type;
 }
        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);
        }
예제 #5
0
 public InferredInstance(Inferred type)
 {
     if (null == type) {
         throw new ArgumentNullException("type");
     }
     Debug.Assert(!type.IsInstance);
     this.type = type;
 }
예제 #6
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;
        }
예제 #7
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;
        }
예제 #8
0
 public bool TryImport(string name, out Inferred inferred)
 {
     return references.TryImport(this.name, name, out inferred);
 }
예제 #9
0
 public bool TryImport(string name, out Inferred inferred)
 {
     return(references.TryImport(this.name, name, out inferred));
 }