public static UriScheme find(string scheme, bool check) { // check cache lock (m_cache) { UriScheme cached = (UriScheme)m_cache[scheme]; if (cached != null) { return(cached); } } try { // lookup scheme type (avoid building index for common types) Type t = null; if (scheme == "fan") { t = Sys.FanSchemeType; } if (scheme == "file") { t = Sys.FileSchemeType; } if (t == null) { string qname = (string)Env.cur().index("sys.uriScheme." + scheme).first(); if (qname == null) { throw UnresolvedErr.make().val; } t = Type.find(qname); } // allocate instance UriScheme s = (UriScheme)t.make(); s.m_scheme = scheme; // add to cache lock (m_cache) { UriScheme cached = (UriScheme)m_cache[scheme]; if (cached != null) { return(cached); } m_cache[scheme] = s; } return(s); } catch (UnresolvedErr.Val) {} catch (System.Exception e) { Err.dumpStack(e); } if (!check) { return(null); } throw UnresolvedErr.make("Unknown scheme: " + scheme).val; }
int executeType(string target) { if (target.IndexOf("::") < 0) { target += "::Main.main"; } else if (target.IndexOf('.') < 0) { target += ".main"; } try { int dot = target.IndexOf('.'); Type type = Type.find(target.Substring(0, dot), true); Method main = type.method(target.Substring(dot + 1), true); return(callMain(type, main)); } catch (Exception e) { if (e is Err.Val) { ((Err.Val)e).err().trace(); } else { Err.dumpStack(e); } return(-1); } }
////////////////////////////////////////////////////////////////////////// // Obj ////////////////////////////////////////////////////////////////////////// public override Type @typeof() { if (m_type == null) { m_type = Type.find("concurrent::Future"); } return(m_type); }
////////////////////////////////////////////////////////////////////////// // Init Env ////////////////////////////////////////////////////////////////////////// private static bool initEnv() { try { string var = (string)Env.cur().vars().get("FAN_ENV"); if (var == null) { return(true); } m_curEnv = (Env)Type.find(var).make(); } catch (Exception e) { initWarn("curEnv", e); } return(true); }
public static Slot find(string qname, bool check) { string typeName, slotName; try { int dot = qname.IndexOf('.'); typeName = qname.Substring(0, dot); slotName = qname.Substring(dot + 1); } catch (Exception) { throw Err.make("Invalid slot qname \"" + qname + "\", use <pod>::<type>.<slot>").val; } Type type = Type.find(typeName, check); if (type == null) { return(null); } return(type.slot(slotName, check)); }