@@ -21,23 +21,6 @@ namespace IronPython.Runtime.Operations {
21
21
public static class ArrayOps {
22
22
#region Python APIs
23
23
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
-
31
- Type type1 = data1 . GetType ( ) ;
32
- Type type2 = data2 . GetType ( ) ;
33
- Type type = ( type1 == type2 ) ? type1 . GetElementType ( ) ! : typeof ( object ) ;
34
-
35
- Array ret = Array . CreateInstance ( type , data1 . Length + data2 . Length ) ;
36
- Array . Copy ( data1 , 0 , ret , 0 , data1 . Length ) ;
37
- Array . Copy ( data2 , 0 , ret , data1 . Length , data2 . Length ) ;
38
- return ret ;
39
- }
40
-
41
24
[ StaticExtensionMethod ]
42
25
public static object __new__ ( CodeContext context , PythonType pythonType , int length ) {
43
26
Type type = pythonType . UnderlyingSystemType . GetElementType ( ) ! ;
@@ -143,12 +126,31 @@ public static object __ne__(CodeContext context, Array self, [NotNone] Array oth
143
126
[ return : MaybeNotImplemented ]
144
127
public static object __ne__ ( CodeContext context , object self , object ? other ) => NotImplementedType . Value ;
145
128
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
+
146
147
/// <summary>
147
148
/// Multiply two object[] arrays - slow version, we need to get the type, etc...
148
149
/// </summary>
149
150
[ SpecialName ]
150
151
public static Array Multiply ( Array data , int count ) {
151
152
if ( data . Rank > 1 ) throw new NotImplementedException ( "can't multiply multidimensional arrays" ) ;
153
+ if ( data . GetLowerBound ( 0 ) != 0 ) throw new NotImplementedException ( "can't multiply non-0-based arrays" ) ;
152
154
153
155
Type elemType = data . GetType ( ) . GetElementType ( ) ! ;
154
156
if ( count <= 0 ) return Array . CreateInstance ( elemType , 0 ) ;
0 commit comments