PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/at2-build190607/src/edu/vub/at/objects/ATBoolean.java

http://ambienttalk.googlecode.com/
Java | 141 lines | 12 code | 11 blank | 118 comment | 0 complexity | 458067b5a20b08e3cbd9acfee0d0e235 MD5 | raw file
  1/**
  2 * AmbientTalk/2 Project
  3 * ATBoolean.java created on Jul 26, 2006 at 9:53:31 PM
  4 * (c) Programming Technology Lab, 2006 - 2007
  5 * Authors: Tom Van Cutsem & Stijn Mostinckx
  6 * 
  7 * Permission is hereby granted, free of charge, to any person
  8 * obtaining a copy of this software and associated documentation
  9 * files (the "Software"), to deal in the Software without
 10 * restriction, including without limitation the rights to use,
 11 * copy, modify, merge, publish, distribute, sublicense, and/or
 12 * sell copies of the Software, and to permit persons to whom the
 13 * Software is furnished to do so, subject to the following
 14 * conditions:
 15 *
 16 * The above copyright notice and this permission notice shall be
 17 * included in all copies or substantial portions of the Software.
 18 *
 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 26 * OTHER DEALINGS IN THE SOFTWARE.
 27 */
 28package edu.vub.at.objects;
 29
 30import edu.vub.at.exceptions.InterpreterException;
 31
 32/**
 33 * The ATBoolean represents the public interface of a boolean object.
 34 * 
 35 * @author smostinc
 36 * @author tvcutsem
 37 */
 38public interface ATBoolean extends ATObject {
 39
 40	/**
 41	 * Returns an ATObject representing the result of evaluating the code to execute
 42	 * if the boolean condition is true. Returns nil if the boolean expression is false.
 43	 * <p>
 44	 * Usage:
 45	 * <code>booleanCondition.ifTrue: { code }</code>
 46	 *  
 47	 * @param a closure containing the code to execute if the boolean is true.
 48	 * @return the result of evaluating the closure or nil.
 49	 * @throws InterpreterException if raised in the evaluation of the closure. 
 50	 */
 51	public ATObject base_ifTrue_(ATClosure clo) throws InterpreterException;
 52	
 53	/**
 54	 * Returns an {@link ATObject} representing the result of evaluating the code to execute
 55	 * if the boolean condition is false. Returns nil if the boolean expression is true.
 56	 * <p>
 57	 * Usage:
 58	 * <code>booleanCondition.ifFalse: { code } </code>
 59	 *  
 60	 * @param a closure containing the code to execute if the boolean is false.
 61	 * @return the result of evaluating the closure or nil.
 62	 * @throws InterpreterException if raised in the evaluation of the closure. 
 63	 */
 64	public ATObject base_ifFalse_(ATClosure alt) throws InterpreterException;
 65	
 66	/**
 67	 * Returns an {@link ATObject} representing the result of evaluating either the code to execute
 68	 * if the boolean condition is false or the one to execute if the boolean condition is true.
 69	 * <p>
 70	 * Usage:
 71	 * <code>booleanCondition.ifTrue: { consequent } ifFalse: { alternative } </code>
 72	 *  
 73	 * @param consequent a closure containing the code to execute if the boolean is true.
 74	 * @param alternative a closure containing the code to execute if the boolean is false.
 75	 * @return the result of the consequent or alternative closure. 
 76	 * @throws InterpreterException if raised in the evaluation of the consequent or alternative closure. 
 77	 */	
 78	public ATObject base_ifTrue_ifFalse_(ATClosure cons, ATClosure alt) throws InterpreterException;
 79	
 80	/**
 81	 * And infix operator. Returns: 
 82	 * <ul>
 83	 * <li>true & otherBoolean = otherBoolean
 84	 * <li>false & otherBoolean = false
 85	 * </ul>
 86	 * <p>
 87	 * This is not a shortcut operation, thus the other boolean is always evaluated.
 88	 * 
 89	 * @param other a boolean.
 90	 * @return a boolean resulting of an and operation between the receiver and the result of evaluating the other boolean. 
 91	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
 92	 */	
 93	public ATBoolean base__opand_(ATBoolean other) throws InterpreterException;
 94	
 95	/**
 96	 * Or infix operator. Returns: 
 97	 * <ul>
 98	 * <li>true | otherBoolean = true
 99	 * <li>false | otherBoolean =  otherBoolean
100	 * </ul>
101	 * <p>
102	 * This is not a shortcut operation, thus the other boolean is always evaluated.
103	 * 
104	 * @param other a boolean.
105	 * @return a boolean resulting of an or operation between the receiver and the result of evaluating the other boolean. 
106	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
107	 */	
108	public ATBoolean base__oppls_(ATBoolean other) throws InterpreterException;
109	
110	/**
111	 * Returns false if the receiver is false or the result of the evaluation of the other
112	 * boolean expression passed as argument if the receiver is true.
113	 * <p>
114	 * Usage: <code>boolean.and: { other }</code>
115	 *  
116	 * @param other a closure whose evaluation returns a boolean.
117	 * @return false or the result of evaluating the other boolean. 
118	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
119	 */
120	public ATBoolean base_and_(ATClosure other) throws InterpreterException;
121	
122	/**
123	 * Returns true if the receiver is true or the result of the evaluation of the other
124	 * boolean expression passed as argument if the receiver is false.
125	 * <p>
126	 * Usage: <code>boolean.or: { other }</code>
127	 *  
128	 * @param other a closure whose evaluation returns a boolean.
129	 * @return true or the result of evaluating the other boolean. 
130	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
131	 */
132	public ATBoolean base_or_(ATClosure other) throws InterpreterException;
133	
134	/**
135	 * Returns true if the receiver is false or false if the receiver is true.
136	 *  
137	 * @return a boolean resulting of the negation of the receiver. 
138	 */
139	public ATBoolean base_not() throws InterpreterException;
140	
141}