public ScriptModuleHandle CreateModuleFromSource(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext)
        {
            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);
            if (externalContext != null)
            {
                foreach (var item in externalContext)
                {
                    compiler.DefineVariable(item.Key, SymbolType.ContextProperty);
                }
            }

            return(compiler.CreateModule(code));
        }
示例#2
0
        public ModuleImage CompileModuleFromSource(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext)
        {
            compiler.DefineVariable("ЭтотОбъект", "ThisObject", SymbolType.ContextProperty);
            if (externalContext != null)
            {
                foreach (var item in externalContext)
                {
                    compiler.DefineVariable(item.Key, null, SymbolType.ContextProperty);
                }
            }

            return(compiler.Compile(code));
        }
        public static ModuleImage CompileModule(CompilerService compiler, ICodeSource src)
        {
            compiler.DefineVariable(THISOBJ_RU, THISOBJ_EN, SymbolType.ContextProperty);
            for (int i = 0; i < _ownProperties.Count; i++)
            {
                var currentProp = _ownProperties.GetProperty(i);
                compiler.DefineVariable(currentProp.Name, currentProp.Alias, SymbolType.ContextProperty);
            }

            for (int i = 0; i < _ownMethods.Count; i++)
            {
                compiler.DefineMethod(_ownMethods.GetMethodInfo(i));
            }

            return(compiler.Compile(src));
        }
示例#4
0
        private IRuntimeContextInstance LoadAndCreate(CompilerService compiler, Environment.ICodeSource code)
        {
            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);
            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);

            return(_engine.NewObject(loadedHandle.Module));
        }
        public ModuleImage CompileModuleFromSource(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext)
        {
            compiler.DefineVariable("ЭтотОбъект", "ThisObject", SymbolType.ContextProperty);

            foreach (var methodInfo in UserScriptContextInstance.GetOwnMethodsDefinition())
            {
                compiler.DefineMethod(methodInfo);
            }

            if (externalContext != null)
            {
                foreach (var item in externalContext)
                {
                    compiler.DefineVariable(item.Key, null, SymbolType.ContextProperty);
                }
            }

            return(compiler.Compile(code));
        }
示例#6
0
        private ModuleHandle LoadAndRegister(Type type, CompilerService compiler, string typeName, Environment.ICodeSource code)
        {
            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);

            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);

            _loadedModules.Add(typeName, loadedHandle.Module);

            TypeManager.RegisterType(typeName, type);

            return(moduleHandle);
        }
示例#7
0
        private void LoadAndRegister(Type type, CompilerService compiler, string typeName, Environment.ICodeSource code)
        {
            if (_loadedModules.ContainsKey(typeName))
            {
                return;
            }

            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);

            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);

            _loadedModules.Add(typeName, loadedHandle.Module);
            using (var md5Hash = MD5.Create())
            {
                var hash = GetMd5Hash(md5Hash, code.Code);
                _fileHashes.Add(typeName, hash);
            }

            TypeManager.RegisterType(typeName, type);
        }
        private void LoadAndRegister(Type type, CompilerService compiler, string typeName, Environment.ICodeSource code)
        {
            if(_loadedModules.ContainsKey(typeName))
            {
                return;
            }

            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);

            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);
            _loadedModules.Add(typeName, loadedHandle.Module);
            using(var md5Hash = MD5.Create())
            {
                var hash = GetMd5Hash(md5Hash, code.Code);
                _fileHashes.Add(typeName, hash);
            }

            TypeManager.RegisterType(typeName, type);
        }
        private IRuntimeContextInstance LoadAndCreate(CompilerService compiler, Environment.ICodeSource code)
        {
            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);
            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);

            return _engine.NewObject(loadedHandle.Module);
        }
        private IRuntimeContextInstance LoadAndCreate(CompilerService compiler, Environment.ICodeSource code, ExternalContextData externalContext)
        {
            compiler.DefineVariable("ЭтотОбъект", SymbolType.ContextProperty);
            if(externalContext != null)
            {
                foreach (var item in externalContext)
                {
                    compiler.DefineVariable(item.Key, SymbolType.ContextProperty);
                }
            }

            var moduleHandle = compiler.CreateModule(code);
            var loadedHandle = _engine.LoadModuleImage(moduleHandle);

            return _engine.NewObject(loadedHandle.Module, externalContext);

        }