@@ -27,7 +27,7 @@ public abstract class Base
2727 protected const string ClassString = "class:" ;
2828 protected const string ComString = "intf:." ;
2929
30- internal static Base Load ( BinaryReader br )
30+ internal static Base Load ( BinaryReader br , Script script )
3131 {
3232 var fdeclLen = br . Read < uint > ( ) ;
3333 using ( var fdeclMem = new NativeMemoryArray < byte > ( fdeclLen , true ) )
@@ -39,21 +39,21 @@ internal static Base Load(BinaryReader br)
3939 if ( fdeclSpan . EqualsAsciiString ( 0 , DllString ) )
4040 {
4141 brDecl . BaseStream . Position = DllString . Length ;
42- return DLL . Load ( brDecl ) ;
42+ return DLL . Load ( brDecl , script ) ;
4343 }
4444 else if ( fdeclSpan . EqualsAsciiString ( 0 , ClassString ) )
4545 {
4646 brDecl . BaseStream . Position = ClassString . Length ;
47- return Class . Load ( brDecl ) ;
47+ return Class . Load ( brDecl , script ) ;
4848 }
4949 else if ( fdeclSpan . EqualsAsciiString ( 0 , ComString ) )
5050 {
5151 brDecl . BaseStream . Position = ComString . Length ;
52- return COM . Load ( brDecl ) ;
52+ return COM . Load ( brDecl , script ) ;
5353 }
5454 else
5555 {
56- return Internal . Load ( brDecl ) ;
56+ return Internal . Load ( brDecl , script ) ;
5757 }
5858 }
5959 }
@@ -124,14 +124,17 @@ public sealed class DLL : BaseCC
124124
125125 internal override string Name => string . Format ( "{0}!{1}" , DllName , ProcedureName ) ;
126126
127- internal static new DLL Load ( BinaryReader br )
127+ internal static new DLL Load ( BinaryReader br , Script script )
128128 {
129129 var ret = new DLL ( ) ;
130130 ret . DllName = br . ReadAsciiStringTerminated ( ) ;
131131 ret . ProcedureName = br . ReadAsciiStringTerminated ( ) ;
132132 ret . CallingConvention = ( NativeCallingConvention ) br . ReadByte ( ) ;
133- ret . DelayLoad = br . ReadByte ( ) != 0 ;
134- ret . LoadWithAlteredSearchPath = br . ReadByte ( ) != 0 ;
133+ if ( script . FileVersion >= Script . VERSION_MIN_DLL_LOAD_FLAGS )
134+ {
135+ ret . DelayLoad = br . ReadByte ( ) != 0 ;
136+ ret . LoadWithAlteredSearchPath = br . ReadByte ( ) != 0 ;
137+ }
135138
136139 ret . LoadArguments ( br ) ;
137140
@@ -164,8 +167,11 @@ internal override void SaveCore(BinaryWriter bw, Script.SaveContext ctx)
164167 bw . WriteAsciiStringTerminated ( DllName ) ;
165168 bw . WriteAsciiStringTerminated ( ProcedureName ) ;
166169 bw . Write ( CallingConvention ) ;
167- bw . Write < byte > ( ( byte ) ( DelayLoad ? 1 : 0 ) ) ;
168- bw . Write < byte > ( ( byte ) ( LoadWithAlteredSearchPath ? 1 : 0 ) ) ;
170+ if ( ctx . FileVersion >= Script . VERSION_MIN_DLL_LOAD_FLAGS )
171+ {
172+ bw . Write < byte > ( ( byte ) ( DelayLoad ? 1 : 0 ) ) ;
173+ bw . Write < byte > ( ( byte ) ( LoadWithAlteredSearchPath ? 1 : 0 ) ) ;
174+ }
169175 SaveArguments ( bw ) ;
170176 }
171177 }
@@ -181,7 +187,7 @@ public sealed class Class : BaseCC
181187
182188 private const byte TERMINATOR = ( byte ) '|' ;
183189
184- internal static new Class Load ( BinaryReader br )
190+ internal static new Class Load ( BinaryReader br , Script script )
185191 {
186192 var ret = new Class ( ) ;
187193
@@ -297,7 +303,7 @@ public sealed class COM : BaseCC
297303
298304 internal override string Name => string . Format ( "CoInterface->vtbl[{0}]" , VTableIndex ) ;
299305
300- internal static new COM Load ( BinaryReader br )
306+ internal static new COM Load ( BinaryReader br , Script script )
301307 {
302308 var ret = new COM ( ) ;
303309 ret . VTableIndex = br . Read < uint > ( ) ;
@@ -325,7 +331,7 @@ internal override void SaveCore(BinaryWriter bw, Script.SaveContext ctx)
325331
326332 public sealed class Internal : Base
327333 {
328- internal static new Internal Load ( BinaryReader br )
334+ internal static new Internal Load ( BinaryReader br , Script script )
329335 {
330336 var ret = new Internal ( ) ;
331337 ret . LoadArguments ( br ) ;
@@ -378,7 +384,7 @@ internal static ExternalFunction Load(BinaryReader br, Script script, bool expor
378384 ret . Name = br . ReadAsciiString ( namelen ) ;
379385 if ( exported )
380386 {
381- ret . Declaration = FDecl . Base . Load ( br ) ;
387+ ret . Declaration = FDecl . Base . Load ( br , script ) ;
382388 if ( ret . Declaration . HasReturnArgument ) ret . ReturnArgument = UnknownType . Instance ;
383389 if ( string . IsNullOrEmpty ( ret . Name ) ) ret . Name = ret . Declaration . Name ;
384390 }
0 commit comments