public IDictionary <string, IScriptModule> GetPublishedModules()
        {
            IDictionary <string, IScriptModule> result = _manager.Environment.GetPublishedModules();

            string[] keys = new string[result.Count];
            result.Keys.CopyTo(keys, 0);

            foreach (string key in keys)
            {
                result[key] = RemoteWrapper.WrapRemotable <IScriptModule>(result[key]);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute code within a given module context and returns the result.
        /// The module must be local with respect to the compiled code object.
        /// </summary>
        public object Evaluate(IScriptModule module)
        {
            ScriptModule localModule;

            if (module == null)
            {
                localModule = RemoteWrapper.TryGetLocal <ScriptModule>(ScriptDomainManager.CurrentManager.Host.DefaultModule);
            }
            else
            {
                localModule = RemoteWrapper.GetLocalArgument <ScriptModule>(module, "module");
            }

            return(_code.Run(localModule));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a module.
        /// <c>dictionary</c> can be <c>null</c>
        /// </summary>
        /// <returns></returns>
        public IScriptModule CreateModule(string name, ScriptModuleKind kind, IAttributesCollection dictionary, params ICompiledCode[] compiledCodes)
        {
            Contract.RequiresNotNullItems(compiledCodes, "compiledCodes");

            ScriptCode[] script_codes = new ScriptCode[compiledCodes.Length];
            for (int i = 0; i < compiledCodes.Length; i++)
            {
                script_codes[i] = ScriptCode.FromCompiledCode(RemoteWrapper.TryGetLocal <CompiledCode>(compiledCodes[i]));
                if (script_codes[i] == null)
                {
                    throw new ArgumentException(Resources.RemoteCodeModuleComposition, String.Format("{0}[{1}]", "compiledCodes", i));
                }
            }

            return(_manager.CreateModule(name, kind, new Scope(dictionary), script_codes));
        }
Ejemplo n.º 4
0
 public ICompiledCode CompileFileContent(string path, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileFileContent(path, module)));
 }
Ejemplo n.º 5
0
 public ICompiledCode CompileFileContent(string path)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileFileContent(path)));
 }
Ejemplo n.º 6
0
 public IScriptModule CompileFile(string path, string moduleName)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_engine.CompileFile(path, moduleName)));
 }
Ejemplo n.º 7
0
 public ICompiledCode CompileInteractiveCode(string code)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileInteractiveCode(code)));
 }
Ejemplo n.º 8
0
 public virtual SourceUnit TryGetSourceFileUnit(IScriptEngine engine, string path, Encoding encoding)
 {
     Debug.Assert(_remoteHost != null);
     return(_remoteHost.TryGetSourceFileUnit(RemoteWrapper.WrapRemotable <IScriptEngine>(engine), path, encoding));
 }
Ejemplo n.º 9
0
 public ICompiledCode CompileSourceUnit(SourceUnit sourceUnit, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileSourceUnit(sourceUnit, module)));
 }
Ejemplo n.º 10
0
 public ICompiledCode CompileStatements(string statement, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileStatements(statement, module)));
 }
 public IScriptModule CompileModule(string name, params SourceUnit[] sourceUnits)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CompileModule(name, sourceUnits)));
 }
 public IScriptModule CreateModule(string name, ScriptModuleKind kind, IAttributesCollection dictionary, params ICompiledCode[] compiledCodes)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CreateModule(name, kind, dictionary, compiledCodes)));
 }
 public IScriptModule CreateModule(string name, params ICompiledCode[] compiledCodes)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CreateModule(name, compiledCodes)));
 }
Ejemplo n.º 14
0
 // Gets a LanguageContext for the specified module that captures the current state
 // of the module which will be used for compilation and execution of the next piece of code against the module.
 private CodeContext GetCodeContext(IScriptModule module)
 {
     return(GetCodeContext(RemoteWrapper.GetLocalArgument <ScriptModule>(module ??
                                                                         ScriptDomainManager.CurrentManager.Host.DefaultModule, "module")));
 }
Ejemplo n.º 15
0
 // throws SerializationException
 public virtual bool TryGetVariable(IScriptEngine engine, SymbolId name, out object value)
 {
     Debug.Assert(_remoteHost != null);
     return(_remoteHost.TryGetVariable(RemoteWrapper.WrapRemotable <IScriptEngine>(engine), name, out value));
 }
Ejemplo n.º 16
0
 public virtual void ModuleCreated(IScriptModule module)
 {
     Contract.RequiresNotNull(module, "module");
     Debug.Assert(_remoteHost != null);
     _remoteHost.ModuleCreated(RemoteWrapper.WrapRemotable <IScriptModule>(module));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// TODO: Called under a lock. Should work with the engine via the argument only.
 /// </summary>
 public virtual void EngineCreated(IScriptEngine engine)
 {
     Contract.RequiresNotNull(engine, "engine");
     Debug.Assert(_remoteHost != null);
     _remoteHost.EngineCreated(RemoteWrapper.WrapRemotable <IScriptEngine>(engine));
 }
Ejemplo n.º 18
0
 public ICompiledCode CompileCode(string code, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileCode(code, module)));
 }
Ejemplo n.º 19
0
 public ICompiledCode CompileExpression(string expression, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileExpression(expression, module)));
 }
 public IScriptModule CompileModule(string name, ScriptModuleKind kind, CompilerOptions options, ErrorSink errorSink, IAttributesCollection dictionary, params SourceUnit[] sourceUnits)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CompileModule(name, kind, options, errorSink, dictionary, sourceUnits)));
 }
Ejemplo n.º 21
0
 public ICompiledCode CompileCodeDom(System.CodeDom.CodeMemberMethod code, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileCodeDom(code, module)));
 }
Ejemplo n.º 22
0
 public IScriptModule MakeModule(string name)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_compiledCode.MakeModule(name)));
 }
Ejemplo n.º 23
0
 public ICompiledCode CompileSourceUnit(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileSourceUnit(sourceUnit, options, errorSink)));
 }
Ejemplo n.º 24
0
 public void PublishModule(IScriptModule module, string publicName)
 {
     _manager.PublishModule(RemoteWrapper.GetLocalArgument <ScriptModule>(module, "module"), publicName);
 }