|
@@ -1,4 +1,4 @@
|
|
-' Copyright (c) 2013-2016 Bruce A Henderson
|
|
|
|
|
|
+' Copyright (c) 2013-2017 Bruce A Henderson
|
|
'
|
|
'
|
|
' Based on the public domain Monkey "trans" by Mark Sibly
|
|
' Based on the public domain Monkey "trans" by Mark Sibly
|
|
'
|
|
'
|
|
@@ -192,18 +192,24 @@ Type TType
|
|
|
|
|
|
Const T_POINTER:Int = T_PTR | T_PTRPTR | T_PTRPTRPTR
|
|
Const T_POINTER:Int = T_PTR | T_PTRPTR | T_PTRPTRPTR
|
|
|
|
|
|
- Const T_BYTE:Int = $001
|
|
|
|
- Const T_SHORT:Int = $002
|
|
|
|
- Const T_INT:Int = $004
|
|
|
|
- Const T_LONG:Int = $008
|
|
|
|
- Const T_FLOAT:Int = $010
|
|
|
|
- Const T_DOUBLE:Int = $020
|
|
|
|
- Const T_STRING:Int = $040
|
|
|
|
- Const T_ARRAY:Int = $080
|
|
|
|
- Const T_FUNCTIONPTR:Int = $100
|
|
|
|
- Const T_SIZET:Int = $200
|
|
|
|
- Const T_UINT:Int = $400
|
|
|
|
- Const T_ULONG:Int = $800
|
|
|
|
|
|
+ Const T_BYTE:Int = $001
|
|
|
|
+ Const T_SHORT:Int = $002
|
|
|
|
+ Const T_INT:Int = $004
|
|
|
|
+ Const T_LONG:Int = $008
|
|
|
|
+ Const T_FLOAT:Int = $010
|
|
|
|
+ Const T_DOUBLE:Int = $020
|
|
|
|
+ Const T_STRING:Int = $040
|
|
|
|
+ Const T_ARRAY:Int = $080
|
|
|
|
+ Const T_FUNCTIONPTR:Int = $100
|
|
|
|
+ Const T_SIZET:Int = $200
|
|
|
|
+ Const T_UINT:Int = $400
|
|
|
|
+ Const T_ULONG:Int = $800
|
|
|
|
+ Const T_FLOAT64:Int = $1000
|
|
|
|
+ Const T_INT128:Int = $2000
|
|
|
|
+ Const T_FLOAT128:Int = $4000
|
|
|
|
+ Const T_DOUBLE128:Int = $8000
|
|
|
|
+ Const T_LPARAM:Int =$10000
|
|
|
|
+ Const T_WPARAM:Int =$20000
|
|
|
|
|
|
Const T_MAX_DISTANCE:Int = $FFFF
|
|
Const T_MAX_DISTANCE:Int = $FFFF
|
|
|
|
|
|
@@ -248,12 +254,22 @@ Function NewType:TType(kind:Int = 0)
|
|
ty = New TUIntType
|
|
ty = New TUIntType
|
|
Case TType.T_LONG
|
|
Case TType.T_LONG
|
|
ty = New TLongType
|
|
ty = New TLongType
|
|
|
|
+ Case TType.T_ULONG
|
|
|
|
+ ty = New TULongType
|
|
Case TType.T_SIZET
|
|
Case TType.T_SIZET
|
|
ty = New TSizeTType
|
|
ty = New TSizeTType
|
|
|
|
+ Case TType.T_INT128
|
|
|
|
+ ty = New TInt128Type
|
|
Case TType.T_FLOAT
|
|
Case TType.T_FLOAT
|
|
ty = New TFloatType
|
|
ty = New TFloatType
|
|
Case TType.T_DOUBLE
|
|
Case TType.T_DOUBLE
|
|
ty = New TDoubleType
|
|
ty = New TDoubleType
|
|
|
|
+ Case TType.T_FLOAT64
|
|
|
|
+ ty = New TFloat64Type
|
|
|
|
+ Case TType.T_FLOAT128
|
|
|
|
+ ty = New TFloat128Type
|
|
|
|
+ Case TType.T_DOUBLE128
|
|
|
|
+ ty = New TDouble128Type
|
|
Case TType.T_STRING
|
|
Case TType.T_STRING
|
|
ty = New TStringType
|
|
ty = New TStringType
|
|
Case TType.T_ARRAY
|
|
Case TType.T_ARRAY
|
|
@@ -303,12 +319,22 @@ Function IsType:Int(ty:TType, kind:Int)
|
|
Return TUIntType(ty) <> Null
|
|
Return TUIntType(ty) <> Null
|
|
Case TType.T_LONG
|
|
Case TType.T_LONG
|
|
Return TLongType(ty) <> Null
|
|
Return TLongType(ty) <> Null
|
|
|
|
+ Case TType.T_ULONG
|
|
|
|
+ Return TULongType(ty) <> Null
|
|
Case TType.T_SIZET
|
|
Case TType.T_SIZET
|
|
Return TSizeTType(ty) <> Null
|
|
Return TSizeTType(ty) <> Null
|
|
|
|
+ Case TType.T_INT128
|
|
|
|
+ Return TInt128Type(ty) <> Null
|
|
Case TType.T_FLOAT
|
|
Case TType.T_FLOAT
|
|
Return TFloatType(ty) <> Null
|
|
Return TFloatType(ty) <> Null
|
|
Case TType.T_DOUBLE
|
|
Case TType.T_DOUBLE
|
|
Return TDoubleType(ty) <> Null
|
|
Return TDoubleType(ty) <> Null
|
|
|
|
+ Case TType.T_FLOAT64
|
|
|
|
+ Return TFloat64Type(ty) <> Null
|
|
|
|
+ Case TType.T_FLOAT128
|
|
|
|
+ Return TFloat128Type(ty) <> Null
|
|
|
|
+ Case TType.T_DOUBLE128
|
|
|
|
+ Return TDouble128Type(ty) <> Null
|
|
Case TType.T_STRING
|
|
Case TType.T_STRING
|
|
Return TStringType(ty) <> Null
|
|
Return TStringType(ty) <> Null
|
|
Case TType.T_ARRAY
|
|
Case TType.T_ARRAY
|
|
@@ -397,7 +423,10 @@ Type TNumericType Extends TType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TIntType Extends TNumericType
|
|
|
|
|
|
+Type TIntegralType Extends TNumericType
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TIntType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TIntType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TIntType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -411,26 +440,38 @@ Type TIntType Extends TNumericType
|
|
' Return ctor And ctor.IsCtor()
|
|
' Return ctor And ctor.IsCtor()
|
|
'EndIf
|
|
'EndIf
|
|
If _flags & T_VARPTR And (TIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
If _flags & T_VARPTR And (TIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
- Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null)
|
|
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And TLParamType(ty)<>Null)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TIntType(ty)<>Null And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TIntType(ty)<>Null And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or (WORD_SIZE=8 And TLParamType(ty)<>Null)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TIntType(ty)<>Null Then
|
|
If TIntType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
If TLongType(ty)<>Null Then
|
|
If TLongType(ty)<>Null Then
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
@@ -456,7 +497,7 @@ Type TIntType Extends TNumericType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TUIntType Extends TNumericType
|
|
|
|
|
|
+Type TUIntType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TUIntType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TUIntType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -470,19 +511,23 @@ Type TUIntType Extends TNumericType
|
|
' Return ctor And ctor.IsCtor()
|
|
' Return ctor And ctor.IsCtor()
|
|
'EndIf
|
|
'EndIf
|
|
If _flags & T_VARPTR And (TUIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
If _flags & T_VARPTR And (TUIntType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
- Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
|
|
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null))
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TUIntType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<> Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TUIntType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<> Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or (WORD_SIZE=8 And TWParamType(ty)<>Null)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
- If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -494,7 +539,7 @@ Type TUIntType Extends TNumericType
|
|
Return 1
|
|
Return 1
|
|
End If
|
|
End If
|
|
|
|
|
|
- If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -531,7 +576,7 @@ Type TUIntType Extends TNumericType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TSizeTType Extends TNumericType
|
|
|
|
|
|
+Type TSizeTType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TSizeTType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TSizeTType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -545,26 +590,34 @@ Type TSizeTType Extends TNumericType
|
|
' Return ctor And ctor.IsCtor()
|
|
' Return ctor And ctor.IsCtor()
|
|
'EndIf
|
|
'EndIf
|
|
If _flags & T_VARPTR And (TSizeTType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
If _flags & T_VARPTR And (TSizeTType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
- Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
|
|
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) Or (WORD_SIZE=4 And TUIntType(ty)<>Null) Or (WORD_SIZE=8 And TULongType(ty)<>Null)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
If WORD_SIZE = 4 Then
|
|
If WORD_SIZE = 4 Then
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
|
|
Else
|
|
Else
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
|
|
End If
|
|
End If
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TSizeTType(ty)<>Null Then
|
|
If TSizeTType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If TWParamType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
If WORD_SIZE = 4 Then
|
|
If WORD_SIZE = 4 Then
|
|
If TUIntType(ty)<>Null Then
|
|
If TUIntType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
@@ -573,6 +626,10 @@ Type TSizeTType Extends TNumericType
|
|
If TIntType(ty)<>Null Then
|
|
If TIntType(ty)<>Null Then
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If TLParamType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
|
|
If TULongType(ty)<>Null Then
|
|
If TULongType(ty)<>Null Then
|
|
Return 3
|
|
Return 3
|
|
@@ -599,6 +656,10 @@ Type TSizeTType Extends TNumericType
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If TLParamType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
@@ -606,6 +667,11 @@ Type TSizeTType Extends TNumericType
|
|
If TDoubleType(ty)<>Null Then
|
|
If TDoubleType(ty)<>Null Then
|
|
Return 6
|
|
Return 6
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 8
|
|
|
|
+ End If
|
|
|
|
+
|
|
End If
|
|
End If
|
|
|
|
|
|
Return T_MAX_DISTANCE
|
|
Return T_MAX_DISTANCE
|
|
@@ -625,7 +691,7 @@ Type TSizeTType Extends TNumericType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TByteType Extends TNumericType
|
|
|
|
|
|
+Type TByteType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TByteType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TByteType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -643,12 +709,16 @@ Type TByteType Extends TNumericType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TByteType(ty)<>Null And (ty._flags & T_VAR)) Or TShortType(ty)<>Null Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TByteType(ty)<>Null And (ty._flags & T_VAR)) Or TShortType(ty)<>Null Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TByteType(ty)<>Null Then
|
|
If TByteType(ty)<>Null Then
|
|
@@ -659,7 +729,7 @@ Type TByteType Extends TNumericType
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
|
|
- If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -670,8 +740,12 @@ Type TByteType Extends TNumericType
|
|
If TIntType(ty)<>Null Then
|
|
If TIntType(ty)<>Null Then
|
|
Return 5
|
|
Return 5
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 5
|
|
|
|
+ End If
|
|
|
|
|
|
- If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 6
|
|
Return 6
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -683,6 +757,10 @@ Type TByteType Extends TNumericType
|
|
Return 7
|
|
Return 7
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 7
|
|
|
|
+ End If
|
|
|
|
+
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
Return 8
|
|
Return 8
|
|
End If
|
|
End If
|
|
@@ -708,7 +786,7 @@ Type TByteType Extends TNumericType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TShortType Extends TNumericType
|
|
|
|
|
|
+Type TShortType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TShortType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TShortType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -726,19 +804,23 @@ Type TShortType Extends TNumericType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TShortType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TShortType(ty)<>Null And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TWParamType(ty)<>Null Or TLParamType(ty)<>Null
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TShortType(ty)<>Null Then
|
|
If TShortType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
- If WORD_SIZE = 4 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 4 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 2
|
|
Return 2
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -749,8 +831,12 @@ Type TShortType Extends TNumericType
|
|
If TIntType(ty)<>Null Then
|
|
If TIntType(ty)<>Null Then
|
|
Return 3
|
|
Return 3
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If WORD_SIZE = 4 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 3
|
|
|
|
+ End If
|
|
|
|
|
|
- If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -762,6 +848,10 @@ Type TShortType Extends TNumericType
|
|
Return 5
|
|
Return 5
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
+ If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 5
|
|
|
|
+ End If
|
|
|
|
+
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
Return 6
|
|
Return 6
|
|
End If
|
|
End If
|
|
@@ -787,7 +877,7 @@ Type TShortType Extends TNumericType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TLongType Extends TNumericType ' BaH Long
|
|
|
|
|
|
+Type TLongType Extends TIntegralType ' BaH Long
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TLongType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TLongType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -805,17 +895,25 @@ Type TLongType Extends TNumericType ' BaH Long
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TLongType(ty)<>Null And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TLongType(ty)<>Null And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TLongType(ty)<>Null Then
|
|
If TLongType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If WORD_SIZE = 8 And TLParamType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
Return 2
|
|
Return 2
|
|
@@ -824,6 +922,10 @@ Type TLongType Extends TNumericType ' BaH Long
|
|
If TDoubleType(ty)<>Null Then
|
|
If TDoubleType(ty)<>Null Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
|
|
Return T_MAX_DISTANCE
|
|
Return T_MAX_DISTANCE
|
|
End Method
|
|
End Method
|
|
@@ -837,7 +939,7 @@ Type TLongType Extends TNumericType ' BaH Long
|
|
End Method
|
|
End Method
|
|
End Type
|
|
End Type
|
|
|
|
|
|
-Type TULongType Extends TNumericType
|
|
|
|
|
|
+Type TULongType Extends TIntegralType
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
Return TULongType( ty )<>Null And (_flags = ty._flags Or ..
|
|
Return TULongType( ty )<>Null And (_flags = ty._flags Or ..
|
|
@@ -855,19 +957,23 @@ Type TULongType Extends TNumericType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method WidensToType:Int( ty:TType )
|
|
Method WidensToType:Int( ty:TType )
|
|
- Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TULongType(ty)<>Null And (ty._flags & T_VAR)) Or TDoubleType(ty)<>Null
|
|
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TULongType(ty)<>Null And (ty._flags & T_VAR)) Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TULongType(ty)<>Null Then
|
|
If TULongType(ty)<>Null Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
- If WORD_SIZE = 8 And TSizeTType(ty)<>Null Then
|
|
|
|
|
|
+ If WORD_SIZE = 8 And (TSizeTType(ty)<>Null Or TWParamType(ty)<>Null) Then
|
|
Return 0
|
|
Return 0
|
|
End If
|
|
End If
|
|
|
|
|
|
@@ -882,7 +988,11 @@ Type TULongType Extends TNumericType
|
|
If TDoubleType(ty)<>Null Then
|
|
If TDoubleType(ty)<>Null Then
|
|
Return 4
|
|
Return 4
|
|
End If
|
|
End If
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
+
|
|
Return T_MAX_DISTANCE
|
|
Return T_MAX_DISTANCE
|
|
End Method
|
|
End Method
|
|
|
|
|
|
@@ -920,8 +1030,12 @@ Type TFloatType Extends TDecimalType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TFloatType(ty)<>Null Then
|
|
If TFloatType(ty)<>Null Then
|
|
@@ -971,8 +1085,12 @@ Type TDoubleType Extends TDecimalType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method DistanceToType:Int(ty:TType)
|
|
Method DistanceToType:Int(ty:TType)
|
|
- If (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Then
|
|
|
|
- Return 0
|
|
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TDoubleType(ty)<>Null Then
|
|
If TDoubleType(ty)<>Null Then
|
|
@@ -992,6 +1110,220 @@ Type TDoubleType Extends TDecimalType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
|
|
+Type TIntrinsicType Extends TNumericType
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TInt128Type Extends TIntrinsicType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TInt128Type( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ 'If TObjectType( ty )
|
|
|
|
+ ' Local expr:TExpr=New TConstExpr.Create( Self,"" ).Semant()
|
|
|
|
+ ' Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True )
|
|
|
|
+ ' Return ctor And ctor.IsCtor()
|
|
|
|
+ 'EndIf
|
|
|
|
+ If _flags & T_VARPTR And (TLongType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TLongVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TInt128Type(ty)<>Null And (ty._flags & T_VAR)) Or TFloat128Type(ty)<>Null Or TDouble128Type(ty)<>Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TInt128Type(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat128Type(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDouble128Type(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TInt128Type
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "Int128" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TFloat64Type Extends TIntrinsicType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TFloat64Type( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ 'If TObjectType( ty )
|
|
|
|
+ ' Local expr:TExpr=New TConstExpr.Create( Self,"" ).Semant()
|
|
|
|
+ ' Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True )
|
|
|
|
+ ' Return ctor And ctor.IsCtor()
|
|
|
|
+ 'EndIf
|
|
|
|
+ If _flags & T_VARPTR And (TFloat64Type(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TDoubleVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TFloat64Type(ty)<>Null And (ty._flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TFloat64Type
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "Float64" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TFloat128Type Extends TIntrinsicType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TFloat128Type( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ 'If TObjectType( ty )
|
|
|
|
+ ' Local expr:TExpr=New TConstExpr.Create( Self,"" ).Semant()
|
|
|
|
+ ' Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True )
|
|
|
|
+ ' Return ctor And ctor.IsCtor()
|
|
|
|
+ 'EndIf
|
|
|
|
+ If _flags & T_VARPTR And (TFloat128Type(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TDoubleVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TFloat128Type(ty)<>Null And (ty._flags & T_VAR)) Or TInt128Type(ty)<>Null Or TDouble128Type(ty)<>Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat128Type(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDouble128Type(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TInt128Type(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TFloat128Type
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "Float128" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TDouble128Type Extends TIntrinsicType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TDouble128Type( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ 'If TObjectType( ty )
|
|
|
|
+ ' Local expr:TExpr=New TConstExpr.Create( Self,"" ).Semant()
|
|
|
|
+ ' Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True )
|
|
|
|
+ ' Return ctor And ctor.IsCtor()
|
|
|
|
+ 'EndIf
|
|
|
|
+ If _flags & T_VARPTR And (TDouble128Type(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TDoubleVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or (TDouble128Type(ty)<>Null And (ty._flags & T_VAR)) Or TInt128Type(ty)<>Null Or TFloat128Type(ty)<>Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDouble128Type(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat128Type(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TInt128Type(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TDouble128Type
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "Double128" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|
|
|
|
+
|
|
Type TStringType Extends TType
|
|
Type TStringType Extends TType
|
|
|
|
|
|
Field cdecl:TClassDecl
|
|
Field cdecl:TClassDecl
|
|
@@ -1065,7 +1397,7 @@ Type TArrayType Extends TType
|
|
|
|
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
Local arrayType:TArrayType=TArrayType( ty )
|
|
Local arrayType:TArrayType=TArrayType( ty )
|
|
- Return (arrayType And ( TVoidType( elemType ) Or elemType.EqualsType( arrayType.elemType ) Or elemType.ExtendsType( arrayType.elemType ) )) Or IsPointerType(ty, 0, TType.T_POINTER) <> Null Or (TObjectType( ty ) And TObjectType( ty ).classDecl.ident="Object")
|
|
|
|
|
|
+ Return (arrayType And dims = arrayType.dims And ( TVoidType( elemType ) Or (TObjectType(elemType) And elemType.EqualsType( arrayType.elemType ) Or elemType.ExtendsType( arrayType.elemType )))) Or IsPointerType(ty, 0, TType.T_POINTER) <> Null Or (TObjectType( ty ) And TObjectType( ty ).classDecl.ident="Object")
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method Semant:TType(option:Int = False)
|
|
Method Semant:TType(option:Int = False)
|
|
@@ -1111,6 +1443,7 @@ Type TObjectType Extends TType
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ If classDecl.IsStruct() Return False
|
|
Local objty:TObjectType=TObjectType( ty )
|
|
Local objty:TObjectType=TObjectType( ty )
|
|
If objty Return classDecl.ExtendsClass( objty.classDecl )
|
|
If objty Return classDecl.ExtendsClass( objty.classDecl )
|
|
If IsPointerType( ty, T_BYTE ) Return True
|
|
If IsPointerType( ty, T_BYTE ) Return True
|
|
@@ -1133,6 +1466,33 @@ Type TObjectType Extends TType
|
|
|
|
|
|
End Type
|
|
End Type
|
|
|
|
|
|
|
|
+Type TClassType Extends TType
|
|
|
|
+
|
|
|
|
+ Field classDecl:TClassDecl
|
|
|
|
+ Field instance:Int
|
|
|
|
+
|
|
|
|
+ Method Create:TClassType( classDecl:TClassDecl )
|
|
|
|
+ Self.classDecl=classDecl
|
|
|
|
+ Return Self
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method GetClass:TClassDecl()
|
|
|
|
+ Return classDecl
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Local ty:TClassType = New TClassType
|
|
|
|
+ ty.classDecl = classDecl
|
|
|
|
+ ty.instance = instance
|
|
|
|
+ Return ty
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString:String()
|
|
|
|
+ Return "Type"
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|
|
|
|
+
|
|
Type TIdentType Extends TType
|
|
Type TIdentType Extends TType
|
|
Field ident$
|
|
Field ident$
|
|
Field args:TType[]
|
|
Field args:TType[]
|
|
@@ -1192,18 +1552,18 @@ Type TIdentType Extends TType
|
|
|
|
|
|
If i=-1
|
|
If i=-1
|
|
tyid=ident.ToLower()
|
|
tyid=ident.ToLower()
|
|
-
|
|
|
|
|
|
+
|
|
If tyid = "self" Then
|
|
If tyid = "self" Then
|
|
' find owning class
|
|
' find owning class
|
|
Local scope:TClassDecl = _env.ClassScope()
|
|
Local scope:TClassDecl = _env.ClassScope()
|
|
If scope Then
|
|
If scope Then
|
|
tyid = scope.ident
|
|
tyid = scope.ident
|
|
- ty = New TObjectType.Create(scope)
|
|
|
|
|
|
+ ty = New TClassType.Create(scope)
|
|
|
|
|
|
' test for method scope - self is already an instance
|
|
' test for method scope - self is already an instance
|
|
Local funcScope:TFuncDecl = _env.FuncScope()
|
|
Local funcScope:TFuncDecl = _env.FuncScope()
|
|
- If funcScope.IsMethod() Then
|
|
|
|
- TObjectType(ty).instance = True
|
|
|
|
|
|
+ If funcScope.IsAnyMethod() Then
|
|
|
|
+ TClassType(ty).instance = True
|
|
End If
|
|
End If
|
|
Else
|
|
Else
|
|
Err "'Self' can only be used within methods."
|
|
Err "'Self' can only be used within methods."
|
|
@@ -1233,12 +1593,12 @@ Type TIdentType Extends TType
|
|
Local scope:TClassDecl = _env.ClassScope()
|
|
Local scope:TClassDecl = _env.ClassScope()
|
|
If scope Then
|
|
If scope Then
|
|
tyid = scope.ident
|
|
tyid = scope.ident
|
|
- ty = New TObjectType.Create(scope)
|
|
|
|
|
|
+ ty = New TClassType.Create(scope)
|
|
|
|
|
|
' test for method scope - self is already an instance
|
|
' test for method scope - self is already an instance
|
|
Local funcScope:TFuncDecl = _env.FuncScope()
|
|
Local funcScope:TFuncDecl = _env.FuncScope()
|
|
- If funcScope.IsMethod() Then
|
|
|
|
- TObjectType(ty).instance = True
|
|
|
|
|
|
+ If funcScope.IsAnyMethod() Then
|
|
|
|
+ TClassType(ty).instance = True
|
|
End If
|
|
End If
|
|
Else
|
|
Else
|
|
Err "'Self' can only be used within methods."
|
|
Err "'Self' can only be used within methods."
|
|
@@ -1279,6 +1639,10 @@ Type TIdentType Extends TType
|
|
End If
|
|
End If
|
|
|
|
|
|
If (_flags & T_POINTER) And TObjectType(ty) Then
|
|
If (_flags & T_POINTER) And TObjectType(ty) Then
|
|
|
|
+ ' FIXME #200
|
|
|
|
+ 'If Not TObjectType(ty).classDecl.IsExtern() Then
|
|
|
|
+ ' Err "Invalid Pointer type."
|
|
|
|
+ 'End If
|
|
ty = New TObjectType.Create(TObjectType(ty).classDecl)
|
|
ty = New TObjectType.Create(TObjectType(ty).classDecl)
|
|
ty._flags :| (_flags & T_POINTER)
|
|
ty._flags :| (_flags & T_POINTER)
|
|
End If
|
|
End If
|
|
@@ -1369,17 +1733,36 @@ End Type
|
|
Type TFunctionPtrType Extends TType
|
|
Type TFunctionPtrType Extends TType
|
|
|
|
|
|
Field func:TFuncDecl
|
|
Field func:TFuncDecl
|
|
|
|
+
|
|
|
|
+ Method Create:TFunctionPtrType(func:TFuncDecl)
|
|
|
|
+ Self.func = func
|
|
|
|
+ Return Self
|
|
|
|
+ End Method
|
|
|
|
|
|
Method EqualsType:Int( ty:TType )
|
|
Method EqualsType:Int( ty:TType )
|
|
-' TODO : compare function decl
|
|
|
|
- Return TFunctionPtrType( ty )<>Null
|
|
|
|
|
|
+ If Not TFunctionPtrType(ty) Then Return False
|
|
|
|
+ ' declared function pointer
|
|
|
|
+ Local tyfunc:TFuncDecl = TFunctionPtrType(ty).func
|
|
|
|
+ If Not tyfunc.retType.EqualsType(func.retType) Then Return False
|
|
|
|
+ If Not (tyfunc.argDecls.Length = func.argDecls.Length) Then Return False
|
|
|
|
+ For Local a:Int = 0 Until func.argDecls.Length
|
|
|
|
+ ' does our arg equal declared arg?
|
|
|
|
+ If Not func.argDecls[a].ty.EqualsType(tyfunc.argDecls[a].ty) Then Return False
|
|
|
|
+ Next
|
|
|
|
+ Return True
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
- If TObjectType( ty )
|
|
|
|
- Local expr:TExpr=New TConstExpr.Create( Self,"" ).Semant()
|
|
|
|
- Local ctor:TFuncDecl=ty.GetClass().FindFuncDecl( "new",[expr],True,,,,SCOPE_CLASS_HEIRARCHY )
|
|
|
|
- Return ctor And ctor.IsCtor()
|
|
|
|
|
|
+ If TFunctionPtrType( ty )
|
|
|
|
+ ' declared function pointer
|
|
|
|
+ Local tyfunc:TFuncDecl = TFunctionPtrType(ty).func
|
|
|
|
+ If Not func.retType.ExtendsType(tyfunc.retType) Then Return False
|
|
|
|
+ If Not (func.argDecls.Length = tyfunc.argDecls.Length) Then Return False
|
|
|
|
+ For Local a:Int = 0 Until func.argDecls.Length
|
|
|
|
+ ' does declared arg extend our arg?
|
|
|
|
+ If Not tyfunc.argDecls[a].ty.ExtendsType(func.argDecls[a].ty) Then Return False
|
|
|
|
+ Next
|
|
|
|
+ Return True
|
|
EndIf
|
|
EndIf
|
|
Return IsPointerType( ty, 0, T_POINTER )<>Null
|
|
Return IsPointerType( ty, 0, T_POINTER )<>Null
|
|
End Method
|
|
End Method
|
|
@@ -1434,3 +1817,195 @@ Type TVarPtrType Extends TType
|
|
Return New TVarPtrType
|
|
Return New TVarPtrType
|
|
End Method
|
|
End Method
|
|
End Type
|
|
End Type
|
|
|
|
+
|
|
|
|
+Type TParamType Extends TIntegralType
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TWParamType Extends TParamType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TWParamType( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ If _flags & T_VARPTR And (TWParamType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ If WORD_SIZE = 4 Then
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TWParamType(ty)<>Null Or TSizeTType(ty)<>Null Or TUIntType(ty)<>Null) And (ty._flags & T_VAR)) Or TIntType(ty)<>Null Or TUIntType(ty)<>Null Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null
|
|
|
|
+ Else
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TWParamType(ty)<>Null Or TSizeTType(ty)<>Null Or TULongType(ty)<>Null) And (ty._flags & T_VAR)) Or TLongType(ty)<>Null Or TULongType(ty)<>Null Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
|
|
|
|
+ End If
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TWParamType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TSizeTType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If WORD_SIZE = 4 Then
|
|
|
|
+ If TUIntType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TIntType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TULongType(ty)<>Null Then
|
|
|
|
+ Return 3
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TLongType(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloatType(ty)<>Null Then
|
|
|
|
+ Return 5
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDoubleType(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Else
|
|
|
|
+ If TULongType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TLongType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloatType(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDoubleType(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 8
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TWParamType
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "WPARAM" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method GetSize:Int()
|
|
|
|
+ Return WORD_SIZE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|
|
|
|
+
|
|
|
|
+Type TLParamType Extends TParamType
|
|
|
|
+
|
|
|
|
+ Method EqualsType:Int( ty:TType )
|
|
|
|
+ Return TLParamType( ty )<>Null And (_flags = ty._flags Or ..
|
|
|
|
+ (_flags & T_VARPTR And ty._flags & T_PTR) Or (ty._flags & T_VARPTR And _flags & T_PTR) Or (_flags & T_VAR))
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ExtendsType:Int( ty:TType, noExtendString:Int = False, widensTest:Int = False )
|
|
|
|
+ If _flags & T_VARPTR And (TLParamType(ty) <> Null Or IsPointerType(ty, 0, T_POINTER)) Return True
|
|
|
|
+ Return (widensTest And WidensToType(ty)) Or (Not widensTest And TNumericType( ty )<>Null) Or (Not noExtendString And TStringType( ty )<>Null) 'Or TIntVarPtrType( ty )<> Null
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method WidensToType:Int( ty:TType )
|
|
|
|
+ If WORD_SIZE = 4 Then
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TIntType(ty)<>Null Or TLParamType(ty)<>Null) And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
|
|
|
|
+ Else
|
|
|
|
+ Return (IsPointerType(ty, 0, T_POINTER) And IsPointerType(Self, 0, T_POINTER)) Or ((TLongType(ty)<>Null Or TLParamType(ty)<>Null) And (ty._flags & T_VAR)) Or TFloatType(ty)<>Null Or TDoubleType(ty)<>Null Or TFloat64Type(ty)<>Null
|
|
|
|
+ End If
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method DistanceToType:Int(ty:TType)
|
|
|
|
+ If IsPointerType(ty, 0, T_POINTER) Then
|
|
|
|
+ If IsPointerType(Self, 0, T_POINTER) Then
|
|
|
|
+ Return 0
|
|
|
|
+ Else
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TLParamType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If WORD_SIZE = 4 Then
|
|
|
|
+
|
|
|
|
+ If TIntType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TLongType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloatType(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDoubleType(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Else
|
|
|
|
+ If TLongType(ty)<>Null Then
|
|
|
|
+ Return 0
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloatType(ty)<>Null Then
|
|
|
|
+ Return 2
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TDoubleType(ty)<>Null Then
|
|
|
|
+ Return 4
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ If TFloat64Type(ty)<>Null Then
|
|
|
|
+ Return 6
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ Return T_MAX_DISTANCE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method OnCopy:TType()
|
|
|
|
+ Return New TLParamType
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method ToString$()
|
|
|
|
+ Return "LPARAM" + ToStringParts()
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+ Method GetSize:Int()
|
|
|
|
+ Return WORD_SIZE
|
|
|
|
+ End Method
|
|
|
|
+
|
|
|
|
+End Type
|