コード例 #1
0
 public ClojureContext(ScriptDomainManager manager, IDictionary<string, object> options)
     : base(manager)
 {
     //Binder = new ClojureBinder(manager);
     //manager.LoadAssembly(typeof(string).Assembly);
     //manager.LoadAssembly(typeof(ISeq).Assembly);
 }
コード例 #2
0
 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.
 }
コード例 #3
0
ファイル: ScriptRuntime.cs プロジェクト: gaybro8777/ironruby
        /// <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);
        }
コード例 #4
0
ファイル: ClojureContext.cs プロジェクト: ryrency/Misc
 public ClojureContext(ScriptDomainManager manager, IDictionary <string, object> options)
     : base(manager)
 {
     //Binder = new ClojureBinder(manager);
     //manager.LoadAssembly(typeof(string).Assembly);
     //manager.LoadAssembly(typeof(ISeq).Assembly);
 }
コード例 #5
0
ファイル: TotemContext.cs プロジェクト: Alxandr/Totem-2.0
 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);
 }
コード例 #6
0
            public RemoteDelegate(ScriptEnvironmentSetup setup)
            {
                ScriptDomainManager local_environment;

                NewCreated  = ScriptDomainManager.TryCreateLocal(setup, out local_environment);
                Environment = new RemoteScriptEnvironment(local_environment);
            }
コード例 #7
0
ファイル: SavableScriptCode.cs プロジェクト: TerabyteX/main
        /// <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();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
ファイル: AssemblyInfo.cs プロジェクト: anthrax3/xacc.ide
    public override void LoadAll(IPluginManagerService svc)
    {
        ScriptDomainManager sdm = ScriptDomainManager.CurrentManager;

        LanguageProvider langs = sdm.GetLanguageProviderByFileExtension("py");

        Console.WriteLine(langs);
    }
コード例 #10
0
 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);
 }
コード例 #11
0
 public TopNamespaceTracker(ScriptDomainManager manager)
     : base(null)
 {
     ContractUtils.RequiresNotNull(manager, "manager");
     SetTopPackage(this);
     _manager      = manager;
     HierarchyLock = new object();
 }
コード例 #12
0
ファイル: ConsoleHost.cs プロジェクト: tylike/IronScheme
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        internal void RegisterProviders(ScriptDomainManager manager)
        {
            Debug.Assert(manager != null);

            foreach (LanguageProviderSetup provider in _languageProviders)
            {
                manager.RegisterLanguageProvider(provider.Assembly, provider.Type, provider.Names);
            }
        }
コード例 #16
0
ファイル: HappyLanguageContext.cs プロジェクト: dlurton/Happy
 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);
 }
コード例 #17
0
        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());
        }
コード例 #18
0
        public static IScriptEnvironment Create()
        {
            ScriptDomainManager manager;

            if (!ScriptDomainManager.TryCreateLocal(out manager))
            {
                throw new InvalidOperationException("Environment already created in the current AppDomain");
            }

            return(manager.Environment);
        }
コード例 #19
0
        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;
            }
        }
コード例 #20
0
ファイル: PythonBinder.cs プロジェクト: octavioh/ironruby
        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);
        }
コード例 #21
0
        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");
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        /// <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);
            }
        }
コード例 #24
0
        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];
            }
        }
コード例 #25
0
 public SilverContext(ScriptDomainManager domainManager, IDictionary<string, object> options)
     : base(domainManager)
 {
 }
コード例 #26
0
 public JSBinder(ScriptDomainManager manager)
     : base(manager)
 {
 }
コード例 #27
0
ファイル: TjsContext.cs プロジェクト: planetarian/IronTJS
 public TjsContext(ScriptDomainManager manager, IDictionary <string, object> options) : base(manager)
 {
     Binder = new TjsBinder();
     DefaultContext.InitializeDefaults(this);
 }
コード例 #28
0
ファイル: DefaultBinder.cs プロジェクト: rudimk/dlr-dotnet
 protected DefaultBinder(ScriptDomainManager manager)
     : base(manager)
 {
 }
コード例 #29
0
ファイル: DefaultContext.cs プロジェクト: jcteague/ironruby
 internal static void CreateClsContexts(ScriptDomainManager manager, PythonContext/*!*/ context) {
     if (_defaultCLS == null) {
         Interlocked.CompareExchange(ref _defaultCLS, CreateDefaultCLSContext(context), null);
     }
 }
コード例 #30
0
 // 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);
 }
コード例 #31
0
 protected LanguageProvider(ScriptDomainManager manager)
 {
     Contract.RequiresNotNull(manager, "manager");
     _manager = manager;
 }
コード例 #32
0
ファイル: MyLanguage.cs プロジェクト: fgretief/IronLua
 public MyContext(ScriptDomainManager domainManager, IDictionary<string, object> options = null)
     : base(domainManager)
 {
     Binder = new DefaultBinder();
 }
コード例 #33
0
        internal void RegisterProviders(ScriptDomainManager manager) {
            Debug.Assert(manager != null);

            foreach (LanguageProviderSetup provider in _languageProviders) {
                manager.RegisterLanguageProvider(provider.Assembly, provider.Type, provider.Names);
            }
        }
コード例 #34
0
ファイル: TotemContext.cs プロジェクト: Alxandr/IronTotem-3.0
        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();
        }
コード例 #35
0
 public NovaContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : base(domainManager)
 {
 }
コード例 #36
0
        static LanguageProvider GetLanguageProvider()
        {
            ScriptDomainManager sdm = ScriptDomainManager.CurrentManager;

            return(sdm.GetLanguageProvider(typeof(IronSchemeLanguageProvider)));
        }
コード例 #37
0
 internal RemoteScriptEnvironment(ScriptDomainManager manager) {
     Debug.Assert(manager != null);
     _manager = manager;
 }
コード例 #38
0
 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);
 }
コード例 #39
0
ファイル: RubyBinder.cs プロジェクト: gaybro8777/ironruby
 internal RubyBinder(ScriptDomainManager /*!*/ manager)
     : base(manager)
 {
 }
コード例 #40
0
ファイル: DefaultContext.cs プロジェクト: jcteague/ironruby
 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);
     }
 }
コード例 #41
0
 internal RemoteScriptEnvironment(ScriptDomainManager manager)
 {
     Debug.Assert(manager != null);
     _manager = manager;
 }
コード例 #42
0
 private SmalltalkLanguageContext(ScriptDomainManager domainManager)
     : base(domainManager)
 {
     this.SmalltalkEnvironment = new SmalltalkEnvironment();
 }
コード例 #43
0
ファイル: ActionBinder.cs プロジェクト: stantoxt/dlr
 protected ActionBinder(ScriptDomainManager manager)
 {
     _manager = manager;
 }
コード例 #44
0
ファイル: RubyBinder.cs プロジェクト: joshholmes/ironruby
 internal RubyBinder(ScriptDomainManager/*!*/ manager)
     : base(manager) {
 }