|
@@ -1558,10 +1558,15 @@ Type TCastExpr Extends TExpr
|
|
Return expr
|
|
Return expr
|
|
End If
|
|
End If
|
|
|
|
|
|
- If TIntegralType(ty) And TEnumType(src) And flags & CAST_EXPLICIT Then
|
|
|
|
|
|
+ If TIntegralType(ty) And TEnumType(src) And (flags & CAST_EXPLICIT Or flags & 2) Then
|
|
exprType = ty
|
|
exprType = ty
|
|
Return Self
|
|
Return Self
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If TIntegralType(src) And TEnumType(ty) And flags & 2 Then
|
|
|
|
+ exprType = src
|
|
|
|
+ Return Self
|
|
|
|
+ End If
|
|
|
|
|
|
If Not exprType
|
|
If Not exprType
|
|
Err "Unable to convert from "+src.ToString()+" to "+ty.ToString()+"."
|
|
Err "Unable to convert from "+src.ToString()+" to "+ty.ToString()+"."
|
|
@@ -1806,6 +1811,7 @@ Type TBinaryMathExpr Extends TBinaryExpr
|
|
End Try
|
|
End Try
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ Local bitEnumOp:Int
|
|
Select op
|
|
Select op
|
|
Case "&","~~","|","shl","shr","sar"
|
|
Case "&","~~","|","shl","shr","sar"
|
|
If TFloat128Type(lhs.exprType) Then
|
|
If TFloat128Type(lhs.exprType) Then
|
|
@@ -1830,6 +1836,12 @@ Type TBinaryMathExpr Extends TBinaryExpr
|
|
exprType=New TWParamType
|
|
exprType=New TWParamType
|
|
Else If TLParamType(lhs.exprType) Then
|
|
Else If TLParamType(lhs.exprType) Then
|
|
exprType=New TLParamType
|
|
exprType=New TLParamType
|
|
|
|
+ Else If TEnumType(lhs.exprType) And TEnumType(lhs.exprType).decl.isFlags Then
|
|
|
|
+ exprType = lhs.exprType.Copy()
|
|
|
|
+ bitEnumOp = 2
|
|
|
|
+ Else If TEnumType(rhs.exprType) And TEnumType(rhs.exprType).decl.isFlags Then
|
|
|
|
+ exprType = rhs.exprType.Copy()
|
|
|
|
+ bitEnumOp = 2
|
|
Else
|
|
Else
|
|
exprType=New TIntType
|
|
exprType=New TIntType
|
|
End If
|
|
End If
|
|
@@ -1855,13 +1867,13 @@ Type TBinaryMathExpr Extends TBinaryExpr
|
|
If (op = "+" Or op = "-") And IsPointerType(exprType, 0, TType.T_POINTER) And TNumericType(lhs.exprType) Then
|
|
If (op = "+" Or op = "-") And IsPointerType(exprType, 0, TType.T_POINTER) And TNumericType(lhs.exprType) Then
|
|
' with pointer addition we don't cast the numeric to a pointer
|
|
' with pointer addition we don't cast the numeric to a pointer
|
|
Else
|
|
Else
|
|
- lhs=lhs.Cast( exprType )
|
|
|
|
|
|
+ lhs=lhs.Cast( exprType, bitEnumOp )
|
|
End If
|
|
End If
|
|
|
|
|
|
If (op = "+" Or op = "-") And IsPointerType(exprType, 0, TType.T_POINTER) And TNumericType(rhs.exprType) Then
|
|
If (op = "+" Or op = "-") And IsPointerType(exprType, 0, TType.T_POINTER) And TNumericType(rhs.exprType) Then
|
|
' with pointer addition we don't cast the numeric to a pointer
|
|
' with pointer addition we don't cast the numeric to a pointer
|
|
Else
|
|
Else
|
|
- rhs=rhs.Cast( exprType )
|
|
|
|
|
|
+ rhs=rhs.Cast( exprType, bitEnumOp )
|
|
End If
|
|
End If
|
|
|
|
|
|
If IsPointerType( lhs.exprType, 0, TType.T_POINTER ) And IsPointerType( rhs.exprType, 0, TType.T_POINTER ) And op = "-" Then
|
|
If IsPointerType( lhs.exprType, 0, TType.T_POINTER ) And IsPointerType( rhs.exprType, 0, TType.T_POINTER ) And op = "-" Then
|
|
@@ -1876,7 +1888,7 @@ Type TBinaryMathExpr Extends TBinaryExpr
|
|
Method Eval$()
|
|
Method Eval$()
|
|
Local lhs$=Self.lhs.Eval()
|
|
Local lhs$=Self.lhs.Eval()
|
|
Local rhs$=Self.rhs.Eval()
|
|
Local rhs$=Self.rhs.Eval()
|
|
- If TIntType( exprType )
|
|
|
|
|
|
+ If TIntType( exprType ) Or TByteType( exprType ) Or TShortType( exprType )
|
|
Local x:Int=Int(lhs),y:Int=Int(rhs)
|
|
Local x:Int=Int(lhs),y:Int=Int(rhs)
|
|
Select op
|
|
Select op
|
|
Case "^" Return x^y
|
|
Case "^" Return x^y
|
|
@@ -1951,6 +1963,18 @@ Type TBinaryMathExpr Extends TBinaryExpr
|
|
_appInstance.removeStringConst(rhs)
|
|
_appInstance.removeStringConst(rhs)
|
|
Return lhs+rhs
|
|
Return lhs+rhs
|
|
End Select
|
|
End Select
|
|
|
|
+ Else If TEnumType( exprType )
|
|
|
|
+ Local x:Long=Long(lhs),y:Long=Long(rhs)
|
|
|
|
+ Select op
|
|
|
|
+ Case "shl" Return x Shl y
|
|
|
|
+ Case "shr" Return x Shr y
|
|
|
|
+ Case "sar" Return x Sar y
|
|
|
|
+ Case "+" Return x + y
|
|
|
|
+ Case "-" Return x - y
|
|
|
|
+ Case "&" Return x & y
|
|
|
|
+ Case "~~" Return x ~ y
|
|
|
|
+ Case "|" Return x | y
|
|
|
|
+ End Select
|
|
EndIf
|
|
EndIf
|
|
InternalErr "TBinaryMathExpr.Eval"
|
|
InternalErr "TBinaryMathExpr.Eval"
|
|
End Method
|
|
End Method
|