@@ -21,24 +21,6 @@ namespace IronPython.Runtime.Operations {
2121 public static class ArrayOps {
2222 #region Python APIs
2323
24- [ SpecialName ]
25- public static Array Add ( Array data1 , Array data2 ) {
26- if ( data1 == null ) throw PythonOps . TypeError ( "expected array for 1st argument, got None" ) ;
27- if ( data2 == null ) throw PythonOps . TypeError ( "expected array for 2nd argument, got None" ) ;
28-
29- if ( data1 . Rank > 1 || data2 . Rank > 1 ) throw new NotImplementedException ( "can't add multidimensional arrays" ) ;
30- if ( data1 . GetLowerBound ( 0 ) != 0 || data2 . GetLowerBound ( 0 ) != 0 ) throw new NotImplementedException ( "can't add non-0-based arrays" ) ;
31-
32- Type type1 = data1 . GetType ( ) ;
33- Type type2 = data2 . GetType ( ) ;
34- Type type = ( type1 == type2 ) ? type1 . GetElementType ( ) ! : typeof ( object ) ;
35-
36- Array ret = Array . CreateInstance ( type , data1 . Length + data2 . Length ) ;
37- Array . Copy ( data1 , 0 , ret , 0 , data1 . Length ) ;
38- Array . Copy ( data2 , 0 , ret , data1 . Length , data2 . Length ) ;
39- return ret ;
40- }
41-
4224 [ StaticExtensionMethod ]
4325 public static object __new__ ( CodeContext context , PythonType pythonType , int length ) {
4426 Type type = pythonType . UnderlyingSystemType . GetElementType ( ) ! ;
@@ -144,6 +126,24 @@ public static object __ne__(CodeContext context, Array self, [NotNone] Array oth
144126 [ return : MaybeNotImplemented ]
145127 public static object __ne__ ( CodeContext context , object self , object ? other ) => NotImplementedType . Value ;
146128
129+ [ SpecialName ]
130+ public static Array Add ( Array data1 , Array data2 ) {
131+ if ( data1 == null ) throw PythonOps . TypeError ( "expected array for 1st argument, got None" ) ;
132+ if ( data2 == null ) throw PythonOps . TypeError ( "expected array for 2nd argument, got None" ) ;
133+
134+ if ( data1 . Rank > 1 || data2 . Rank > 1 ) throw new NotImplementedException ( "can't add multidimensional arrays" ) ;
135+ if ( data1 . GetLowerBound ( 0 ) != 0 || data2 . GetLowerBound ( 0 ) != 0 ) throw new NotImplementedException ( "can't add non-0-based arrays" ) ;
136+
137+ Type type1 = data1 . GetType ( ) ;
138+ Type type2 = data2 . GetType ( ) ;
139+ Type type = ( type1 == type2 ) ? type1 . GetElementType ( ) ! : typeof ( object ) ;
140+
141+ Array ret = Array . CreateInstance ( type , data1 . Length + data2 . Length ) ;
142+ Array . Copy ( data1 , 0 , ret , 0 , data1 . Length ) ;
143+ Array . Copy ( data2 , 0 , ret , data1 . Length , data2 . Length ) ;
144+ return ret ;
145+ }
146+
147147 /// <summary>
148148 /// Multiply two object[] arrays - slow version, we need to get the type, etc...
149149 /// </summary>
0 commit comments