Browse Source

Some tweaks for var ptrs.

woollybah 11 years ago
parent
commit
62e4b6b698
2 changed files with 21 additions and 4 deletions
  1. 11 2
      expr.bmx
  2. 10 2
      type.bmx

+ 11 - 2
expr.bmx

@@ -75,7 +75,6 @@ Type TExpr
 
 	'semant and cast
 	Method SemantAndCast:TExpr( ty:TType,castFlags:Int=0 )
-'DebugStop
 		Local expr:TExpr=Semant()
 		If expr.exprType.EqualsType( ty ) Return expr
 		Return New TCastExpr.Create( ty,expr,castFlags ).Semant()
@@ -870,7 +869,7 @@ Type TCastExpr Extends TExpr
 		
 		If TArrayType(ty) And TObjectType(src) And TObjectType(src).classDecl.ident = "Array" Then
 			exprType = ty
-			Return Self
+			Return expr
 		End If
 
 		If Not exprType
@@ -922,6 +921,12 @@ Type TCastExpr Extends TExpr
 		Return _trans.TransCastExpr( Self )
 	End Method
 
+	Method ToString$()
+		Local t$="TCastExpr(" + ty.ToString()
+		If expr t:+","+expr.ToString()
+		Return t+")"
+	End Method
+
 End Type
 
 'op = '+', '-', '~'
@@ -992,6 +997,10 @@ Type TBinaryExpr Extends TExpr
 		Return _trans.TransBinaryExpr( Self )
 	End Method
 
+	Method ToString$()
+		Return "(" + lhs.ToString() + " " + op + " " + rhs.ToString() + ")"
+	End Method
+
 End Type
 
 ' * / + / & ~ | ^ shl shr

+ 10 - 2
type.bmx

@@ -138,6 +138,14 @@ Type TType
 		If TFloatPtrType(ty) Return floatPointerPtrType
 		If TDoublePtrType(ty) Return doublePointerPtrType
 		If TLongPtrType(ty) Return longPointerPtrType
+
+		' var pointer to pointer
+		If TByteVarPtrType(ty) Return bytePointerType
+		If TIntVarPtrType(ty) Return intPointerType
+		If TShortVarPtrType(ty) Return shortPointerType
+		If TFloatVarPtrType(ty) Return floatPointerType
+		If TDoubleVarPtrType(ty) Return doublePointerType
+		If TLongVarPtrType(ty) Return longPointerType
 		
 		Return Null
 	End Function
@@ -1019,7 +1027,7 @@ End Type
 Type TFloatVarPtrType Extends TVarPtrType
 
 	Method EqualsType:Int( ty:TType )
-		Return TFloatVarPtrType( ty )<>Null Or TVarPtrType( ty )<>Null
+		Return TFloatVarPtrType( ty )<>Null
 	End Method
 	
 	Method ExtendsType:Int( ty:TType )
@@ -1028,7 +1036,7 @@ Type TFloatVarPtrType Extends TVarPtrType
 			Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True )
 			Return ctor And ctor.IsCtor()
 		EndIf
-		Return TPointerType( ty )<>Null Or TStringType( ty )<>Null Or TFloatType( ty )<>Null
+		Return TPointerType( ty )<>Null Or TStringType( ty )<>Null Or TFloatType( ty )<>Null Or TVarPtrType( ty )<>Null
 	End Method
 	
 	Method ToString$()