/// <summary> /// Creates a new local <see cref="ScriptDomainManager"/> unless it already exists. /// Returns either <c>true</c> and the newly created environment initialized according to the provided setup information /// or <c>false</c> and the existing one ignoring the specified setup information. /// </summary> internal static bool TryCreateLocal(ScriptEnvironmentSetup setup, out ScriptDomainManager manager) { bool new_created = false; if (_singleton == null) { if (setup == null) { setup = GetSetupInformation(); } lock (_singletonLock) { if (_singleton == null) { ScriptDomainManager singleton = new ScriptDomainManager(setup); Utilities.MemoryBarrier(); _singleton = singleton; new_created = true; } } } manager = _singleton; return(new_created); }
internal IronSchemeLanguageProvider(ScriptDomainManager x) : base(x) { ScriptDomainManager.Options.DynamicStackTraceSupport = false; Runtime.Closure.ConsFromArray = Runtime.Cons.FromArray; Runtime.Closure.ConsStarFromArray = delegate(object[] args) { return Builtins.ToImproper(Cons.FromArray(args)); }; Runtime.Closure.Unspecified = Builtins.Unspecified; Runtime.Closure.ArrayFromCons = Builtins.ListToVector; Initialize(); // only register when done x.RegisterLanguageProvider("IronScheme", "IronScheme.Hosting.IronSchemeLanguageProvider", ".sps", ".ss", ".sls"); }
/// <summary> /// Creates a new local <see cref="ScriptDomainManager"/> unless it already exists. /// Returns either <c>true</c> and the newly created environment initialized according to the provided setup information /// or <c>false</c> and the existing one ignoring the specified setup information. /// </summary> internal static bool TryCreateLocal(out ScriptDomainManager manager) { bool new_created = false; if (_singleton == null) { lock (_singletonLock) { if (_singleton == null) { ScriptDomainManager singleton = new ScriptDomainManager(); _singleton = singleton; new_created = true; } } } manager = _singleton; return(new_created); }
/// <summary> /// This will take an assembly object which the user has loaded and return a new set of ScriptCode�s which have /// been loaded into the provided ScriptDomainManager. /// /// If the language associated with the ScriptCode�s has not already been loaded the DLR will load the /// LanguageContext into the ScriptDomainManager based upon the saved LanguageContext type. /// /// If the LanguageContext or the version of the DLR the language was compiled against is unavailable a /// TypeLoadException will be raised unless policy has been applied by the administrator to redirect bindings. /// </summary> public static ScriptCode[] LoadFromAssembly(ScriptDomainManager runtime, Assembly assembly) { ContractUtils.RequiresNotNull(runtime, "runtime"); ContractUtils.RequiresNotNull(assembly, "assembly"); // get the type which has our cached code... Type t = assembly.GetType("DLRCachedCode"); if (t == null) { return(new ScriptCode[0]); } List <ScriptCode> codes = new List <ScriptCode>(); MethodInfo mi = t.GetMethod("GetScriptCodeInfo"); if (mi.IsSpecialName && mi.IsDefined(typeof(DlrCachedCodeAttribute), false)) { var infos = (MutableTuple <Type[], Delegate[][], string[][], string[][]>)mi.Invoke(null, ArrayUtils.EmptyObjects); for (int i = 0; i < infos.Item000.Length; i++) { Type curType = infos.Item000[i]; LanguageContext lc = runtime.GetLanguage(curType); Debug.Assert(infos.Item001[i].Length == infos.Item002[i].Length); Delegate[] methods = infos.Item001[i]; string[] names = infos.Item002[i]; string[] customData = infos.Item003[i]; for (int j = 0; j < methods.Length; j++) { codes.Add(lc.LoadCompiledCode(methods[j], names[j], customData[j])); } } } return(codes.ToArray()); }
/// <summary> /// Must not be called under a lock as it can potentially call a user code. /// </summary> /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception> /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception> public LanguageProvider LoadProvider(ScriptDomainManager manager) { if (_provider == null) { if (_type == null) { try { _type = ScriptDomainManager.CurrentManager.PAL.LoadAssembly(_assemblyName).GetType(_typeName, true); } catch (Exception e) { throw new MissingTypeException(MakeAssemblyQualifiedName(_assemblyName, _typeName), e); } } lock (manager._languageProvidersLock) { manager._languageTypes[_type.AssemblyQualifiedName] = this; } // needn't to be locked, we can create multiple LPs: LanguageProvider provider = ReflectionUtils.CreateInstance <LanguageProvider>(_type, manager); _provider = provider; } return(_provider); }
internal ScriptEnvironment(ScriptDomainManager manager) { Debug.Assert(manager != null); _manager = manager; }
/// <summary> /// Must not be called under a lock as it can potentially call a user code. /// </summary> /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception> /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception> public LanguageProvider LoadProvider(ScriptDomainManager manager) { if (_provider == null) { if (_type == null) { try { _type = ScriptDomainManager.CurrentManager.PAL.LoadAssembly(_assemblyName).GetType(_typeName, true); } catch (Exception e) { throw new MissingTypeException(MakeAssemblyQualifiedName(_assemblyName, _typeName), e); } } lock (manager._languageProvidersLock) { manager._languageTypes[_type.AssemblyQualifiedName] = this; } // needn't to be locked, we can create multiple LPs: LanguageProvider provider = ReflectionUtils.CreateInstance<LanguageProvider>(_type, manager); Utilities.MemoryBarrier(); _provider = provider; } return _provider; }
/// <summary> /// Creates a new local <see cref="ScriptDomainManager"/> unless it already exists. /// Returns either <c>true</c> and the newly created environment initialized according to the provided setup information /// or <c>false</c> and the existing one ignoring the specified setup information. /// </summary> internal static bool TryCreateLocal(out ScriptDomainManager manager) { bool new_created = false; if (_singleton == null) { lock (_singletonLock) { if (_singleton == null) { ScriptDomainManager singleton = new ScriptDomainManager(); Utilities.MemoryBarrier(); _singleton = singleton; new_created = true; } } } manager = _singleton; return new_created; }
public void Init() { MsS.ScriptDomainManager scriptMgr = MsS.ScriptDomainManager.CurrentManager; provider = (MonoJCH.LanguageProvider)scriptMgr.GetLanguageProvider(typeof(MonoJCH.LanguageProvider)); }
public ToyLanguageProvider(ScriptDomainManager manager) : base(manager) { }