Skip to content
Stéphane Lozier edited this page Jan 18, 2021 · 1 revision

5 Current Issues

Host aborts. Need to provide a way for hosts to signal the DLR to abort execution so that we do not do a rude thread abort while the host is potentially executing deep in its code. The scenario is that the host has provided an OM layer that it protects all over and understands dyn code could abort, but the code internal (lower down) that the OM layer calls is not coded for rude aborts. The host executes dyn code, the dyn code calls back into the hosts OM, and the host then calls internal functions that shouldn't have to be protected everywhere against rude thread aborts. These internal functions do not worry about thread aborts because if that's happening, then the app is going down. The host would like to be able to support user actions to abort dyn code executions (for example, spinning cassette in VSMacros or ctrl-c in Nessie) by setting a ScriptRuntime.AbortExecutions flag. The DLR code periodically checks this, does whatever internal throwing it wants, but then just returns from whatever functions. Is the model that the host has to clear the flag, or can the DLR know to stop all code on all threads, then clear the flag?

Stack depth control. Need to add support for the host to provide a delegate or some control on handling stack overflows. It could set a limit, and when we detect it, we call the host's delegate. It could set the abort flag, kill the thread, perhaps return a value to abort, or whatever.

Engine recycling. Need to design model for engines that can recycle themselves and how to shutdown or reset ScriptRuntimes for use in asp.net like server situations.

Doc exceptions. Doc for each member what exceptions can be thrown, should we define catcher exceptions for lower-level calls (e.g., wrapper for loadassm to hide its nine exceptions).

Global value src loc. Consider host inspecting global value and asking for src line where the value came from for good error msgs to users.

MWeb and error sinking. Error sink'ing and MWeb requirements need to be factored into hosting API.

DLL loading filters. Hosts can control dynamic language file resolution, but they don't get called on for DLL resolution. This means they can't redirect or limit which DLLs can load. Not sure this is meaningful since the code could just use .NET calls from standard BCL libs to load assemblies (eh?).

MBRO/remoting lifetime lease timeout. Currently if you do not use a host for 15 min, it dies, and you lose your data. We've added InitializeLifetimeService on objects to cause them to stay alive forever, but we need to think through the design and the host controls here.

Remote AppDomain DLR exceptions need to remote. An exception may be thrown in the remote AppDomain, and the host application needs to be able to catch this error. Currently there are some DLR exceptions that don't serialize across the AppDomain boundary or contain data that doesn't serialize across the AppDomain boundary. Does it wrap all local exceptions with a remotable exception that refers back to the local exception? Or are all exceptions required to be serializable across AppDomain boundaries.

VB hosting and static info for compiling. One team asked us to support hosts that want to pass static info in for globals or scope variables. We think this makes sense so that when the DLR supports optional explicit typing, inferencing, etc., then hosts could supply optional explicit type info.

The rough idea for how to do this (given current VB and C# namespace and scope chains) is to take a chain of SourceMetadata objects with names and types declared in them. Then, when the host executes the code, it would reproduce the shape of the chain with ScriptScope objects. When hosts construct these ScriptScope chains, they probably should be able to both use SetVar to set add members, or create a ScriptScope on a static .NET object (where the members of the object match the SourceMetadata names and types).

Add a SourceMetadata type with:

  • Names -> Dictionary<string, Type> (ok to use Type since it would have to be loaded in both app domains if doing remote hosting)

  • ReferenceDlls -> string[]

  • ImportedNamespaces -> string[]

  • Parent -> SourceMetadata

Add to ScriptSource:

  • .Compile(CompilerOptions, ErrorSink, SourceMetadata) where first two can be null for defaults.

Add to CompiledCode (if we follow through on supporting this, we might still add this only to a lower-level API like LangCtx):

  • .GetExpressionTree(), but I suspect we also need ...

Add to ScriptScope

  • .Parent -> ScriptScope (returns null by default, must be set in constructor)

GetMembersVerbose. This would return something like IList<Tuple<string,flags>>, but it would support poor man tooling for objects or languages that wanted to report value namespaces or categorize names somehow.

Compiler options between REPL inputs. Ipy.exe compiles the input "from future import truedivision", and then on the next line compile the input "3/2". How does the scope/compiler context flow from the first to the second? Maybe we can unify the VB SrcMetadata request with this to capture compiler options and let them be updated across compilation.

Need to revisit ScriptIO.SetInput. Do we need encoding arg?

public void SetInput(Stream stream, TextReader reader,

Encoding encoding)

Consider expanding LoadAssembly and simplifying name. Probably need to expand to type libs for COM interop (check with BizApps folks):

ScriptRuntime.LoadTypeLibrary(TypeLibrary library)

ScriptRuntime.LoadTypeLibrary(TypeLibraryName libraryName)

TypeLibrary and TypeLibraryName types don’t exist yet. Also consider consolidating:

ScriptRuntime.Load(Assembly assembly)

ScriptRuntime.Load(AssemblyName assembly)

ScriptRuntime.Load(TypeLibrary library)

ScriptRuntime.Load(TypeLibraryName libraryName)

Add a convention for a .NET exception representing failed name look up that is common across all languages. Otherwise, hosts have to handle N different exceptions from all the languages. Can we use the python exception folding trick here?

ObjOps.Equal and Operators.Equals should match in name.

Spec HostingHelpers and think about how it fits the general model.

ScriptScope doesn't offer a case insensitive variable lookup even if languages support it. Since we never fully build the case-insensitive symbol design, and since we intend to go to dict<str,obj> over IAttrColl, we have no model for langs that want to do case-insensitive lookups without O(n) searching the table.

DLR Hostirng Spec

Frontmatter
1 Introduction
2 High-level Hosting Model Concepts
  2.1 Level One -- Script Runtimes, Scopes, and Executing Files and Snippets
    2.1.1 Code Sample -- Application Programmability
  2.2 Level Two -- Engines, Compiled Code, Sources, and Object Operations
    2.2.1 Code Sample -- REPL and Merlin Web
  2.3 Level Three -- Full Control, Remoting, Tool Support, and More
    2.3.1 Code Sample -- Tools Support and Remoting
  2.4 Implementer’s Convenience
3 Hosts Requirements
  3.1 SilverLight (RIA)
  3.2 MerlinWeb (Server Side)
    3.2.1 Compilation
    3.2.2 Globals and Member Injection
    3.2.3 Error handling
  3.3 Base Tools Support
    3.3.1 General Hosting (ScriptEngineServer)
    3.3.2 Language Tool Support (IScriptEngine or ILanguageToolService)
    3.3.3 Static Analysis (Post MIX 07)
  3.4 What Languages and DLR Need to Support
  3.5 Configuration Notes
    3.5.1 Requirements
    3.5.2 Goals
    3.5.3 Scenarios
  3.6 Remote Construction Design Notes
4 API References
  4.1 ScriptRuntime Class
    4.1.1 Class Summary
    4.1.2 Constructor
    4.1.3 Create* Methods
    4.1.4 ExecuteFile Method
    4.1.5 UseFile Method
    4.1.6 Globals Property
    4.1.7 CreateScope Method
    4.1.8 GetEngine Method
    4.1.9 GetEngineByFileExtension Method
    4.1.10 GetEngineByMimeType Method
    4.1.11 GetRegisteredFileExtensions Method
    4.1.12 GetRegisteredLanguageIdentifiers Method
    4.1.13 LoadAssembly Method
    4.1.14 Operations Property
    4.1.15 CreateOperations Methods
    4.1.16 Setup Property
    4.1.17 Host Property
    4.1.18 IO Property
    4.1.19 Shutdown Method
  4.2 ScriptScope Class
    4.2.1 Class Summary
    4.2.2 GetVariable* Methods
    4.2.3 SetVariable Methods
    4.2.4 TryGetVariable* Methods
    4.2.5 ContainsVariable Method
    4.2.6 GetVariableNames Method
    4.2.7 GetItems Method
    4.2.8 RemoveVariable Method
    4.2.9 Engine Property
  4.3 ScriptEngine Class
    4.3.1 Class Summary
    4.3.2 Runtime Property
    4.3.3 LanguageDisplayName Property
    4.3.4 GetRegistered* Methods
    4.3.5 Execute* Methods
    4.3.6 ExecuteFile Methods
    4.3.7 GetScope Method
    4.3.8 Operations Property
    4.3.9 CreateOperations Methods
    4.3.10 CreateScriptSourceFromString Methods
    4.3.11 CreateScriptSourceFromFile Methods
    4.3.12 CreateScriptSource Methods
    4.3.13 CreateScope Method
    4.3.14 GetService Method
    4.3.15 Setup Property
    4.3.16 GetCompilerOptions Method
    4.3.17 GetSearchPaths Method
    4.3.18 SetSearchPaths Method
    4.3.19 LanguageVersion Property
  4.4 ScriptSource Class
    4.4.1 Class Summary
    4.4.2 Path Property
    4.4.3 Kind Property
    4.4.4 GetCodeProperties Methods
    4.4.5 Engine Property
    4.4.6 Compile Methods
    4.4.7 Execute* Methods
    4.4.8 GetReader Method
    4.4.9 DetectEncoding Method
    4.4.10 GetCode Method
    4.4.11 GetCodeLine* Methods
    4.4.12 MapLine Methods
    4.4.13 MapLineToFile Method
  4.5 CompiledCode Class
    4.5.1 Class Summary
    4.5.2 DefaultScope Property
    4.5.3 Engine Property
    4.5.4 Execute* Methods
  4.6 ObjectOperations Class
    4.6.1 Class Summary
    4.6.2 Engine Property
    4.6.3 IsCallable Methods
    4.6.4 Invoke Methods
    4.6.5 InvokeMember Method
    4.6.6 CreateInstance Methods
    4.6.7 GetMember* Methods
    4.6.8 TryGetMember Methods
    4.6.9 ContainsMember Methods
    4.6.10 RemoveMember Methods
    4.6.11 SetMember Methods
    4.6.12 ConvertTo* Methods
    4.6.13 TryConvertTo* Methods
    4.6.14 ExplicitConvertTo* Methods
    4.6.15 TryExplicitConvertTo* Methods
    4.6.16 ImplicitConvertTo* Methods
    4.6.17 TryimplicitConvertTo* Methods
    4.6.18 Unwrap<T> Method
    4.6.19 Format Methods
    4.6.20 GetMemberNames Methods
    4.6.21 GetDocumentation Methods
    4.6.22 GetCallSignatures Methods
    4.6.23 DoOperation* Methods
    4.6.24 Add Methods
    4.6.25 Subtract Methods
    4.6.26 Power Methods
    4.6.27 Multiply Methods
    4.6.28 Divide Methods
    4.6.29 Modulo Methods
    4.6.30 LeftShift Methods
    4.6.31 RightShift Methods
    4.6.32 BitwiseAnd Methods
    4.6.33 BitwiseOr Methods
    4.6.34 ExclusiveOr Methods
    4.6.35 Equal Methods
    4.6.36 NotEqual Methods
    4.6.37 LessThan Methods
    4.6.38 LessThanOrEqual Methods
    4.6.39 GreaterThan Methods
    4.6.40 GreaterThanOrEqual Methods
  4.7 SourceCodeKind Enum
    4.7.1 Type Summary
    4.7.2 Members
  4.8 ScriptCodeParseResult Enum
    4.8.1 Type Summary
    4.8.2 Members
  4.9 TextContentProvider Abstract Class
    4.9.1 Class Summary
    4.9.2 GetReader Method
  4.10 StreamContentProvider Abstract Class
    4.10.1 Class Summary
    4.10.2 GetStream Method
  4.11 ScriptCodeReader Sealed Class
    4.11.1 Class Summary
  4.12 ScriptIO Class
    4.12.1 Class Summary
    4.12.2 OutputStream Property
    4.12.3 InputStream Property
    4.12.4 ErrorStream Property
    4.12.5 InputReader Property
    4.12.6 OutputWriter Property
    4.12.7 ErrorWriter Property
    4.12.8 InputEncoding Property
    4.12.9 OutputEncoding Property
    4.12.10 ErrorEncoding Property
    4.12.11 SetOutput Method
    4.12.12 SetErrorOutput Method
    4.12.13 SetInput Method
    4.12.14 RedirectToConsole Method
  4.13 ScriptRuntimeSetup Class
    4.13.1 Class Summary
    4.13.2 Constructor
    4.13.3 ReadConfiguration Methods
      4.13.3.1 Configuration Structure
      4.13.3.2 Default DLR Configuration
    4.13.4 LanguageSetups Property
    4.13.5 HostType Property
    4.13.6 HostArguments Property
    4.13.7 Options Property
    4.13.8 DebugMode Property
    4.13.9 PrivateBinding Property
  4.14 LanguageSetup Class
    4.14.1 Class Summary
    4.14.2 Constructors
    4.14.3 TypeName Property
    4.14.4 DisplayName Property
    4.14.5 Names Property
    4.14.6 FileExtensions Property
    4.14.7 InterpretedMode Property
    4.14.8 ExceptionDetail Property
    4.14.9 PerfStats Property
    4.14.10 Options Property
    4.14.11 GetOption Method
  4.15 ScriptHost Class
    4.15.1 Class Summary
    4.15.2 Runtime Property
    4.15.3 PlatformAdaptationLayer Property
    4.15.4 RuntimeAttached Method
    4.15.5 EngineCreated Method
  4.16 ScriptRuntimeConfig Class
    4.16.1 Class Summary
  4.17 LanguageConfig Class
    4.17.1 Class Summary
  4.18 PlatformAdaptationLayer Class
    4.18.1 Class Summary
  4.19 SyntaxErrorException Class
  4.20 ScriptExecutionException Class
  4.21 ErrorListener Class
    4.21.1 Class Summary
  4.22 Severity Enum
    4.22.1 Type Summary
  4.23 SourceLocation Struct
  4.24 SourceSpan Struct
  4.25 ExceptionOperations Class
    4.25.1 Class Summary
  4.26 DocumentOperations Class
    4.26.1 Class Summary
    4.26.2 GetMembers Method
    4.26.3 GetOverloads
  4.27 MemberDoc Class
    4.27.1 Class Summary
    4.27.2 Name Property
    4.27.3 Kind Property
  4.28 MemberKind Enum
    4.28.1 Type Summary
    4.28.2 Members
  4.29 OverloadDoc Class
    4.29.1 Class Summary
    4.29.2 Name Property
    4.29.3 Documenation Property
    4.29.4 Parameters Property
    4.29.5 ReturnParameter
  4.30 ParameterDoc Class
    4.30.1 Class Summary
    4.30.2 Name Property
    4.30.3 TypeName Property
    4.30.4 Documentation Property
  4.31 ParameterFlags Enum
    4.31.1 Type Summary
    4.31.2 Members
  4.32 POST CLR 4.0 -- TokenCategorizer Abstract Class
    4.32.1 Class Summary
  4.33 POST CLR 4.0 -- TokenCategory Enum
  4.34 POST CLR 4.0 -- TokenInfo Struct
  4.35 POST CLR 4.0 -- TokenTriggers Enum
  4.36 CUT -- ConsoleHost Abstract Class ???
  4.37 CUT -- ConsoleHostOptions Class
  4.38 CUT -- ConsoleHostOptionsParser Class
5 Current Issues


Other documents:

Dynamic Language Runtime
Expression Trees v2 Spec
Getting Started with the DLR as a Library Author
Sites, Binders, and Dynamic Object Interop Spec
SymPL Implementation on the Dynamic Language Runtime

Clone this wiki locally