internal override void Close() { this.Remove(); base.Close(); this.hostObject = null; this.scope = null; }
internal override void Close() { base.Close(); this.binaryCode = null; this.scope = null; this.codeContext = null; this.compiledBlock = null; }
internal VsaScriptScope(VsaEngine engine, string itemName, VsaScriptScope parent) : base(engine, itemName, (VsaItemType)(int)VSAITEMTYPE2.SCRIPTSCOPE, VsaItemFlag.None){ this.parent = parent; this.scope = null; this.items = new ArrayList(8); this.isCompiled = false; this.isClosed = false; }
internal VsaScriptScope(VsaEngine engine, string itemName, VsaScriptScope parent) : base(engine, itemName, (JSVsaItemType) 0x13, JSVsaItemFlag.None) { this.parent = parent; this.scope = null; this.items = new ArrayList(8); this.isCompiled = false; this.isClosed = false; }
internal override void Reset() { base.Reset(); this.hostObject = null; this.exposed = false; this.compiled = false; this.scope = null; }
internal VsaScriptScope(VsaEngine engine, string itemName, VsaScriptScope parent) : base(engine, itemName, (JSVsaItemType)0x13, JSVsaItemFlag.None) { this.parent = parent; this.scope = null; this.items = new ArrayList(8); this.isCompiled = false; this.isClosed = false; }
internal VsaScriptScope(VsaEngine engine, string itemName, VsaScriptScope parent) : base(engine, itemName, (VsaItemType)(int)VSAITEMTYPE2.SCRIPTSCOPE, VsaItemFlag.None) { this.parent = parent; this.scope = null; this.items = new ArrayList(8); this.isCompiled = false; this.isClosed = false; }
internal VsaScriptCode(VsaEngine engine, string itemName, JSVsaItemType type, IVsaScriptScope scope) : base(engine, itemName, type, JSVsaItemFlag.None) { this.binaryCode = null; this.executed = false; this.scope = (VsaScriptScope)scope; this.codeContext = new Context(new DocumentContext(this), null); this.compiledBlock = null; this.compileToIL = true; this.optimize = true; }
internal VsaScriptCode(VsaEngine engine, string itemName, JSVsaItemType type, IVsaScriptScope scope) : base(engine, itemName, type, JSVsaItemFlag.None) { this.binaryCode = null; this.executed = false; this.scope = (VsaScriptScope) scope; this.codeContext = new Context(new DocumentContext(this), null); this.compiledBlock = null; this.compileToIL = true; this.optimize = true; }
internal VsaHostObject(VsaEngine engine, string itemName, JSVsaItemType type, VsaScriptScope scope) : base(engine, itemName, type, JSVsaItemFlag.None) { this.hostObject = null; this.exposeMembers = false; this.isVisible = false; this.exposed = false; this.compiled = false; this.scope = scope; this.field = null; this.typeString = "System.Object"; }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type, VsaScriptScope scope) : base(engine, itemName, type, VsaItemFlag.None){ this.hostObject = null; this.exposeMembers = false; this.isVisible = false; this.exposed = false; this.compiled = false; this.scope = scope; // non-null only when the VsaHostObject is added to a VsaScriptScope (rather than being added directly to the engine) this.field = null; this.typeString = "System.Object"; }
internal override void Close() { foreach (Object item in this.items) { ((VsaItem)item).Close(); } this.items = null; this.parent = null; this.scope = null; this.isClosed = true; }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type, VsaScriptScope scope) : base(engine, itemName, type, VsaItemFlag.None) { this.hostObject = null; this.exposeMembers = false; this.isVisible = false; this.exposed = false; this.compiled = false; this.scope = scope; // non-null only when the VsaHostObject is added to a VsaScriptScope (rather than being added directly to the engine) this.field = null; this.typeString = "System.Object"; }
private void AddNamedItemNamespace() { GlobalScope scope = (GlobalScope) this.Scope.GetObject(); if (scope.isComponentScope) { scope = (GlobalScope) scope.GetParent(); } ScriptObject parent = scope.GetParent(); VsaNamedItemScope scope2 = new VsaNamedItemScope(this.GetObject(), parent, base.engine); scope.SetParent(scope2); scope2.SetParent(parent); }
public virtual IVsaItem AddItem(string itemName, VsaItemType type) { VsaItem item = null; if (this.isClosed) { throw new VsaException(VsaError.EngineClosed); } if (null != GetItem(itemName)) { throw new VsaException(VsaError.ItemNameInUse); } switch ((int)type) { case (int)VSAITEMTYPE2.HOSTOBJECT: case (int)VSAITEMTYPE2.HOSTSCOPE: case (int)VSAITEMTYPE2.HOSTSCOPEANDOBJECT: item = new VsaHostObject(this.engine, itemName, (VsaItemType)type, this); if (type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPE || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) { ((VsaHostObject)item).exposeMembers = true; } if (type == (VsaItemType)VSAITEMTYPE2.HOSTOBJECT || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) { ((VsaHostObject)item).isVisible = true; } if (this.engine.IsRunning) { ((VsaHostObject)item).Compile(); ((VsaHostObject)item).Run(); } break; case (int)VSAITEMTYPE2.SCRIPTSCOPE: item = new VsaScriptScope(this.engine, itemName, this); break; } if (null != item) { //if (!this.engine.IsRunning) this.items.Add(item); } else { throw new VsaException(VsaError.ItemTypeNotSupported); } return(item); }
private void AddNamedItemNamespace() { GlobalScope scope = (GlobalScope)this.Scope.GetObject(); if (scope.isComponentScope) { scope = (GlobalScope)scope.GetParent(); } ScriptObject parent = scope.GetParent(); VsaNamedItemScope scope2 = new VsaNamedItemScope(this.GetObject(), parent, base.engine); scope.SetParent(scope2); scope2.SetParent(parent); }
public virtual IVsaItem AddItem(string itemName, VsaItemType type){ VsaItem item = null; if (this.isClosed) throw new VsaException(VsaError.EngineClosed); if (null != GetItem(itemName)) throw new VsaException(VsaError.ItemNameInUse); switch ((int)type){ case (int)VSAITEMTYPE2.HOSTOBJECT: case (int)VSAITEMTYPE2.HOSTSCOPE: case (int)VSAITEMTYPE2.HOSTSCOPEANDOBJECT: item = new VsaHostObject(this.engine, itemName, (VsaItemType)type, this); if (type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPE || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT){ ((VsaHostObject)item).exposeMembers = true; } if (type == (VsaItemType)VSAITEMTYPE2.HOSTOBJECT || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) ((VsaHostObject)item).isVisible = true; if (this.engine.IsRunning){ ((VsaHostObject)item).Compile(); ((VsaHostObject)item).Run(); } break; case (int)VSAITEMTYPE2.SCRIPTSCOPE: item = new VsaScriptScope(this.engine, itemName, this); break; } if (null != item){ //if (!this.engine.IsRunning) this.items.Add(item); }else throw new VsaException(VsaError.ItemTypeNotSupported); return item; }
protected override void DoClose(){ ((VsaItems)this.vsaItems).Close(); if (null != this.globalScope) this.globalScope.Close(); this.vsaItems = null; this.engineSite = null; this.globalScope = null; this.runningThread = null; this.compilerGlobals = null; this.globals = null; ScriptStream.Out = Console.Out; ScriptStream.Error = Console.Error; this.rawPE = null; this.rawPDB = null; this.isClosed = true; if (this.tempDirectory != null && Directory.Exists(this.tempDirectory)) Directory.Delete(this.tempDirectory); }
public void Restart(){ this.TryObtainLock(); try{ ((VsaItems)this.vsaItems).Close(); if (null != this.globalScope) this.globalScope.Close(); this.globalScope = null; this.vsaItems = new VsaItems(this); this.isEngineRunning = false; this.isEngineCompiled = false; this.isCompilerSet = false; this.isClosed = false; this.runningThread = null; this.globals = null; }finally{ this.ReleaseLock(); } }
public VsaEngine(bool fast) : base("JScript", VsaEngine.engineVersion, true){ this.alwaysGenerateIL = false; this.autoRef = false; this.doCRS = false; this.doFast = fast; this.genDebugInfo = false; this.genStartupClass = true; this.doPrint = false; this.doWarnAsError = false; this.nWarningLevel = 4; this.isCLSCompliant = false; this.versionSafe = false; this.PEFileName = null; this.PEFileKind = PEFileKinds.Dll; this.PEKindFlags = PortableExecutableKinds.ILOnly; this.PEMachineArchitecture = ImageFileMachine.I386; this.ReferenceLoaderAPI = LoaderAPI.LoadFrom; this.errorCultureInfo = null; this.libpath = null; this.libpathList = null; this.globalScope = null; this.vsaItems = new VsaItems(this); this.packages = null; this.scopes = null; this.classCounter = 0; this.implicitAssemblies = null; this.implicitAssemblyCache = null; this.cachedTypeLookups = null; this.isEngineRunning = false; this.isEngineCompiled = false; this.isCompilerSet = false; this.isClosed = false; this.runningThread = null; this.compilerGlobals = null; this.globals = null; this.runtimeDirectory = null; Globals.contextEngine = this; this.runtimeAssembly = null; this.typenameTable = null; }
internal override void Close(){ foreach (Object item in this.items) ((VsaItem)item).Close(); this.items = null; this.parent = null; this.scope = null; this.isClosed = true; }
public virtual IJSVsaItem AddItem(string itemName, JSVsaItemType type) { VsaItem item = null; if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } if (this.GetItem(itemName) != null) { throw new JSVsaException(JSVsaError.ItemNameInUse); } switch (((int) type)) { case 0x10: case 0x11: case 0x12: item = new VsaHostObject(base.engine, itemName, type, this); if ((type == ((JSVsaItemType) 0x11)) || (type == ((JSVsaItemType) 0x12))) { ((VsaHostObject) item).exposeMembers = true; } if ((type == ((JSVsaItemType) 0x10)) || (type == ((JSVsaItemType) 0x12))) { ((VsaHostObject) item).isVisible = true; } if (base.engine.IsRunning) { ((VsaHostObject) item).Compile(); ((VsaHostObject) item).Run(); } break; case 0x13: item = new VsaScriptScope(base.engine, itemName, this); break; case 20: item = new VsaScriptCode(base.engine, itemName, type, this); break; case 0x15: if (!base.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineNotRunning); } item = new VsaScriptCode(base.engine, itemName, type, this); break; case 0x16: if (!base.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineNotRunning); } item = new VsaScriptCode(base.engine, itemName, type, this); break; } if (item == null) { throw new JSVsaException(JSVsaError.ItemTypeNotSupported); } this.items.Add(item); return item; }
protected override void DoClose(){ ((VsaItems)this.vsaItems).Close(); if (null != this.globalScope) this.globalScope.Close(); this.vsaItems = null; this.engineSite = null; this.globalScope = null; this.runningThread = null; this.compilerGlobals = null; this.globals = null; ScriptStream.Out = Console.Out; ScriptStream.Error = Console.Error; this.DeleteCachedCompiledState(); this.isClosed = true; // The following calls ensure that all pointers to unmanaged objects get properly released // and avoid memory leaks on shutdown. GC.Collect() should be enough by itself when COM+ // takes care of the second automatically. GC.Collect(); }
internal override void Close() { foreach (object obj2 in this.items) { ((VsaItem) obj2).Close(); } this.items = null; this.parent = null; this.scope = null; this.isClosed = true; }
protected override void ResetCompiledState() { if (this.globalScope != null) { this.globalScope.Reset(); this.globalScope = null; } this.classCounter = 0; base.haveCompiledState = false; base.failedCompilation = true; base.compiledRootNamespace = null; base.startupClass = null; this.compilerGlobals = null; this.globals = null; foreach (object obj2 in base.vsaItems) { ((VsaItem) obj2).Reset(); } this.implicitAssemblies = null; this.implicitAssemblyCache = null; this.cachedTypeLookups = null; base.isEngineCompiled = false; base.isEngineRunning = false; this.isCompilerSet = false; this.packages = null; if (!this.doSaveAfterCompile) { this.PEFileName = null; } this.rawPE = null; this.rawPDB = null; }
public virtual IJSVsaItem AddItem(string itemName, JSVsaItemType type) { VsaItem item = null; if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } if (this.GetItem(itemName) != null) { throw new JSVsaException(JSVsaError.ItemNameInUse); } switch (((int)type)) { case 0x10: case 0x11: case 0x12: item = new VsaHostObject(base.engine, itemName, type, this); if ((type == ((JSVsaItemType)0x11)) || (type == ((JSVsaItemType)0x12))) { ((VsaHostObject)item).exposeMembers = true; } if ((type == ((JSVsaItemType)0x10)) || (type == ((JSVsaItemType)0x12))) { ((VsaHostObject)item).isVisible = true; } if (base.engine.IsRunning) { ((VsaHostObject)item).Compile(); ((VsaHostObject)item).Run(); } break; case 0x13: item = new VsaScriptScope(base.engine, itemName, this); break; case 20: item = new VsaScriptCode(base.engine, itemName, type, this); break; case 0x15: if (!base.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineNotRunning); } item = new VsaScriptCode(base.engine, itemName, type, this); break; case 0x16: if (!base.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineNotRunning); } item = new VsaScriptCode(base.engine, itemName, type, this); break; } if (item == null) { throw new JSVsaException(JSVsaError.ItemTypeNotSupported); } this.items.Add(item); return(item); }
public VsaEngine(bool fast) : base("JScript", "7.0.3300.0", true){ this.alwaysGenerateIL = false; this.autoRef = false; this.doCRS = false; this.doFast = fast; this.cachedPEFileName = ""; this.genDebugInfo = false; this.genStartupClass = true; this.doPrint = false; this.doWarnAsError = false; this.nWarningLevel = 4; this.isCLSCompliant = false; this.versionSafe = false; this.PEFileName = null; this.PEFileKind = PEFileKinds.Dll; this.errorCultureInfo = null; this.libpath = null; this.libpathList = null; this.globalScope = null; this.vsaItems = new VsaItems(this); this.packages = null; this.scopes = null; this.classCounter = 0; this.implicitAssemblies = null; this.implicitAssemblyCache = null; this.cachedTypeLookups = null; this.isEngineRunning = false; this.isEngineCompiled = false; this.isCompilerSet = false; this.isClosed = false; this.runningThread = null; this.compilerGlobals = null; this.globals = null; this.runtimeDirectory = null; Globals.contextEngine = this; this.runtimeAssembly = null; this.typenameTable = null; }
// the debugger restart the engine to run different expression evaluation public virtual void Restart(){ this.TryObtainLock(); try{ ((VsaItems)this.vsaItems).Close(); if (null != this.globalScope) this.globalScope.Close(); this.globalScope = null; this.vsaItems = new VsaItems(this); this.isEngineRunning = false; this.isEngineCompiled = false; this.isCompilerSet = false; this.isClosed = false; this.runningThread = null; this.globals = null; // These are the same as the calls in Close(). Ideally, they should be necessary only in Close(), // but actually the debugger leaks memory on shutdown if they are not present at both places. GC.Collect(); }finally{ this.ReleaseLock(); } }
internal void CheckForErrors(){ if (!this.isClosed && !this.isEngineCompiled){ SetUpCompilerEnvironment(); Globals.ScopeStack.Push(this.GetGlobalScope().GetObject()); try{ foreach (Object item in this.vsaItems){ if (item is VsaReference) ((VsaReference)item).Compile(); //Load the assembly into memory. } if (this.vsaItems.Count > 0) this.SetEnclosingContext(new WrappedNamespace("", this)); //Provide a way to find types that are not inside of a name space foreach (Object item in this.vsaItems){ if (!(item is VsaReference)) ((VsaItem)item).CheckForErrors(); } if (null != this.globalScope) this.globalScope.CheckForErrors(); //In case the host added items to the global scope. }finally{ Globals.ScopeStack.Pop(); } } this.globalScope = null; }
internal void CheckForErrors() { if (!base.isClosed && !base.isEngineCompiled) { this.SetUpCompilerEnvironment(); this.Globals.ScopeStack.Push(this.GetGlobalScope().GetObject()); try { foreach (object obj2 in base.vsaItems) { if (obj2 is VsaReference) { ((VsaReference) obj2).Compile(); } } if (base.vsaItems.Count > 0) { this.SetEnclosingContext(new WrappedNamespace("", this)); } foreach (object obj3 in base.vsaItems) { if (!(obj3 is VsaReference)) { ((VsaItem) obj3).CheckForErrors(); } } if (this.globalScope != null) { this.globalScope.CheckForErrors(); } } finally { this.Globals.ScopeStack.Pop(); } } this.globalScope = null; }
public virtual IVsaScriptScope GetGlobalScope(){ if (null == this.globalScope){ this.globalScope = new VsaScriptScope(this, "Global", null); GlobalScope scope = (GlobalScope)this.globalScope.GetObject(); scope.globalObject = this.Globals.globalObject; scope.fast = this.doFast; scope.isKnownAtCompileTime = this.doFast; } return this.globalScope; }
internal VsaScriptScope(VsaEngine engine, string item_name, VsaScriptScope parent) : base(engine, item_name, (VsaItemType) 0, VsaItemFlag.None) { this.parent = parent; items = new ArrayList (8); }
protected override void ResetCompiledState(){ if (this.globalScope != null){ this.globalScope.Reset(); this.globalScope = null; } this.classCounter = 0; this.haveCompiledState = false; this.failedCompilation = true; this.compiledRootNamespace = null; this.startupClass = null; this.compilerGlobals = null; this.globals = null; foreach (Object item in this.vsaItems) ((VsaItem)item).Reset(); this.implicitAssemblies = null; this.implicitAssemblyCache = null; this.cachedTypeLookups = null; this.isEngineCompiled = false; this.isEngineRunning = false; this.isCompilerSet = false; this.packages = null; this.DeleteCachedCompiledState(); }
internal VsaScriptScope(VsaEngine engine, string item_name, VsaScriptScope parent) : base(engine, item_name, (VsaItemType)0, VsaItemFlag.None) { this.parent = parent; items = new ArrayList(8); }