瀏覽代碼

Changed Min/Max keywords into Functions.

woollybah 6 年之前
父節點
當前提交
0b65b4a59e
共有 2 個文件被更改,包括 184 次插入12 次删除
  1. 2 12
      blitz.mod/blitz.bmx
  2. 182 0
      blitz.mod/builtin.bmx

+ 2 - 12
blitz.mod/blitz.bmx

@@ -155,6 +155,8 @@ Import "blitz_nx.c"
 ?
 Import "tree/tree.c"
 
+Include "builtin.bmx"
+
 Extern
 Global OnDebugStop()="bbOnDebugStop"
 Global OnDebugLog( message$ )="bbOnDebugLog"
@@ -1056,18 +1058,6 @@ bbdoc: Numeric 'sign' unary operator
 keyword: "Sgn"
 End Rem
 
-Rem
-bbdoc: Numeric 'minimum' builtin function
-returns: The lesser of the two numeric arguments
-keyword: "Min"
-End Rem
-
-Rem
-bbdoc: Numeric 'maximum' builtin function
-returns: The larger of the two numeric arguments
-keyword: "Max"
-End Rem
-
 Rem
 bbdoc: Find the address of a variable
 keyword: "Varptr"

+ 182 - 0
blitz.mod/builtin.bmx

@@ -0,0 +1,182 @@
+
+Rem
+bbdoc: Returns the larger of the two #Int arguments.
+End Rem
+Function Max:Int(a:Int, b:Int)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Long arguments.
+End Rem
+Function Max:Long(a:Long, b:Long)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Float arguments.
+End Rem
+Function Max:Float(a:Float, b:Float)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Double arguments.
+End Rem
+Function Max:Double(a:Double, b:Double)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Byte arguments.
+End Rem
+Function Max:Byte(a:Byte, b:Byte)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Short arguments.
+End Rem
+Function Max:Short(a:Short, b:Short)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #UInt arguments.
+End Rem
+Function Max:UInt(a:UInt, b:UInt)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #ULong arguments.
+End Rem
+Function Max:ULong(a:ULong, b:ULong)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the larger of the two #Size_T arguments.
+End Rem
+Function Max:Size_T(a:Size_T, b:Size_T)
+	If a < b Then
+		Return b
+	End If
+	Return a
+End Function
+
+
+
+Rem
+bbdoc: Returns the lesser of the two #Int arguments.
+End Rem
+Function Min:Int(a:Int, b:Int)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Long arguments.
+End Rem
+Function Min:Long(a:Long, b:Long)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Float arguments.
+End Rem
+Function Min:Float(a:Float, b:Float)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Double arguments.
+End Rem
+Function Min:Double(a:Double, b:Double)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Byte arguments.
+End Rem
+Function Min:Byte(a:Byte, b:Byte)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Short arguments.
+End Rem
+Function Min:Short(a:Short, b:Short)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #UInt arguments.
+End Rem
+Function Min:UInt(a:UInt, b:UInt)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #ULong arguments.
+End Rem
+Function Min:ULong(a:ULong, b:ULong)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function
+
+Rem
+bbdoc: Returns the lesser of the two #Size_T arguments.
+End Rem
+Function Min:Size_T(a:Size_T, b:Size_T)
+	If a > b Then
+		Return b
+	End If
+	Return a
+End Function