/// <summary> /// Creates a compiled script with an associated document name. /// </summary> /// <param name="documentName">A document name for the compiled script. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param> /// <param name="code">The script code to compile.</param> /// <returns>A compiled script that can be executed by multiple V8 script engine instances.</returns> public V8Script Compile(string documentName, string code) { VerifyNotDisposed(); var uniqueName = name + ":" + documentNameManager.GetUniqueName(documentName, "Script Document"); return(proxy.Compile(uniqueName, FormatCode ? MiscHelpers.FormatCode(code) : code)); }
/// <summary> /// Creates a compiled script with an associated document name. /// </summary> /// <param name="documentName">A document name for the compiled script. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param> /// <param name="code">The script code to compile.</param> /// <returns>A compiled script that can be executed multiple times without recompilation.</returns> public V8Script Compile(string documentName, string code) { VerifyNotDisposed(); return(ScriptInvoke(() => { var uniqueName = documentNameManager.GetUniqueName(documentName, "Script Document"); return proxy.Compile(uniqueName, FormatCode ? MiscHelpers.FormatCode(code) : code); })); }
/// <summary> /// Creates a compiled script with the specified document information. /// </summary> /// <param name="documentInfo">A structure containing information about the script document.</param> /// <param name="code">The script code to compile.</param> /// <returns>A compiled script that can be executed multiple times without recompilation.</returns> public V8Script Compile(DocumentInfo documentInfo, string code) { VerifyNotDisposed(); return(ScriptInvoke(() => { documentInfo.UniqueName = documentNameManager.GetUniqueName(documentInfo.Name, DocumentInfo.DefaultName); return proxy.Compile(documentInfo, FormatCode ? MiscHelpers.FormatCode(code) : code); })); }
internal UniqueDocumentInfo MakeUnique(IUniqueNameManager manager, DocumentFlags?defaultFlags) { var info = this; if (!info.Flags.HasValue && defaultFlags.HasValue) { info.Flags = defaultFlags; } if (uniqueId < 1) { uniqueId = Interlocked.Increment(ref lastUniqueId).ToUnsigned(); } var uniqueName = manager.GetUniqueName(Name, Category.DefaultName); if (info.Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient)) { uniqueName += " [temp]"; } return(new UniqueDocumentInfo(info, uniqueId, uniqueName)); }
/// <summary> /// Initializes a new V8 runtime instance with the specified name, resource constraints, options, and debug port. /// </summary> /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param> /// <param name="constraints">Resource constraints for the instance.</param> /// <param name="flags">A value that selects options for the operation.</param> /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param> public V8Runtime(string name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, int debugPort) { this.name = nameManager.GetUniqueName(name, GetType().GetRootName()); proxy = V8IsolateProxy.Create(this.name, constraints, flags.HasFlag(V8RuntimeFlags.EnableDebugging), debugPort); }
/// <summary> /// Initializes a new V8 runtime instance with the specified name, resource constraints, options, and debug port. /// </summary> /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param> /// <param name="constraints">Resource constraints for the instance.</param> /// <param name="flags">A value that selects options for the operation.</param> /// <param name="debugPort">A TCP port on which to listen for a debugger connection.</param> public V8Runtime(string name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, int debugPort) { Name = nameManager.GetUniqueName(name, GetType().GetRootName()); proxy = V8IsolateProxy.Create(Name, constraints, flags, debugPort); }