@@ -5,19 +5,20 @@ This Source Code Form is subject to the terms of the
55at http://mozilla.org/MPL/2.0/.
66----------------------------------------------------------*/
77
8- using ScriptEngine . Machine ;
9- using ScriptEngine . Machine . Contexts ;
10- using System ;
11- using System . Collections . Generic ;
12- using System . IO ;
13- using System . Linq ;
148using OneScript . Commons ;
159using OneScript . Compilation ;
1610using OneScript . Contexts ;
1711using OneScript . Exceptions ;
1812using OneScript . Execution ;
13+ using OneScript . Sources ;
1914using OneScript . Values ;
2015using ScriptEngine . Libraries ;
16+ using ScriptEngine . Machine ;
17+ using ScriptEngine . Machine . Contexts ;
18+ using System ;
19+ using System . Collections . Generic ;
20+ using System . IO ;
21+ using System . Linq ;
2122
2223namespace ScriptEngine . HostedScript
2324{
@@ -28,7 +29,7 @@ public class LibraryLoader : AutoScriptDrivenObject<LibraryLoader>
2829 private readonly ScriptingEngine _engine ;
2930
3031 private readonly bool _customized ;
31- private readonly Stack < LibraryLoadingContext > _librariesInProgress = new Stack < LibraryLoadingContext > ( ) ;
32+ private readonly Stack < LibraryLoadingContext > _librariesInProgress = [ ] ;
3233
3334 private struct DelayLoadedScriptData
3435 {
@@ -70,17 +71,30 @@ private LibraryLoader(IRuntimeEnvironment env,
7071 _libManager = libManager ;
7172 _engine = engine ;
7273 _customized = false ;
73- }
74-
74+ }
75+
76+ private LibraryLoader ( ScriptingEngine engine ) : base ( EmptyModule . Instance , true )
77+ {
78+ _env = engine . Environment ;
79+ _libManager = engine . LibraryManager ;
80+ _engine = engine ;
81+ _customized = true ;
82+ }
83+
7584 #region Static part
76-
85+
7786 public static LibraryLoader Create ( ScriptingEngine engine , string processingScript , IBslProcess process )
7887 {
7988 var compiler = engine . GetCompilerService ( ) ;
8089 var code = engine . Loader . FromFile ( processingScript ) ;
81- var module = CompileModule ( compiler , code , typeof ( LibraryLoader ) , process ) ;
82-
83- return new LibraryLoader ( module , engine . Environment , engine . LibraryManager , engine , process ) ;
90+
91+ var loader = new LibraryLoader ( engine ) ;
92+ CompileModule ( compiler , code , loader , process ) ;
93+
94+ loader . InitOwnData ( ) ;
95+ loader . _engine . InitializeSDO ( loader , process ) ;
96+
97+ return loader ;
8498 }
8599
86100 public static LibraryLoader Create ( ScriptingEngine engine , IBslProcess process )
@@ -200,7 +214,7 @@ private bool CustomizedProcessing(string libraryPath, IBslProcess process)
200214 return DefaultProcessing ( libraryPath , process ) ;
201215 }
202216
203- CallScriptMethod ( eventIdx , new [ ] { libPathValue , defaultLoading , cancelLoading } , process ) ;
217+ CallScriptMethod ( eventIdx , [ libPathValue , defaultLoading , cancelLoading ] , process ) ;
204218
205219 if ( cancelLoading . AsBoolean ( ) ) // Отказ = Ложь
206220 return false ;
@@ -209,7 +223,6 @@ private bool CustomizedProcessing(string libraryPath, IBslProcess process)
209223 return DefaultProcessing ( libraryPath , process ) ;
210224
211225 return true ;
212-
213226 }
214227
215228 private bool DefaultProcessing ( string libraryPath , IBslProcess process )
0 commit comments