Browse Source

Added longint and ulongint types.

Brucey 3 năm trước cách đây
mục cha
commit
b1013fda29
9 tập tin đã thay đổi với 465 bổ sung14 xóa
  1. 5 4
      config.bmx
  2. 95 0
      ctranslator.bmx
  3. 15 7
      expr.bmx
  4. 28 0
      iparser.bmx
  5. 109 0
      math.c
  6. 1 1
      options.bmx
  7. 13 1
      parser.bmx
  8. 1 1
      toker.bmx
  9. 198 0
      type.bmx

+ 5 - 4
config.bmx

@@ -34,9 +34,7 @@ Import "base.stringhelper.bmx"
 Import "base64.bmx"
 Import "enums.c"
 Import "hash.c"
-?Not bmxng
 Import "math.c"
-?
 
 ' debugging help
 Const DEBUG:Int = False
@@ -760,12 +758,15 @@ Extern
 	Function bmx_hash_update(state:Byte Ptr, data:Byte Ptr, length:Int)
 	Function bmx_hash_digest:String(state:Byte Ptr)
 
-?Not bmxng
 	Function bmx_bitwise_not_uint:String(value:String)
 	Function bmx_bitwise_not_sizet:String(value:String)
 	Function bmx_bitwise_not_ulong:String(value:String)
+	Function bmx_bitwise_not_longint:String(value:String, size:Int)
+	Function bmx_bitwise_not_ulongint:String(value:String, size:Int)
 	Function bmx_binarymathexpr_sizet:String(op:Int, lhs:String, rhs:String)
 	Function bmx_binarymathexpr_uint:String(op:Int, lhs:String, rhs:String)
 	Function bmx_binarymathexpr_ulong:String(op:Int, lhs:String, rhs:String)
-?
+	Function bmx_binarymathexpr_longint:String(op:Int, lhs:String, rhs:String, size:Int)
+	Function bmx_binarymathexpr_ulongint:String(op:Int, lhs:String, rhs:String, size:Int)
+
 End Extern

+ 95 - 0
ctranslator.bmx

@@ -71,6 +71,8 @@ Type TCTranslator Extends TTranslator
 		If TDoubleType( ty ) Return "~q" + p + "d~q"
 		If TLongType( ty ) Return "~q" + p + "l~q"
 		If TULongType( ty ) Return "~q" + p + "y~q"
+		If TLongIntType( ty ) Return "~q" + p + "v~q"
+		If TULongIntType( ty ) Return "~q" + p + "e~q"
 		If TSizeTType( ty ) Return "~q" + p + "z~q"
 		If TWParamType( ty ) Return "~q" + p + "w~q"
 		If TLParamType( ty ) Return "~q" + p + "x~q"
@@ -120,6 +122,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "~ql~q"
 		If TULongType( ty ) Return "~qy~q"
 		If TSizeTType( ty ) Return "~qz~q"
+		If TLongIntType( ty ) Return "~qv~q"
+		If TULongIntType( ty ) Return "~qe~q"
 		If TStringType( ty ) Return "~q$~q"
 		If TWParamType( ty ) Return "~qw~q"
 		If TLParamType( ty ) Return "~qx~q"
@@ -135,6 +139,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "bbConvertToLong"
 		If TULongType( ty ) Return "bbConvertToULong"
 		If TSizeTType( ty ) Return "bbConvertToSizet"
+		If TLongIntType( ty ) Return "bbConvertToLongInt"
+		If TULongIntType( ty ) Return "bbConvertToULongInt"
 		If TStringType( ty ) Return "bbConvertToString"
 	End Method
 
@@ -148,6 +154,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "l"
 		If TULongType( ty ) Return "y"
 		If TSizeTType( ty ) Return "z"
+		If TLongIntType( ty ) Return "v"
+		If TULongIntType( ty ) Return "e"
 		If TWParamType( ty ) Return "w"
 		If TLParamType( ty ) Return "x"
 		If TStringType( ty ) Return "t"
@@ -165,6 +173,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return p + "l"
 		If TULongType( ty ) Return p + "y"
 		If TSizeTType( ty ) Return p + "t"
+		If TLongIntType( ty ) Return p + "v"
+		If TULongIntType( ty ) Return p + "e"
 		If TWParamType( ty ) Return p + "W"
 		If TLParamType( ty ) Return p + "X"
 		If TInt128Type( ty ) Return p + "j"
@@ -230,6 +240,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "BBLONG" + p
 		If TULongType( ty ) Return "BBULONG" + p
 		If TSizeTType( ty ) Return "BBSIZET" + p
+		If TLongIntType( ty ) Return "BBLONGINT" + p
+		If TULongIntType( ty ) Return "BBULONGINT" + p
 		If TWParamType( ty ) Return "WPARAM" + p
 		If TLParamType( ty ) Return "LPARAM" + p
 		If TInt128Type( ty ) Return "BBINT128" + p
@@ -328,6 +340,8 @@ Type TCTranslator Extends TTranslator
 		If TLongType( ty ) Return "%%" + p
 		If TULongType( ty ) Return "||" + p
 		If TSizeTType( ty ) Return "%z" + p
+		If TLongIntType( ty ) Return "%v" + p
+		If TULongIntType( ty ) Return "%e" + p
 		If TWParamType( ty ) Return "%w" + p
 		If TLParamType( ty ) Return "%x" + p
 		If TInt128Type( ty ) Return "%j" + p
@@ -416,6 +430,8 @@ Type TCTranslator Extends TTranslator
 			If TLongType( ty ) Return value+"LL"
 			If TULongType( ty ) Return value+"ULL"
 			If TSizeTType( ty ) Return value
+			If TLongIntType( ty ) Return value
+			If TULongIntType( ty ) Return value
 			If TWParamType( ty ) Return value
 			If TLParamType( ty ) Return value
 			If TInt128Type( ty ) Return value
@@ -1898,6 +1914,8 @@ t:+"NULLNULLNULL"
 				If TLongType( src) Return Bra("&"+t)
 				If TULongType( src) Return Bra("&"+t)
 				If TSizeTType( src) Return Bra("&"+t)
+				If TLongIntType( src) Return Bra("&"+t)
+				If TULongIntType( src) Return Bra("&"+t)
 				If TDoubleType( src) Return Bra("&"+t)
 				If TInt128Type( src) Return Bra("&"+t)
 				If TFloat128Type( src) Return Bra("&"+t)
@@ -1990,6 +2008,12 @@ t:+"NULLNULLNULL"
 			Else If TSizeTType( dst )
 				If IsPointerType(src, TType.T_SIZET, TType.T_POINTER & dst._flags) Return t
 				If TNumericType( src ) Return Bra("(BBSIZET" + p + ")"+t)
+			Else If TLongIntType( dst )
+				If IsPointerType(src, TType.T_LONGINT, TType.T_POINTER & dst._flags) Return t
+				If TNumericType( src ) Return Bra("(BBLONGINT" + p + ")"+t)
+			Else If TULongIntType( dst )
+				If IsPointerType(src, TType.T_ULONGINT, TType.T_POINTER & dst._flags) Return t
+				If TNumericType( src ) Return Bra("(BBULONGINT" + p + ")"+t)
 			Else If TWParamType( dst )
 				If IsPointerType(src, TType.T_WPARAM, TType.T_POINTER & dst._flags) Return t
 				If TNumericType( src ) Return Bra("(WPARAM" + p + ")"+t)
@@ -2034,6 +2058,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra( t+"!=0" )
 			If TULongType( src ) Return Bra( t+"!=0" )
 			If TSizeTType( src ) Return Bra( t+"!=0" )
+			If TLongIntType( src ) Return Bra( t+"!=0" )
+			If TULongIntType( src ) Return Bra( t+"!=0" )
 			If TWParamType( src ) Return Bra( t+"!=0" )
 			If TLParamType( src ) Return Bra( t+"!=0" )
 			If TDoubleType( src ) Return Bra( t+"!=0.0f" )
@@ -2067,6 +2093,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBINT)"+t)
 			If TULongType( src ) Return Bra("(BBINT)"+t)
 			If TSizeTType( src ) Return Bra("(BBINT)"+t)
+			If TLongIntType( src ) Return Bra("(BBINT)"+t)
+			If TULongIntType( src ) Return Bra("(BBINT)"+t)
 			If TWParamType( src ) Return Bra("(BBINT)"+t)
 			If TLParamType( src ) Return Bra("(BBINT)"+t)
 			If TStringType( src ) Return "bbStringToInt" + Bra(t)
@@ -2083,6 +2111,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return t
 			If TULongType( src ) Return Bra("(BBLONG)"+t)
 			If TSizeTType( src ) Return Bra("(BBLONG)"+t)
+			If TLongIntType( src ) Return Bra("(BBLONG)"+t)
+			If TULongIntType( src ) Return Bra("(BBLONG)"+t)
 			If TWParamType( src ) Return Bra("(BBLONG)"+t)
 			If TLParamType( src ) Return Bra("(BBLONG)"+t)
 			If TFloatType( src ) Return Bra("(BBLONG)"+t)
@@ -2101,6 +2131,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src) Return Bra("(BBSIZET)"+t)
 			If TULongType( src) Return Bra("(BBSIZET)"+t)
 			If TSizeTType( src ) Return t
+			If TLongIntType( src) Return Bra("(BBSIZET)"+t)
+			If TULongIntType( src) Return Bra("(BBSIZET)"+t)
 			If TWParamType( src ) Return Bra("(BBSIZET)"+t)
 			If TLParamType( src ) Return Bra("(BBSIZET)"+t)
 			If TFloatType( src ) Return Bra("(BBSIZET)"+t)
@@ -2110,6 +2142,46 @@ t:+"NULLNULLNULL"
 			If TFloat64Type( src ) Return Bra("(BBSIZET)"+t)
 			If TEnumType( src) Return Bra("(BBSIZET)"+t)
 			'If TPointerType( src ) Return Bra("(BBLONG)"+t)
+		Else If TLongIntType( dst )
+			If TBoolType( src ) Return Bra( t )
+			If TByteType( src) Return Bra("(BBLONGINT)"+t)
+			If TShortType( src) Return Bra("(BBLONGINT)"+t)
+			If TIntType( src) Return Bra("(BBLONGINT)"+t)
+			If TUIntType( src) Return Bra("(BBLONGINT)"+t)
+			If TLongType( src ) Return Bra("(BBLONGINT)"+t)
+			If TULongType( src ) Return Bra("(BBLONGINT)"+t)
+			If TSizeTType( src ) Return Bra("(BBLONGINT)"+t)
+			If TLongIntType( src ) Return t
+			If TULongIntType( src ) Return Bra("(BBLONGINT)"+t)
+			If TWParamType( src ) Return Bra("(BBLONGINT)"+t)
+			If TLParamType( src ) Return Bra("(BBLONGINT)"+t)
+			If TFloatType( src ) Return Bra("(BBLONGINT)"+t)
+			If TDoubleType( src ) Return Bra("(BBLONGINT)"+t)
+			If TStringType( src ) Return "bbStringToLongInt" + Bra(t)
+			If IsPointerType(src,0,TType.T_POINTER) Return Bra("(BBLONGINT)"+t)
+			If TFloat64Type( src ) Return Bra("(BBLONGINT)"+t)
+			If TEnumType( src) Return Bra("(BBLONGINT)"+t)
+			'If TPointerType( src ) Return Bra("(BBLONGINT)"+t)
+		Else If TULongIntType( dst )
+			If TBoolType( src ) Return Bra( t )
+			If TByteType( src) Return Bra("(BBULONGINT)"+t)
+			If TShortType( src) Return Bra("(BBULONGINT)"+t)
+			If TIntType( src) Return Bra("(BBULONGINT)"+t)
+			If TUIntType( src) Return Bra("(BBULONGINT)"+t)
+			If TLongType( src ) Return Bra("(BBULONGINT)"+t)
+			If TULongType( src ) Return Bra("(BBULONGINT)"+t)
+			If TSizeTType( src ) Return Bra("(BBULONGINT)"+t)
+			If TLongIntType( src ) Return Bra("(BBULONGINT)"+t)
+			If TULongIntType( src ) Return t
+			If TWParamType( src ) Return Bra("(BBULONGINT)"+t)
+			If TLParamType( src ) Return Bra("(BBULONGINT)"+t)
+			If TFloatType( src ) Return Bra("(BBULONGINT)"+t)
+			If TDoubleType( src ) Return Bra("(BBULONGINT)"+t)
+			If TStringType( src ) Return "bbStringToULongInt" + Bra(t)
+			If IsPointerType(src,0,TType.T_POINTER) Return Bra("(BBULONGINT)"+t)
+			If TFloat64Type( src ) Return Bra("(BBULONGINT)"+t)
+			If TEnumType( src) Return Bra("(BBULONGINT)"+t)
+			'If TPointerType( src ) Return Bra("(BBULONGINT)"+t)
 		Else If TFloatType( dst )
 			If TBoolType( src ) Return Bra( t )
 			If TByteType( src ) Return Bra("(BBFLOAT)"+t)
@@ -2121,6 +2193,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBFLOAT)"+t)
 			If TULongType( src ) Return Bra("(BBFLOAT)"+t)
 			If TSizeTType( src ) Return Bra("(BBFLOAT)"+t)
+			If TLongIntType( src ) Return Bra("(BBFLOAT)"+t)
+			If TULongIntType( src ) Return Bra("(BBFLOAT)"+t)
 			If TWParamType( src ) Return Bra("(BBFLOAT)"+t)
 			If TLParamType( src ) Return Bra("(BBFLOAT)"+t)
 			If TStringType( src ) Return "bbStringToFloat" + Bra(t)
@@ -2137,6 +2211,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TULongType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TSizeTType( src ) Return Bra("(BBDOUBLE)"+t)
+			If TLongIntType( src ) Return Bra("(BBDOUBLE)"+t)
+			If TULongIntType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TWParamType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TLParamType( src ) Return Bra("(BBDOUBLE)"+t)
 			If TStringType( src ) Return "bbStringToDouble" + Bra(t)
@@ -2152,6 +2228,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return "bbStringFromLong"+Bra( t )
 			If TULongType( src ) Return "bbStringFromULong"+Bra( t )
 			If TSizeTType( src ) Return "bbStringFromSizet"+Bra( t )
+			If TLongIntType( src ) Return "bbStringFromLongInt"+Bra( t )
+			If TULongIntType( src ) Return "bbStringFromULongInt"+Bra( t )
 			If TWParamType( src ) Return "bbStringFromWParam"+Bra( t )
 			If TLParamType( src ) Return "bbStringFromLParam"+Bra( t )
 			If TFloatType( src ) Return "bbStringFromFloat"+Bra( t )
@@ -2180,6 +2258,8 @@ t:+"NULLNULLNULL"
 				If TLongType( ty ) Return "bbStringFromLong"+Bra( t )
 				If TULongType( ty ) Return "bbStringFromULong"+Bra( t )
 				If TSizeTType( ty ) Return "bbStringFromSizet"+Bra( t )
+				If TLongIntType( ty ) Return "bbStringFromLongInt"+Bra( t )
+				If TULongIntType( ty ) Return "bbStringFromULongInt"+Bra( t )
 			End If
 			'If TStringVarPtrType( src ) Then
 			'	If TSliceExpr( expr.expr ) Then
@@ -2201,6 +2281,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBBYTE)"+t)
 			If TULongType( src ) Return Bra("(BBBYTE)"+t)
 			If TSizeTType( src ) Return Bra("(BBBYTE)"+t)
+			If TLongIntType( src ) Return Bra("(BBBYTE)"+t)
+			If TULongIntType( src ) Return Bra("(BBBYTE)"+t)
 			If TWParamType( src ) Return Bra("(BBBYTE)"+t)
 			If TLParamType( src ) Return Bra("(BBBYTE)"+t)
 			If TStringType( src ) Return Bra("(BBBYTE)bbStringToInt" + Bra(t))
@@ -2217,6 +2299,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBSHORT)"+t)
 			If TULongType( src ) Return Bra("(BBSHORT)"+t)
 			If TSizeTType( src ) Return Bra("(BBSHORT)"+t)
+			If TLongIntType( src ) Return Bra("(BBSHORT)"+t)
+			If TULongIntType( src ) Return Bra("(BBSHORT)"+t)
 			If TWParamType( src ) Return Bra("(BBSHORT)"+t)
 			If TLParamType( src ) Return Bra("(BBSHORT)"+t)
 			If TStringType( src ) Return Bra("(BBSHORT)bbStringToInt" + Bra(t))
@@ -2233,6 +2317,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBUINT)"+t)
 			If TULongType( src ) Return Bra("(BBUINT)"+t)
 			If TSizeTType( src ) Return Bra("(BBUINT)"+t)
+			If TLongIntType( src ) Return Bra("(BBUINT)"+t)
+			If TULongIntType( src ) Return Bra("(BBUINT)"+t)
 			If TWParamType( src ) Return Bra("(BBUINT)"+t)
 			If TLParamType( src ) Return Bra("(BBUINT)"+t)
 			If TStringType( src ) Return "bbStringToUInt" + Bra(t)
@@ -2248,6 +2334,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src ) Return Bra("(BBULONG)"+t)
 			If TULongType( src) Return t
 			If TSizeTType( src ) Return Bra("(BBULONG)"+t)
+			If TLongIntType( src ) Return Bra("(BBULONG)"+t)
+			If TULongIntType( src ) Return Bra("(BBULONG)"+t)
 			If TWParamType( src ) Return Bra("(BBULONG)"+t)
 			If TLParamType( src ) Return Bra("(BBULONG)"+t)
 			If TStringType( src ) Return "bbStringToULong" + Bra(t)
@@ -2279,6 +2367,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src) Return Bra("(WPARAM)"+t)
 			If TULongType( src) Return Bra("(WPARAM)"+t)
 			If TSizeTType( src ) Return Bra("(WPARAM)"+t)
+			If TLongIntType( src) Return Bra("(WPARAM)"+t)
+			If TULongIntType( src) Return Bra("(WPARAM)"+t)
 			If TWParamType( src ) Return t
 			If TLParamType( src ) Return Bra("(WPARAM)"+t)
 			If TFloatType( src ) Return Bra("(WPARAM)"+t)
@@ -2294,6 +2384,8 @@ t:+"NULLNULLNULL"
 			If TLongType( src) Return Bra("(LPARAM)"+t)
 			If TULongType( src) Return Bra("(LPARAM)"+t)
 			If TSizeTType( src ) Return Bra("(LPARAM)"+t)
+			If TLongIntType( src) Return Bra("(LPARAM)"+t)
+			If TULongIntType( src) Return Bra("(LPARAM)"+t)
 			If TWParamType( src ) Return Bra("(LPARAM)"+t)
 			If TLParamType( src ) Return t
 			If TFloatType( src ) Return Bra("(LPARAM)"+t)
@@ -2428,6 +2520,9 @@ t:+"NULLNULLNULL"
 			Else If TLongType(expr.exprType) Then
 				t_lhs = "(unsigned long long)(" + t_lhs + ")"
 				t_rhs = "(unsigned long long)(" + t_rhs + ")"
+			Else If TLongIntType(expr.exprType) Then
+				t_lhs = "(unsigned long)(" + t_lhs + ")"
+				t_rhs = "(unsigned long)(" + t_rhs + ")"
 			End If
 		End If
 

+ 15 - 7
expr.bmx

@@ -266,7 +266,9 @@ Type TExpr
 		If TLongType( lhs ) And TUIntType( rhs ) Return New TULongType
 		If TUIntType( lhs ) And TLongType( rhs ) Return New TULongType
 		If TLParamType( lhs ) Or TLParamType( rhs ) Return New TLParamType
+		If TULongIntType( lhs ) Or TULongIntType( rhs ) Return New TULongIntType
 		If TLongType( lhs ) Or TLongType( rhs ) Return New TLongType
+		If TLongIntType( lhs ) Or TLongIntType( rhs ) Return New TLongIntType
 		If TUIntType( lhs ) Or TUIntType( rhs ) Return New TUIntType
 		If TIntType( lhs ) Or TIntType( rhs ) Return New TIntType
 		If TEnumType( lhs ) Or TEnumType( rhs ) Then
@@ -421,7 +423,7 @@ Type TConstExpr Extends TExpr
 			Return Self
 		End If
 		
-		If TIntType( ty ) Or TShortType( ty ) Or TByteType( ty ) Or TLongType( ty ) Or TUIntType( ty ) Or TULongType( ty ) Or TWParamType(ty) Or TLParamType(ty)
+		If TIntType( ty ) Or TShortType( ty ) Or TByteType( ty ) Or TLongType( ty ) Or TUIntType( ty ) Or TULongType( ty ) Or TWParamType(ty) Or TLParamType(ty) Or TLongIntType(ty) Or TULongIntType(ty)
 			Local radix:Int
 			If value.StartsWith( "%" )
 				radix=1
@@ -566,7 +568,7 @@ Type TConstExpr Extends TExpr
 			Local val:Long = value.ToLong()
 			
 			If val < 0 Then
-				If TByteType(ty) Or TShortType(ty) Or TUIntType(ty) Or TULongType(ty) Or TSizeTType(ty) Or TInt128Type(ty) Or TWParamType(ty) Then
+				If TByteType(ty) Or TShortType(ty) Or TUIntType(ty) Or TULongType(ty) Or TSizeTType(ty) Or TInt128Type(ty) Or TWParamType(ty) or TULongIntType(ty) Then
 					Return False
 				End If
 			Else
@@ -576,13 +578,13 @@ Type TConstExpr Extends TExpr
 					End If
 				End If
 
-				If TUIntType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 4) Then
+				If TUIntType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 4) Or (TULongIntType(ty) And TULongIntType(ty).GetSize() = 4) Then
 					If val > 4294967296:Long Then
 						Return False
 					End If
 				End If
 				
-				If TULongType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 8) Then
+				If TULongType(ty) Or ((TSizeTType(ty) Or TWParamType(ty)) And WORD_SIZE = 8) Or (TULongIntType(ty) And TULongIntType(ty).GetSize() = 8) Then
 					If value.length > 20 Then
 						Return False
 					Else If value.length = 20 Then
@@ -605,13 +607,13 @@ Type TConstExpr Extends TExpr
 				End If
 			End If
 
-			If TIntType(ty) Or (TLParamType(ty) And WORD_SIZE = 4) Then
+			If TIntType(ty) Or (TLParamType(ty) And WORD_SIZE = 4) Or (TLongIntType(ty) And TLongIntType(ty).GetSize() = 4) Then
 				If value <> String.FromInt(Int(val)) Then
 					Return False
 				End If
 			End If
 
-			If TLongType(ty) Or (TLParamType(ty) And WORD_SIZE = 8) Then
+			If TLongType(ty) Or (TLParamType(ty) And WORD_SIZE = 8) Or (TLongIntType(ty) And TLongIntType(ty).GetSize() = 8) Then
 				If value <> String.FromLong(Long(val)) Then
 					Return False
 				End If
@@ -1351,7 +1353,7 @@ Type TCastExpr Extends TExpr
 				' intrinsics can only cast between selves
 				If (TIntrinsicType(src) And TIntrinsicType(ty)=Null) Or (TIntrinsicType(ty) And TIntrinsicType(src)=Null) Then
 					If TFloat64Type(src) Or TFloat64Type(ty) Then
-						If (TFloat64Type(src) And (TLongType(ty) Or TULongType(ty))) Or (TFloat64Type(ty) And (TLongType(src) Or TULongType(src))) Then
+						If (TFloat64Type(src) And (TLongType(ty) Or TULongType(ty) Or (TLongIntType(ty) And TLongIntType(ty).GetSize() = 8) Or (TULongIntType(ty) And TULongIntType(ty).GetSize() = 8))) Or (TFloat64Type(ty) And (TLongType(src) Or TULongType(src) Or (TLongIntType(src) And TLongIntType(src).GetSize() = 8) Or (TULongIntType(src) And TULongIntType(src).GetSize() = 8))) Then
 							' ok
 						Else
 							Err "Unable to convert from "+src.ToString()+" to "+ty.ToString()+"."
@@ -1697,6 +1699,10 @@ Type TCastExpr Extends TExpr
 			Return Long( val )
 		Else If TULongType( exprType )
 			Return Long( val )
+		Else If TLongIntType( exprType )
+			Return Long( val )
+		Else If TULongIntType( exprType )
+			Return Long( val )
 		Else If TSizeTType( exprType )
 			Return Long( val )
 		Else If TInt128Type( exprType )
@@ -1815,6 +1821,8 @@ Type TUnaryExpr Extends TExpr
 		Case "~~"
 			If TIntType(exprType) Return ~Int( val )
 			If TLongType(exprType) Return ~Long( val )
+			If TLongIntType(exprType) Return bmx_bitwise_not_longint( val, TLongIntType(exprType).GetSize() )
+			If TULongIntType(exprType) Return bmx_bitwise_not_ulongint( val, TULongIntType(exprType).GetSize() )
 ?Not bmxng
 			If TUIntType(exprType) Return bmx_bitwise_not_uint( val )
 			If TSizeTType(exprType) Return bmx_bitwise_not_sizet( val )

+ 28 - 0
iparser.bmx

@@ -1539,6 +1539,10 @@ End Rem
 				ty = New TLongType
 			ElseIf CParse("z") Then
 				ty = New TSizetType
+			ElseIf CParse("v") Then
+				ty = New TLongIntType
+			ElseIf CParse("e") Then
+				ty = New TULongIntType
 			ElseIf CParse("j") Then
 				ty = New TInt128Type
 			ElseIf CParse("w") Then
@@ -1823,6 +1827,26 @@ End Rem
 			Wend
 			Return ty
 		End If
+		If CParse( "longint" )
+			Local ty:TType = New TLongType
+			While CParse("ptr")
+				ty = TType.MapToPointerType(ty)
+			Wend
+			While CParse( "*" )
+				ty = TType.MapToPointerType(ty)
+			Wend
+			Return ty
+		End If
+		If CParse( "ulongint" )
+			Local ty:TType = New TULongIntType
+			While CParse("ptr")
+				ty = TType.MapToPointerType(ty)
+			Wend
+			While CParse( "*" )
+				ty = TType.MapToPointerType(ty)
+			Wend
+			Return ty
+		End If
 		If CParse( "double" )
 			Local ty:TType = New TDoubleType
 			While CParse("ptr")
@@ -1943,6 +1967,10 @@ End Rem
 			ty = New TLongType
 		Else If CParse( "ulong" )
 			ty = New TULongType
+		Else If CParse( "longint" )
+			ty = New TLongIntType
+		Else If CParse( "ulongint" )
+			ty = New TULongIntType
 		Else If CParse( "double" )
 			ty = New TDoubleType
 		Else If CParse( "size_t" )

+ 109 - 0
math.c

@@ -154,6 +154,27 @@ BBString * bmx_bitwise_not_ulong(BBString * value) {
 	return bmx_string_from_ulong(~v);
 }
 
+BBString * bmx_bitwise_not_longint(BBString * value, int size) {
+	if (size == 4) {
+		int v = bbStringToInt(value);
+		return bbStringFromInt(~v);
+	} else { // 8
+		BBInt64 v = bbStringToLong(value);
+		return bbStringFromLong(~v);
+	}
+}
+
+BBString * bmx_bitwise_not_ulongint(BBString * value, int size) {
+	if (size == 4) {
+		unsigned int v = bmx_string_to_uint(value);
+		return bmx_string_from_uint(~v);
+	} else { // 8
+		unsigned long long v = bmx_string_to_ulong(value);
+		return bmx_string_from_ulong(~v);
+	}
+}
+
+
 BBString * bmx_binarymathexpr_sizet(enum binaryOps op, BBString * slhs, BBString * srhs) {
 	size_t lhs = bmx_string_to_size_t(slhs);
 	size_t rhs = bmx_string_to_size_t(srhs);
@@ -273,3 +294,91 @@ BBString * bmx_binarymathexpr_ulong(enum binaryOps op, BBString * slhs, BBString
 	}
 	return bmx_string_from_ulong(res);
 }
+
+BBString * bmx_binarymathexpr_longint(enum binaryOps op, BBString * slhs, BBString * srhs, int size) {
+	if (size == 4) {
+		int lhs = bbStringToInt(slhs);
+		int rhs = bbStringToInt(srhs);
+		int res = 0;
+		switch (op) {
+			case OP_MUL:
+				res = lhs * rhs;
+				break;
+			case OP_DIV:
+				res = lhs / rhs;
+				break;
+			case OP_MOD:
+				res = lhs % rhs;
+				break;
+			case OP_SHL:
+				res = lhs << rhs;
+				break;
+			case OP_SHR:
+			case OP_SAR:
+				res = lhs >> rhs;
+				break;
+			case OP_ADD:
+				res = lhs + rhs;
+				break;
+			case OP_SUB:
+				res = lhs - rhs;
+				break;
+			case OP_AND:
+				res = lhs & rhs;
+				break;
+			case OP_XOR:
+				res = lhs ^ rhs;
+				break;
+			case OP_OR:
+				res = lhs | rhs;
+				break;
+		}
+		return bbStringFromInt(res);
+	} else { // 8
+		BBInt64 lhs = bbStringToLong(slhs);
+		BBInt64 rhs = bbStringToLong(srhs);
+		BBInt64 res = 0;
+		switch (op) {
+			case OP_MUL:
+				res = lhs * rhs;
+				break;
+			case OP_DIV:
+				res = lhs / rhs;
+				break;
+			case OP_MOD:
+				res = lhs % rhs;
+				break;
+			case OP_SHL:
+				res = lhs << rhs;
+				break;
+			case OP_SHR:
+			case OP_SAR:
+				res = lhs >> rhs;
+				break;
+			case OP_ADD:
+				res = lhs + rhs;
+				break;
+			case OP_SUB:
+				res = lhs - rhs;
+				break;
+			case OP_AND:
+				res = lhs & rhs;
+				break;
+			case OP_XOR:
+				res = lhs ^ rhs;
+				break;
+			case OP_OR:
+				res = lhs | rhs;
+				break;
+		}
+		return bbStringFromLong(res);
+	}
+}
+
+BBString * bmx_binarymathexpr_ulongint(enum binaryOps op, BBString * slhs, BBString * srhs, int size) {
+	if (size == 4) {
+		return bmx_binarymathexpr_uint(op, slhs, srhs);
+	} else { // 8
+		return bmx_binarymathexpr_ulong(op, slhs, srhs);
+	}
+}

+ 1 - 1
options.bmx

@@ -25,7 +25,7 @@ SuperStrict
 
 Import "base.configmap.bmx"
 
-Const version:String = "0.133"
+Const version:String = "0.134"
 
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_MODULE:Int = 1

+ 13 - 1
parser.bmx

@@ -739,6 +739,10 @@ Type TParser Extends TGenProcessor
 			ty = New TLongType
 		Else If CParse( "ulong" )
 			ty = New TULongType
+		Else If CParse( "longint" )
+			ty = New TLongIntType
+		Else If CParse( "ulongint" )
+			ty = New TULongIntType
 		Else If CParse( "double" )
 			ty = New TDoubleType
 		Else If CParse( "size_t" )
@@ -777,6 +781,8 @@ Type TParser Extends TGenProcessor
 		If CParse( "float" ) Return New TFloatType
 		If CParse( "long" ) Return New TLongType
 		If CParse( "ulong" ) Return New TULongType
+		If CParse( "longint" ) Return New TLongIntType
+		If CParse( "ulongint" ) Return New TULongIntType
 		If CParse( "double" ) Return New TDoubleType
 		If CParse( "size_t" ) Return New TSizeTType
 		If CParse( "int128" ) Then
@@ -816,6 +822,8 @@ Type TParser Extends TGenProcessor
 		If CParse( "object" ) Return New TIdentType.Create( "brl.classes.object" )
 		If CParse( "long" ) Return New TLongType
 		If CParse( "ulong" ) Return New TULongType
+		If CParse( "longint" ) Return New TLongIntType
+		If CParse( "ulongint" ) Return New TULongIntType
 		If CParse( "double" ) Return New TDoubleType
 		If CParse( "size_t" ) Return New TSizeTType
 		If CParse( "int128" ) Then
@@ -1306,7 +1314,7 @@ Type TParser Extends TGenProcessor
 		Case "false"
 			NextToke
 			expr=New TConstExpr.Create( New TIntType,"" )
-		Case "int","long","float","double","object","short","byte","size_t","uint","ulong","int128","float64","float128","double128","lparam","wparam","string"
+		Case "int","long","float","double","object","short","byte","size_t","uint","ulong","longint","ulongint","int128","float64","float128","double128","lparam","wparam","string"
 			Local id$=_toke
 			Local ty:TType=ParseType()
 
@@ -1322,6 +1330,10 @@ Type TParser Extends TGenProcessor
 						ty = New TLongType
 					Case "ulong"
 						ty = New TULongType
+					Case "longint"
+						ty = New TLongIntType
+					Case "ulongint"
+						ty = New TULongIntType
 					Case "float"
 						ty = New TFloatType
 					Case "double"

+ 1 - 1
toker.bmx

@@ -51,7 +51,7 @@ Type TToker
 		"next,return,alias,rem,endrem,throw,assert,try,catch,finally,nodebug,incbin,endselect,endmethod," + ..
 		"endfunction,endtype,endextern,endtry,endwhile,pi,release,defdata,readdata,restoredata,interface," + ..
 		"endinterface,implements,size_t,uint,ulong,struct,endstruct,operator,where,readonly,export,override," + ..
-		"enum,endenum,stackalloc,inline,fieldoffset,staticarray,threadedglobal"
+		"enum,endenum,stackalloc,inline,fieldoffset,staticarray,threadedglobal,longint,ulongint"
 	Global _keywords:TMap
 
 	Field _path$

+ 198 - 0
type.bmx

@@ -219,6 +219,8 @@ Type TType
 	Const T_LPARAM:Int      =$10000
 	Const T_WPARAM:Int      =$20000
 	Const T_ENUM:Int        =$40000
+	Const T_LONGINT:Int     =$80000
+	Const T_ULONGINT:Int    =$100000
 
 	Const T_MAX_DISTANCE:Int = $FFFF
 
@@ -299,6 +301,10 @@ Function NewType:TType(kind:Int = 0)
 			ty = New TFunctionPtrType
 		Case TType.T_ENUM
 			ty = New TEnumType
+		Case TType.T_LONGINT
+			ty = New TLongIntType
+		Case TType.T_ULONGINT
+			ty = New TULongIntType
 		Default
 			Err "Don't have a pointer type for " + kind
 	End Select
@@ -366,6 +372,10 @@ Function IsType:Int(ty:TType, kind:Int)
 			Return TFunctionPtrType(ty) <> Null
 		Case TType.T_ENUM
 			Return TEnumType(ty) <> Null
+		Case TType.T_LONGINT
+			Return TLongIntType(ty) <> Null
+		Case TType.T_ULONGINT
+			Return TULongIntType(ty) <> Null
 	End Select
 
 	Return False
@@ -1043,6 +1053,194 @@ Type TULongType Extends TIntegralType
 	End Method
 End Type
 
+Type TLongIntType Extends TIntegralType
+	
+	Method EqualsType:Int( ty:TType )
+		Return TLongIntType( 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 (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) Or (WORD_SIZE=4 And TLParamType(ty)<>Null)
+	End Method
+
+	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 Or (WORD_SIZE=8 And TLParamType(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 TLongIntType(ty)<>Null Then
+			Return 0
+		End If
+
+		Local longIntSize:Int = GetSize()
+
+		If longIntSize = 4 And TIntType(ty)<>Null Then
+			Return 1
+		End If
+
+		If longIntSize = 4 And TLParamType(ty)<>Null Then
+			Return 1
+		End If
+		
+		If longIntSize = 4 And TLongType(ty)<>Null Then
+			Return 2
+		End If
+
+		If longIntSize = 8 And TLParamType(ty)<>Null Then
+			Return 3
+		End If
+
+		If longIntSize = 8 And TIntType(ty)<>Null Then
+			Return 2
+		End If
+
+		If longIntSize = 8 And TLongType(ty)<>Null Then
+			Return 1
+		End If
+
+		If TFloatType(ty)<>Null Then
+			Return 4
+		End If
+
+		If TDoubleType(ty)<>Null Then
+			Return 6
+		End If
+		
+		Return T_MAX_DISTANCE
+	End Method
+	
+	Method OnCopy:TType()
+		Return New TLongIntType
+	End Method
+
+	Method ToString$()
+		Return "LongInt" + ToStringParts()
+	End Method
+
+	Method GetSize:Int()
+		If WORD_SIZE = 4 Then
+			Return 4
+		Else
+			If opt_platform = "linux" or opt_platform = "macos" Then
+				Return 8
+			Else
+				Return 4
+			End If
+		End If
+	End Method
+
+End Type
+
+Type TULongIntType Extends TIntegralType
+	
+	Method EqualsType:Int( ty:TType )
+		Return TULongIntType( 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 (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) Or (WORD_SIZE=4 And TLParamType(ty)<>Null)
+	End Method
+
+	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 Or (WORD_SIZE=8 And TLParamType(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 TULongIntType(ty)<>Null Then
+			Return 0
+		End If
+
+		Local longIntSize:Int = GetSize()
+
+		If longIntSize = 4 And TIntType(ty)<>Null Then
+			Return 2
+		End If
+
+		If longIntSize = 4 And TUIntType(ty)<>Null Then
+			Return 1
+		End If
+
+		If longIntSize = 4 And TLParamType(ty)<>Null Then
+			Return 3
+		End If
+		
+		If longIntSize = 4 And TLongType(ty)<>Null Then
+			Return 4
+		End If
+
+		If longIntSize = 8 And TLParamType(ty)<>Null Then
+			Return 3
+		End If
+
+		If longIntSize = 8 And TIntType(ty)<>Null Then
+			Return 4
+		End If
+
+		If longIntSize = 8 And TUIntType(ty)<>Null Then
+			Return 3
+		End If
+
+		If longIntSize = 8 And TLongType(ty)<>Null Then
+			Return 1
+		End If
+
+		If longIntSize = 8 And TULongType(ty)<>Null Then
+			Return 2
+		End If
+
+		If TFloatType(ty)<>Null Then
+			Return 5
+		End If
+
+		If TDoubleType(ty)<>Null Then
+			Return 6
+		End If
+		
+		Return T_MAX_DISTANCE
+	End Method
+	
+	Method OnCopy:TType()
+		Return New TULongIntType
+	End Method
+
+	Method ToString$()
+		Return "ULongInt" + ToStringParts()
+	End Method
+
+	Method GetSize:Int()
+		If WORD_SIZE = 4 Then
+			Return 4
+		Else
+			If opt_platform = "linux" or opt_platform = "macos" Then
+				Return 8
+			Else
+				Return 4
+			End If
+		End If
+	End Method
+
+End Type
+
 Type TDecimalType Extends TNumericType
 End Type