1 /*
2 * ASBinaryExpression.java
3 *
4 * Copyright (c) 2008 David Holroyd
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package uk.co.badgersinfoil.metaas.dom;
20
21 import uk.co.badgersinfoil.metaas.ActionScriptFactory;
22
23 /**
24 * A binary expression, such as <code>a + b</code> or <code>a && b</code>.
25 *
26 * @see ActionScriptFactory#newAddExpression(Expression, Expression)
27 * @see ActionScriptFactory#newAndExpression(Expression, Expression)
28 * @see ActionScriptFactory#newBitAndExpression(Expression, Expression)
29 * @see ActionScriptFactory#newBitOrExpression(Expression, Expression)
30 * @see ActionScriptFactory#newBitXorExpression(Expression, Expression)
31 * @see ActionScriptFactory#newDivisionExpression(Expression, Expression)
32 * @see ActionScriptFactory#newEqualsExpression(Expression, Expression)
33 * @see ActionScriptFactory#newGreaterEqualsExpression(Expression, Expression)
34 * @see ActionScriptFactory#newGreaterThanExpression(Expression, Expression)
35 * @see ActionScriptFactory#newLessEqualsExpression(Expression, Expression)
36 * @see ActionScriptFactory#newLessThanExpression(Expression, Expression)
37 * @see ActionScriptFactory#newModuloExpression(Expression, Expression)
38 * @see ActionScriptFactory#newMultiplyExpression(Expression, Expression)
39 * @see ActionScriptFactory#newNotEqualsExpression(Expression, Expression)
40 * @see ActionScriptFactory#newOrExpression(Expression, Expression)
41 * @see ActionScriptFactory#newShiftLeftExpression(Expression, Expression)
42 * @see ActionScriptFactory#newShiftRightExpression(Expression, Expression)
43 * @see ActionScriptFactory#newShiftRightUnsignedExpression(Expression, Expression)
44 * @see ActionScriptFactory#newSubtractExpression(Expression, Expression)
45 */
46 public interface ASBinaryExpression extends Expression {
47 public Op getOperator();
48 public void setOperator(Op operator);
49 public Expression getLeftSubexpression();
50 public void setLeftSubexpression(Expression left);
51 public Expression getRightSubexpression();
52 public void setRightSubexpression(Expression right);
53
54 /**
55 * Operators allowed for binary-expressions
56 */
57 public static class Op {
58 private String name;
59 private Op(String name) {
60 this.name = name;
61 }
62
63 /** Addition '+' */
64 public static final Op ADD = new Op("ADD");
65 /** Logical and '&&' */
66 public static final Op AND = new Op("AND");
67 /** Bit-wise and '&' */
68 public static final Op BITAND = new Op("BITAND");
69 /** Bit-wise or '|' */
70 public static final Op BITOR = new Op("BITOR");
71 /** Bit-wise xor '^' */
72 public static final Op BITXOR = new Op("BITXOR");
73 /** Division '/' */
74 public static final Op DIV = new Op("DIV");
75 /** Equality '==' */
76 public static final Op EQ = new Op("EQ");
77 /** Greater-than-or-equals '>=' */
78 public static final Op GE = new Op("GE");
79 /** Strictly greater-than '>' */
80 public static final Op GT = new Op("GT");
81 /** Less-than-or-equals '<=' */
82 public static final Op LE = new Op("LE");
83 /** Strictly less-than '<' */
84 public static final Op LT = new Op("LT");
85 /** Modulo '%' */
86 public static final Op MOD = new Op("MOD");
87 /** Multiplication '*' */
88 public static final Op MUL = new Op("MUL");
89 /** Not equal '!=' */
90 public static final Op NE = new Op("NE");
91 /** Logical or '||' */
92 public static final Op OR = new Op("OR");
93 /** Shift left '<<' */
94 public static final Op SL = new Op("SL");
95 /** Shift right '>>' */
96 public static final Op SR = new Op("SR");
97 /** Shift right, unsigned '>>>' */
98 public static final Op SRU = new Op("SRU");
99 /** Subtraction '-' */
100 public static final Op SUB = new Op("SUB");
101
102 public String toString() {
103 return name;
104 }
105 }
106 }