public ClojureContext(ScriptDomainManager manager, IDictionary<string, object> options) : base(manager) { //Binder = new ClojureBinder(manager); //manager.LoadAssembly(typeof(string).Assembly); //manager.LoadAssembly(typeof(ISeq).Assembly); }
public QsContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { _binder = new QsBinder(); // I have defined end statement to close the execution of the program. // the end statement will return null which in return the execution of current program will end. // always write end in the final line of your qs program. }
/// <summary> /// Creates ScriptRuntime in the current app-domain and initialized according to the the specified settings. /// Creates an instance of host class specified in the setup and associates it with the created runtime. /// Both Runtime and ScriptHost are collocated in the current app-domain. /// </summary> public ScriptRuntime(ScriptRuntimeSetup setup) { ContractUtils.RequiresNotNull(setup, "setup"); // Do this first, so we detect configuration errors immediately DlrConfiguration config = setup.ToConfiguration(); _setup = setup; _host = ReflectionUtils.CreateInstance <ScriptHost>(setup.HostType, setup.HostArguments.ToArray <object>()); ScriptHostProxy hostProxy = new ScriptHostProxy(_host); _manager = new ScriptDomainManager(hostProxy, config); _invariantContext = new InvariantContext(_manager); _io = new ScriptIO(_manager.SharedIO); _engines = new Dictionary <LanguageContext, ScriptEngine>(); bool freshEngineCreated; _globals = new ScriptScope(GetEngineNoLockNoNotification(_invariantContext, out freshEngineCreated), _manager.Globals); // runtime needs to be all set at this point, host code is called _host.SetRuntime(this); }
public ClojureContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { //Binder = new ClojureBinder(manager); //manager.LoadAssembly(typeof(string).Assembly); //manager.LoadAssembly(typeof(ISeq).Assembly); }
public TotemContext(ScriptDomainManager manager, IDictionary<string, object> options) : base(manager) { // TODO: parse options // TODO: register event: manager.AssemblyLoaded engine = new TotemEngine(manager.GetLoadedAssemblyList(), manager.Globals); }
public RemoteDelegate(ScriptEnvironmentSetup setup) { ScriptDomainManager local_environment; NewCreated = ScriptDomainManager.TryCreateLocal(setup, out local_environment); Environment = new RemoteScriptEnvironment(local_environment); }
/// <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(); }
public ScriptLanguageContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : base(domainManager) { _topNamespace = new TopNamespaceTracker(domainManager); _aliasedNamespaceGroups = new Dictionary <string, NamespaceGroupTracker>(); _scriptVisibleNamespaces = new NamespaceGroupTracker("$sxe", _topNamespace); if ((_onAssemblyLoadHandler == null) && (Interlocked.CompareExchange(ref _onAssemblyLoadHandler, OnAssemblyLoaded, null) == null)) { DomainManager.AssemblyLoaded += _onAssemblyLoadHandler; } foreach (var assembly in DomainManager.GetLoadedAssemblyList()) { LoadAssembly(assembly); } LoadAssemblyScriptImports(typeof(ScriptLanguageContext).Assembly); _defaultBinderState = new BinderState(new ScriptBinder(this)); _overloadResolver = new ScriptOverloadResolverFactory(this); EnsureParser(); }
public override void LoadAll(IPluginManagerService svc) { ScriptDomainManager sdm = ScriptDomainManager.CurrentManager; LanguageProvider langs = sdm.GetLanguageProviderByFileExtension("py"); Console.WriteLine(langs); }
public SymplLangContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { // TODO: parse options // TODO: register event manager.AssemblyLoaded _sympl = new Sympl(manager.GetLoadedAssemblyList(), manager.Globals); }
public TopNamespaceTracker(ScriptDomainManager manager) : base(null) { ContractUtils.RequiresNotNull(manager, "manager"); SetTopPackage(this); _manager = manager; HierarchyLock = new object(); }
protected virtual void Initialize() { // A console application needs just the simple setup. // The full setup is potentially expensive as it can involve loading System.Configuration.dll ScriptDomainManager manager; ScriptDomainManager.TryCreateLocal(out manager); }
public ClojureContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { _options = new ClojureOptions(options); _binder = new ClojureBinder(this); _sharedOverloadResolverFactory = new ClojureOverloadResolverFactory(_binder); Interlocked.CompareExchange(ref _default, this, null); }
public ClojureContext(ScriptDomainManager manager, IDictionary<string, object> options) : base(manager) { _options = new ClojureOptions(options); _binder = new ClojureBinder(this); _sharedOverloadResolverFactory = new ClojureOverloadResolverFactory(_binder); Interlocked.CompareExchange(ref _default, this, null); }
internal void RegisterProviders(ScriptDomainManager manager) { Debug.Assert(manager != null); foreach (LanguageProviderSetup provider in _languageProviders) { manager.RegisterLanguageProvider(provider.Assembly, provider.Type, provider.Names); } }
public HappyLanguageContext(ScriptDomainManager manager, IDictionary<string, object> options) : base(manager) { _manager = manager; this.ErrorSink = new HappyErrorSink(this); this.Output = manager.SharedIO.GetWriter(ConsoleStreamType.Output); this.ErrorOutput = manager.SharedIO.GetWriter(ConsoleStreamType.ErrorOutput); this.Binder = new HappyBinder(); this.OverloadResolverFactory = new HappyOverloadResolverFactory(this.Binder); }
private TokenInfo InitAndRead(string code) { tokenCategorizer = new MJC.TokenCategorizer(); ScriptDomainManager scriptMgr = ScriptDomainManager.CurrentManager; tokenCategorizer.Initialize(new object(), new SourceCodeUnit(new MJC.Engine(scriptMgr.GetLanguageProvider(typeof(MJC.Hosting.LanguageProvider)), new MJC.EngineOptions()), code, "test").GetReader(), new SourceLocation()); return(tokenCategorizer.ReadToken()); }
public static IScriptEnvironment Create() { ScriptDomainManager manager; if (!ScriptDomainManager.TryCreateLocal(out manager)) { throw new InvalidOperationException("Environment already created in the current AppDomain"); } return(manager.Environment); }
public VBScriptContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { // TODO: parse options // TODO: register event manager.AssemblyLoaded _vbscript = new VBScript(manager.GetLoadedAssemblyList(), manager.Globals); if (options.ContainsKey("Trace") && options["Trace"].Equals(true)) { _vbscript.Trace = true; } }
public PythonBinder(ScriptDomainManager manager, PythonContext/*!*/ pythonContext, CodeContext context) : base(manager) { ContractUtils.RequiresNotNull(pythonContext, "pythonContext"); _context = pythonContext; if (context != null) { context.LanguageContext.DomainManager.AssemblyLoaded += new EventHandler<AssemblyLoadedEventArgs>(DomainManager_AssemblyLoaded); foreach (Assembly asm in pythonContext.DomainManager.GetLoadedAssemblyList()) { DomainManager_AssemblyLoaded(this, new AssemblyLoadedEventArgs(asm)); } } EmptyGetMemberAction = OldGetMemberAction.Make(this, String.Empty); }
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"); }
public AplusLanguageContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { if (options.ContainsKey("LexerMode")) { this.aplus = new Aplus(manager.Globals, (LexerMode)options["LexerMode"]); } else { LexerMode mode = LexerMode.ASCII; // read the default lexer mode from the application's config file string modeText = ConfigurationManager.AppSettings["LexerMode"]; if (modeText != null) { mode = Aplus.ConvertToLexerMode(modeText); } this.aplus = new Aplus(manager.Globals, mode); } }
/// <summary> /// Creates ScriptRuntime in the current app-domain and initialized according to the the specified settings. /// Creates an instance of host class specified in the setup and associates it with the created runtime. /// Both Runtime and ScriptHost are collocated in the current app-domain. /// </summary> public ScriptRuntime(ScriptRuntimeSetup setup) { ContractUtils.RequiresNotNull(setup, "setup"); // Do this first, so we detect configuration errors immediately DlrConfiguration config = setup.ToConfiguration(); _setup = setup; try { _host = (ScriptHost)Activator.CreateInstance(setup.HostType, setup.HostArguments.ToArray <object>()); } catch (TargetInvocationException e) { throw new InvalidImplementationException(Strings.InvalidCtorImplementation(setup.HostType, e.InnerException.Message), e.InnerException); } catch (Exception e) { throw new InvalidImplementationException(Strings.InvalidCtorImplementation(setup.HostType, e.Message), e); } ScriptHostProxy hostProxy = new ScriptHostProxy(_host); _manager = new ScriptDomainManager(hostProxy, config); _invariantContext = new InvariantContext(_manager); _io = new ScriptIO(_manager.SharedIO); _engines = new Dictionary <LanguageContext, ScriptEngine>(); bool freshEngineCreated; _globals = new ScriptScope(GetEngineNoLockNoNotification(_invariantContext, out freshEngineCreated), _manager.Globals); // runtime needs to be all set at this point, host code is called _host.SetRuntime(this); object noDefaultRefs; if (!setup.Options.TryGetValue("NoDefaultReferences", out noDefaultRefs) || Convert.ToBoolean(noDefaultRefs) == false) { LoadAssembly(typeof(string).GetTypeInfo().Assembly); LoadAssembly(typeof(System.Diagnostics.Debug).GetTypeInfo().Assembly); } }
public SmalltalkLanguageContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : this(domainManager) { if (options.ContainsKey("IncludeStandardClassLibrary")) { this.IncludeStandardClassLibrary = (bool)options["IncludeStandardClassLibrary"]; } else { this.IncludeStandardClassLibrary = true; } if (options.ContainsKey("FileIns")) { this.FileInCommands = (FileInCommand[])options["FileIns"]; } if (this.FileInCommands == null) { this.FileInCommands = new FileInCommand[0]; } }
public SilverContext(ScriptDomainManager domainManager, IDictionary<string, object> options) : base(domainManager) { }
public JSBinder(ScriptDomainManager manager) : base(manager) { }
public TjsContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager) { Binder = new TjsBinder(); DefaultContext.InitializeDefaults(this); }
protected DefaultBinder(ScriptDomainManager manager) : base(manager) { }
internal static void CreateClsContexts(ScriptDomainManager manager, PythonContext/*!*/ context) { if (_defaultCLS == null) { Interlocked.CompareExchange(ref _defaultCLS, CreateDefaultCLSContext(context), null); } }
// The DLR uses reflection to instantiate this and requires the "options" param public RilaContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : base(domainManager) { rila = new Rila(domainManager.GetLoadedAssemblyList(), domainManager.Globals); }
protected LanguageProvider(ScriptDomainManager manager) { Contract.RequiresNotNull(manager, "manager"); _manager = manager; }
public MyContext(ScriptDomainManager domainManager, IDictionary<string, object> options = null) : base(domainManager) { Binder = new DefaultBinder(); }
public TotemContext(ScriptDomainManager manager, IDictionary<string, object> options) : base(manager) { _options = new TotemOptions(options); _builtinModulesDict = CreateBuiltinTable(); TotemDictionary defaultScope = new TotemDictionary(); ModuleContext moduleContext = new ModuleContext(defaultScope, this); _defaultContext = moduleContext.GlobalContext; TotemBinder binder = new TotemBinder(this, _defaultContext); _sharedOverloadResolverFactory = new TotemOverloadResolverFactory(binder, Expression.Constant(_defaultContext)); _binder = binder; if (DefaultContext._default == null) { DefaultContext.InitializeDefaults(_defaultContext); } RecursionLimit = _options.RecursionLimit; InitializeBuiltins(); }
public NovaContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : base(domainManager) { }
static LanguageProvider GetLanguageProvider() { ScriptDomainManager sdm = ScriptDomainManager.CurrentManager; return(sdm.GetLanguageProvider(typeof(IronSchemeLanguageProvider))); }
internal RemoteScriptEnvironment(ScriptDomainManager manager) { Debug.Assert(manager != null); _manager = manager; }
public EssenceSharpContext(ScriptDomainManager manager, Dictionary <String, Object> optionsDictionary) : base(manager) { objectSpace = new ESObjectSpace(); bindToLanguageOptions(optionsDictionary ?? new Dictionary <String, Object>()); librariesLoaded = ObjectSpace.ensureStartUp(options.LibraryNames, options.LoadLibrariesVerbosely, options.ReportTimings); }
internal RubyBinder(ScriptDomainManager /*!*/ manager) : base(manager) { }
internal static void CreateContexts(ScriptDomainManager manager, PythonContext/*!*/ context) { if (_default == null) { Interlocked.CompareExchange(ref _default, CreateDefaultContext(context), null); Interlocked.CompareExchange(ref _defaultBinder, new PythonBinder(manager, context, null), null); } }
private SmalltalkLanguageContext(ScriptDomainManager domainManager) : base(domainManager) { this.SmalltalkEnvironment = new SmalltalkEnvironment(); }
protected ActionBinder(ScriptDomainManager manager) { _manager = manager; }
internal RubyBinder(ScriptDomainManager/*!*/ manager) : base(manager) { }