@@ -213,6 +213,110 @@ public object Return()
213213
214214 return ret ;
215215 }
216+ void FillArray ( object array , byte [ ] bytes )
217+ {
218+ if ( array is byte [ ] )
219+ {
220+ byte [ ] arr = array as byte [ ] ;
221+ for ( int i = 0 ; i < bytes . Length ; i ++ )
222+ {
223+ arr [ i ] = bytes [ i ] ;
224+ }
225+ }
226+ else if ( array is sbyte [ ] )
227+ {
228+ sbyte [ ] arr = array as sbyte [ ] ;
229+ for ( int i = 0 ; i < bytes . Length ; i ++ )
230+ {
231+ arr [ i ] = ( sbyte ) bytes [ i ] ;
232+ }
233+ }
234+ else if ( array is Int16 [ ] )
235+ {
236+ int step = 2 ;
237+ Int16 [ ] arr = array as Int16 [ ] ;
238+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
239+ {
240+ arr [ i ] = BitConverter . ToInt16 ( bytes , i * step ) ;
241+ }
242+ }
243+ else if ( array is UInt16 [ ] )
244+ {
245+ int step = 2 ;
246+ UInt16 [ ] arr = array as UInt16 [ ] ;
247+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
248+ {
249+ arr [ i ] = BitConverter . ToUInt16 ( bytes , i * step ) ;
250+ }
251+ }
252+ else if ( array is char [ ] )
253+ {
254+ int step = 2 ;
255+ char [ ] arr = array as char [ ] ;
256+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
257+ {
258+ arr [ i ] = ( char ) BitConverter . ToUInt16 ( bytes , i * step ) ;
259+ }
260+ }
261+ else if ( array is int [ ] )
262+ {
263+ int step = 4 ;
264+ int [ ] arr = array as int [ ] ;
265+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
266+ {
267+ arr [ i ] = BitConverter . ToInt32 ( bytes , i * step ) ;
268+ }
269+ }
270+ else if ( array is uint [ ] )
271+ {
272+ int step = 4 ;
273+ uint [ ] arr = array as uint [ ] ;
274+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
275+ {
276+ arr [ i ] = BitConverter . ToUInt32 ( bytes , i * step ) ;
277+ }
278+ }
279+ else if ( array is Int64 [ ] )
280+ {
281+ int step = 8 ;
282+ Int64 [ ] arr = array as Int64 [ ] ;
283+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
284+ {
285+ arr [ i ] = BitConverter . ToInt64 ( bytes , i * step ) ;
286+ }
287+ }
288+ else if ( array is UInt64 [ ] )
289+ {
290+ int step = 8 ;
291+ UInt64 [ ] arr = array as UInt64 [ ] ;
292+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
293+ {
294+ arr [ i ] = BitConverter . ToUInt64 ( bytes , i * step ) ;
295+ }
296+ }
297+ else if ( array is float [ ] )
298+ {
299+ int step = 4 ;
300+ float [ ] arr = array as float [ ] ;
301+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
302+ {
303+ arr [ i ] = BitConverter . ToSingle ( bytes , i * step ) ;
304+ }
305+ }
306+ else if ( array is double [ ] )
307+ {
308+ int step = 8 ;
309+ double [ ] arr = array as double [ ] ;
310+ for ( int i = 0 ; i < bytes . Length / step ; i ++ )
311+ {
312+ arr [ i ] = BitConverter . ToDouble ( bytes , i * step ) ;
313+ }
314+ }
315+ else
316+ {
317+ throw new NotImplementedException ( "array=" + array . GetType ( ) ) ;
318+ }
319+ }
216320 //流程控制
217321 public void Call ( ThreadContext context , IMethod _clrmethod , bool bVisual )
218322 {
@@ -287,6 +391,7 @@ public void Call(ThreadContext context, IMethod _clrmethod, bool bVisual)
287391 }
288392 if ( _clrmethod . DeclaringType . FullName . Contains ( "System.Runtime.CompilerServices.RuntimeHelpers" ) && _clrmethod . Name . Contains ( "InitializeArray" ) )
289393 {
394+ FillArray ( _pp [ 0 ] , _pp [ 1 ] as byte [ ] ) ;
290395 _codepos ++ ;
291396 return ;
292397 }
0 commit comments