소스 검색

Added missing casts for Long.
Don't downcast when doing bit math.

woollybah 11 년 전
부모
커밋
026ebe4920
2개의 변경된 파일35개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 0
      ctranslator.bmx
  2. 32 2
      expr.bmx

+ 3 - 0
ctranslator.bmx

@@ -747,6 +747,7 @@ Type TCTranslator Extends TTranslator
 			If TIntType( src ) Return t
 			If TFloatType( src ) Return Bra("(BBINT)"+t)
 			If TDoubleType( src ) Return Bra("(BBINT)"+t)
+			If TLongType( src ) Return Bra("(BBINT)"+t)
 			If TStringType( src ) Return "bbStringToInt" + Bra(t)
 			If TPointerType( src ) Return Bra("(BBINT)"+t)
 		 Else If TLongType( dst )
@@ -764,6 +765,7 @@ Type TCTranslator Extends TTranslator
 			If TShortType( src ) Return Bra("(BBFLOAT)"+t)
 			If TFloatType( src ) Return t
 			If TDoubleType( src ) Return Bra("(BBFLOAT)"+t)
+			If TLongType( src ) Return Bra("(BBFLOAT)"+t)
 			If TStringType( src ) Return "bbStringToFloat" + Bra(t)
 			If TPointerType( src ) Return Bra("(BBFLOAT)"+t)
 		Else If TDoubleType( dst )
@@ -772,6 +774,7 @@ Type TCTranslator Extends TTranslator
 			If TShortType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TDoubleType( src ) Return t
 			If TFloatType( src ) Return Bra("(BBDOUBLE)"+t)
+			If TLongType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TStringType( src ) Return "bbStringToDouble" + Bra(t)
 			If TPointerType( src ) Return Bra("(BBDOUBLE)"+t)
 		Else If TStringType( dst )

+ 32 - 2
expr.bmx

@@ -966,7 +966,15 @@ Type TBinaryMathExpr Extends TBinaryExpr
 
 		Select op
 		Case "&","~~","|","mod","shl","shr"
-			exprType=TType.intType
+			If TDoubleType(lhs.exprType) Then
+				exprType=TType.longType
+			Else If TFloatType(lhs.exprType) Then
+				exprType=TType.intType
+			Else If TNumericType(lhs.exprType) Then
+				exprType=lhs.exprType
+			Else
+				exprType=TType.intType
+			End If
 		Default
 			exprType=BalanceTypes( lhs.exprType,rhs.exprType )
 			If TStringType( exprType )
@@ -1003,8 +1011,30 @@ Type TBinaryMathExpr Extends TBinaryExpr
 			Case "~~" Return x ~ y
 			Case "|" Return x | y
 			End Select
+		Else If TLongType( exprType )
+			Local x:Long=Long(lhs),y:Long=Long(rhs)
+			Select op
+			Case "*" Return x*y
+			Case "/" Return x/y
+			Case "mod" Return x Mod y
+			Case "shl" Return x Shl y
+			Case "shr" Return x Shr y
+			Case "+" Return x + y
+			Case "-" Return x - y
+			Case "&" Return x & y
+			Case "~~" Return x ~ y
+			Case "|" Return x | y
+			End Select
 		Else If TFloatType( exprType )
-			Local x#=Float(lhs),y#=Float(rhs)
+			Local x:Float=Float(lhs),y:Float=Float(rhs)
+			Select op
+			Case "*" Return x * y
+			Case "/" Return x / y
+			Case "+" Return x + y
+			Case "-" Return x - y
+			End Select
+		Else If TDoubleType( exprType )
+			Local x:Double=Double(lhs),y:Double=Double(rhs)
 			Select op
 			Case "*" Return x * y
 			Case "/" Return x / y