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)); }
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)); }
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)); }
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); }
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); }