01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.java.expression.operator;
12:
13: import de.uka.ilkd.key.java.Expression;
14: import de.uka.ilkd.key.java.PrettyPrinter;
15: import de.uka.ilkd.key.java.Services;
16: import de.uka.ilkd.key.java.abstraction.KeYJavaType;
17: import de.uka.ilkd.key.java.expression.Operator;
18: import de.uka.ilkd.key.java.reference.ExecutionContext;
19: import de.uka.ilkd.key.java.visitor.Visitor;
20: import de.uka.ilkd.key.util.ExtList;
21:
22: /**
23: * Negative.
24: */
25:
26: public class Negative extends Operator {
27:
28: /**
29: * Negative.
30: * @param children an ExtList with all children of this node
31: * the first children in list will be the one on the left
32: * side, the second the one on the right side.
33: */
34:
35: public Negative(ExtList children) {
36: super (children);
37: }
38:
39: public Negative(Expression expr) {
40: super (expr);
41: }
42:
43: /**
44: * Get arity.
45: * @return the int value.
46: */
47:
48: public int getArity() {
49: return 1;
50: }
51:
52: /**
53: * Get precedence.
54: * @return the int value.
55: */
56:
57: public int getPrecedence() {
58: return 1;
59: }
60:
61: /**
62: * Get notation.
63: * @return the int value.
64: */
65:
66: public int getNotation() {
67: return PREFIX;
68: }
69:
70: /**
71: * Checks if this operator is left or right associative. Ordinary
72: * unary operators are right associative.
73: * @return <CODE>true</CODE>, if the operator is left associative,
74: * <CODE>false</CODE> otherwise.
75: */
76:
77: public boolean isLeftAssociative() {
78: return false;
79: }
80:
81: /** calls the corresponding method of a visitor in order to
82: * perform some action/transformation on this element
83: * @param v the Visitor
84: */
85: public void visit(Visitor v) {
86: v.performActionOnNegative(this );
87: }
88:
89: public void prettyPrint(PrettyPrinter p) throws java.io.IOException {
90: p.printNegative(this );
91: }
92:
93: public KeYJavaType getKeYJavaType(Services services,
94: ExecutionContext ec) {
95: return services.getTypeConverter().getPromotedType(
96: getExpressionAt(0).getKeYJavaType(services, ec));
97: }
98:
99: }
|