Jelajahi Sumber

Fixed static array issues.

Brucey 5 tahun lalu
induk
melakukan
93a5dbad2a
2 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 6 2
      ctranslator.bmx
  2. 2 0
      expr.bmx

+ 6 - 2
ctranslator.bmx

@@ -774,7 +774,7 @@ t:+"NULLNULLNULL"
 					If Not TConstExpr(init) Then
 						Return decl.munged + initTrans
 					End If
-				Else
+				Else If Not TArrayType(ty) Or Not TArrayType(ty).isStatic Then 
 					Return decl.munged + initTrans
 				End If
 			Else If TObjectType( ty ) And TObjectType( ty ).classDecl.IsStruct() Then
@@ -847,7 +847,11 @@ t:+"NULLNULLNULL"
 				If TLocalDecl(decl) And TLocalDecl(decl).volatile Then
 					Return TransType( decl.ty, decl.munged )+" volatile "+decl.munged + "=" + TransValue(decl.ty, "")
 				Else
-					Return TransType( decl.ty, decl.munged )+" "+decl.munged + "=" + TransValue(decl.ty, "")
+					If TArrayType(decl.ty) And TArrayType(decl.ty).isStatic Then
+						Return TransType( decl.ty, decl.munged )+" "+decl.munged + "[" + TArrayType(decl.ty).length + "]"
+					Else
+						Return TransType( decl.ty, decl.munged )+" "+decl.munged + "=" + TransValue(decl.ty, "")
+					End If
 				End If
 			End If
 		End If

+ 2 - 0
expr.bmx

@@ -2100,6 +2100,8 @@ Type TBinaryCompareExpr Extends TBinaryExpr
 				End If
 				' otherwise, no overload, continue...
 			End Try
+		Else If (TArrayType(lhs.exprType) And TArrayType(lhs.exprType).isStatic) Or (TArrayType(rhs.exprType) And TArrayType(rhs.exprType).isStatic) Then
+			Err "Static arrays cannot be compared"
 		End If