[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / docs / ecma334 / 18.4.2.xml
1 <?xml version="1.0"?>
2 <clause number="18.4.2" title="Database boolean type" informative="true">
3   <paragraph>The DBBool struct below implements a three-valued logical type. The possible values of this type are DBBool.True, DBBool.False, and DBBool.Null, where the Null member indicates an unknown value. Such three-valued logical types are commonly used in databases. <code_example><![CDATA[
4 using System;  
5 public struct DBBool  
6 {  
7    // The three possible DBBool values.  
8    public static readonly DBBool Null = new DBBool(0);  
9    public static readonly DBBool False = new DBBool(-1);  
10    public static readonly DBBool True = new DBBool(1);  
11    // Private field that stores -1, 0, 1 for False, Null, True.  
12    sbyte value;  
13    // Private instance constructor. The value parameter must be -1, 0, or 1.  
14    
15    DBBool(int value) {  
16       this.value = (sbyte)value;  
17    }  
18    // Properties to examine the value of a DBBool. Return true if this  
19    // DBBool has the given value, false otherwise.  
20    public bool IsNull { get { return value == 0; } }  
21    public bool IsFalse { get { return value < 0; } }  
22    public bool IsTrue { get { return value > 0; } }  
23    // Implicit conversion from bool to DBBool. Maps true to DBBool.True  
24    
25    // and false to DBBool.False.  
26    public static implicit operator DBBool(bool x) {  
27       return x? True: False;  
28    }  
29    // Explicit conversion from DBBool to bool. Throws an exception if the  
30    // given DBBool is Null, otherwise returns true or false.  
31    public static explicit operator bool(DBBool x) {  
32       if (x.value == 0) throw new InvalidOperationException();  
33       return x.value > 0;  
34    }  
35    // Equality operator. Returns Null if either operand is Null,  
36    
37    // otherwise returns True or False.  
38    public static DBBool operator ==(DBBool x, DBBool y) {  
39       if (x.value == 0 || y.value == 0) return Null;  
40       return x.value == y.value? True: False;  
41    }  
42    // Inequality operator. Returns Null if either operand is Null,  
43    
44    // otherwise returns True or False.  
45    public static DBBool operator !=(DBBool x, DBBool y) {  
46       if (x.value == 0 || y.value == 0) return Null;  
47       return x.value != y.value? True: False;  
48    }  
49    // Logical negation operator. Returns True if the operand is False,  
50    
51    // Null if the operand is Null, or False if the operand is True.  
52    public static DBBool operator !(DBBool x) {  
53       return new DBBool(-x.value);  
54    }  
55    // Logical AND operator. Returns False if either operand is False,  
56    // otherwise Null if either operand is Null, otherwise True.  
57    public static DBBool operator &(DBBool x, DBBool y) {  
58       return new DBBool(x.value < y.value? x.value: y.value);  
59    }  
60    // Logical OR operator. Returns True if either operand is True,  
61    
62    // otherwise Null if either operand is Null, otherwise False.  
63    public static DBBool operator |(DBBool x, DBBool y) {  
64       return new DBBool(x.value > y.value? x.value: y.value);  
65    }  
66    // Definitely true operator. Returns true if the operand is True,  
67    
68    // false otherwise.  
69    public static bool operator true(DBBool x) {  
70       return x.value > 0;  
71    }  
72    // Definitely false operator. Returns true if the operand is False,  
73    
74    // false otherwise.  
75    public static bool operator false(DBBool x) {  
76       return x.value < 0;  
77    }  
78 }  
79 ]]></code_example></paragraph>
80   <paragraph>End of informative text. </paragraph>
81 </clause>