Browse Source

Default function pointers to a NullFunctionError.

woollybah 11 years ago
parent
commit
027054140a
2 changed files with 14 additions and 5 deletions
  1. 13 4
      ctranslator.bmx
  2. 1 1
      options.bmx

+ 13 - 4
ctranslator.bmx

@@ -244,7 +244,7 @@ Type TCTranslator Extends TTranslator
 					Return "&bbNullObject"
 					Return "&bbNullObject"
 				End If
 				End If
 			End If
 			End If
-			If TFunctionPtrType( ty) Return "0" ' todo ??
+			If TFunctionPtrType( ty) Return "&brl_blitz_NullFunctionError" ' todo ??
 			'If TByteType( ty ) Return "0"
 			'If TByteType( ty ) Return "0"
 		EndIf
 		EndIf
 		InternalErr
 		InternalErr
@@ -473,7 +473,11 @@ t:+"NULLNULLNULL"
 					glob :+ init.Trans()
 					glob :+ init.Trans()
 				End If
 				End If
 			Else
 			Else
-				glob :+ "0"
+				If TFunctionPtrType(ty) Then
+					glob :+ "&brl_blitz_NullFunctionError"
+				Else
+					glob :+ "0"
+				End If
 			End If
 			End If
 		End If
 		End If
 
 
@@ -1244,7 +1248,7 @@ EndRem
 			'	If TNumericType( src ) Return Bra("(BBINT**)"+t)
 			'	If TNumericType( src ) Return Bra("(BBINT**)"+t)
 			End If
 			End If
 		Else If TBoolType( dst )
 		Else If TBoolType( dst )
-			If TFunctionPtrType(src) Return Bra( t )
+			If TFunctionPtrType(src) Return Bra( t+"!=&brl_blitz_NullFunctionError" )
 			If IsPointerType( src, 0, TType.T_POINTER ) Return Bra( t )
 			If IsPointerType( src, 0, TType.T_POINTER ) Return Bra( t )
 			If TBoolType( src ) Return t
 			If TBoolType( src ) Return t
 			If TByteType( src ) Return Bra( t+"!=0" )
 			If TByteType( src ) Return Bra( t+"!=0" )
@@ -2862,8 +2866,10 @@ End Rem
 				' initial value
 				' initial value
 				fld :+ "= " + decl.init.Trans() + ";";
 				fld :+ "= " + decl.init.Trans() + ";";
 			Else
 			Else
-				If TNumericType(decl.ty) Or TObjectType(decl.ty) Or TFunctionPtrType(decl.ty) Or IsPointerType(decl.ty, 0, TType.T_POINTER) Then
+				If TNumericType(decl.ty) Or TObjectType(decl.ty) Or IsPointerType(decl.ty, 0, TType.T_POINTER) Then
 					fld :+ "= 0;"
 					fld :+ "= 0;"
+				Else If TFunctionPtrType(decl.ty) Then
+					fld :+ "= &brl_blitz_NullFunctionError;"
 				Else If TStringType(decl.ty) Then
 				Else If TStringType(decl.ty) Then
 					fld :+ "= &bbEmptyString;"
 					fld :+ "= &bbEmptyString;"
 				Else If TArrayType(decl.ty) Then
 				Else If TArrayType(decl.ty) Then
@@ -3091,6 +3097,9 @@ End Rem
 				If TInvokeExpr(TCastExpr(expr).expr) Then
 				If TInvokeExpr(TCastExpr(expr).expr) Then
 					Return Enquote(TInvokeExpr(TCastExpr(expr).expr).decl.munged)
 					Return Enquote(TInvokeExpr(TCastExpr(expr).expr).decl.munged)
 				End If
 				End If
+				If TNullExpr(TCastExpr(expr).expr) Then
+					Return Enquote("brl_blitz_NullFunctionError")
+				End If
 			End If
 			End If
 
 
 			InternalErr
 			InternalErr

+ 1 - 1
options.bmx

@@ -25,7 +25,7 @@ SuperStrict
 
 
 Import "base.configmap.bmx"
 Import "base.configmap.bmx"
 
 
-Const version:String = "0.13"
+Const version:String = "0.14"
 
 
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_MODULE:Int = 1
 Const BUILDTYPE_MODULE:Int = 1