Browse Source

Added temporary fix for null arrays crashing on gcc6.

Mark Sibly 9 years ago
parent
commit
78957c6921
2 changed files with 18 additions and 2 deletions
  1. 2 0
      modules/monkey/native/bbarray.cpp
  2. 16 2
      modules/monkey/native/bbarray.h

+ 2 - 0
modules/monkey/native/bbarray.cpp

@@ -1,2 +1,4 @@
 
 
 #include "bbarray.h"
 #include "bbarray.h"
+
+void *bb_array_null;

+ 16 - 2
modules/monkey/native/bbarray.h

@@ -6,6 +6,8 @@
 #include "bbdebug.h"
 #include "bbdebug.h"
 #include "bbobject.h"
 #include "bbobject.h"
 
 
+extern void *bb_array_null;
+
 template<class T,int D> class bbArray : public bbGCNode{
 template<class T,int D> class bbArray : public bbGCNode{
 
 
 	int _sizes[D];
 	int _sizes[D];
@@ -81,13 +83,25 @@ template<class T,int D> class bbArray : public bbGCNode{
 	}
 	}
 	
 	
 	int length()const{
 	int length()const{
-		return this ? _sizes[D-1] : 0;
+//		return this ? _sizes[D-1] : 0;
+		return this!=bb_array_null ? _sizes[D-1] : 0;
 	}
 	}
 	
 	
 	int size( int q )const{
 	int size( int q )const{
 		bbDebugAssert( q<D,"Array dimension out of range" );
 		bbDebugAssert( q<D,"Array dimension out of range" );
 		
 		
-		return this ? (q ? _sizes[q]/_sizes[q-1] : _sizes[0]) : 0;
+//		return this ? (q ? _sizes[q]/_sizes[q-1] : _sizes[0]) : 0;
+		return this!=bb_array_null ? (q ? _sizes[q]/_sizes[q-1] : _sizes[0]) : 0;
+	}
+	
+	static int length( bbArray *array ){
+		return array ? array->_sizes[D-1] : 0;
+	}
+	
+	static int size( bbArray *array,int q ){
+		bbDebugAssert( q<D,"Array dimension out of range" );
+		
+		return array ? (q ? array->_sizes[q]/array->_sizes[q-1] : array->_sizes[0]) : 0;
 	}
 	}
 	
 	
 	bbArray<T,1> *slice( int from )const{
 	bbArray<T,1> *slice( int from )const{