Sfoglia il codice sorgente

Static array improvements.

Brucey 5 anni fa
parent
commit
2a48044f8e
2 ha cambiato i file con 28 aggiunte e 1 eliminazioni
  1. 1 1
      expr.bmx
  2. 27 0
      iparser.bmx

+ 1 - 1
expr.bmx

@@ -1327,7 +1327,7 @@ Type TCastExpr Extends TExpr
 
 			EndIf
 			
-			If TNullType(src) And Not TVoidType(ty) Then
+			If TNullType(src) And Not TVoidType(ty) And Not (TArrayType(ty) And TArrayType(ty).IsStatic) Then
 				exprType = ty
 			End If
 			

+ 27 - 0
iparser.bmx

@@ -488,6 +488,10 @@ Type TIParser
 						If CParse( "&" ) Then
 						End If
 
+						If IstStaticArrayDef() Then
+							attrs :| DECL_STATIC
+						End If
+
 						While IsArrayDef()
 							ty = ParseArrayType(ty)
 				
@@ -1301,6 +1305,10 @@ Type TIParser
 					If CParse( "&" ) Then
 					End If
 
+					If IstStaticArrayDef() Then
+						attrs :| DECL_STATIC
+					End If
+
 					While IsArrayDef(attrs & DECL_STATIC > 0)
 						ty = ParseArrayType(ty, attrs & DECL_STATIC > 0)
 			
@@ -1457,6 +1465,21 @@ End Rem
 		Return ty
 	End Method
 
+	Method IstStaticArrayDef:Int()
+		Local toker:TToker=New TToker.Copy(_toker)
+		If Not CParseToker(toker, "[") Then
+			Return False
+		End If
+		If toker.TokeType() <> TOKE_INTLIT Then
+			Return False
+		End If
+		NextTokeToker(toker)
+		If Not CParseToker(toker, "]") Then
+			Return False
+		End If
+		Return True
+	End Method
+
 	Method IsArrayDef:Int(isStatic:Int = False)
 		Local isDef:Int = True
 		Local toker:TToker=New TToker.Copy(_toker)
@@ -1699,6 +1722,10 @@ End Rem
 		If CParse( "&" ) Then
 		End If
 
+		If IstStaticArrayDef() Then
+			attrs :| DECL_STATIC
+		End If
+		
 		While IsArrayDef(attrs & DECL_STATIC > 0)
 
 			ty = ParseArrayType(ty, attrs & DECL_STATIC > 0)