01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.js.ast;
17:
18: /**
19: * A JavaScript unary operator.
20: */
21: public final class JsUnaryOperator extends JsOperator {
22: // Precedence indices from "JavaScript - The Definitive Guide" 4th Edition
23: // (page 57)
24: //
25:
26: public static final JsUnaryOperator BIT_NOT = create("~", 14,
27: PREFIX);
28: public static final JsUnaryOperator NEG = create("-", 14, PREFIX);
29: public static final JsUnaryOperator NOT = create("!", 14, PREFIX);
30: public static final JsUnaryOperator DEC = create("--", 14, POSTFIX
31: | PREFIX);
32: public static final JsUnaryOperator INC = create("++", 14, POSTFIX
33: | PREFIX);
34: public static final JsUnaryOperator DELETE = create("delete", 14,
35: PREFIX);
36: public static final JsUnaryOperator TYPEOF = create("typeof", 14,
37: PREFIX);
38: public static final JsUnaryOperator VOID = create("void", 14,
39: PREFIX);
40:
41: private static JsUnaryOperator create(String symbol,
42: int precedence, int mask) {
43: JsUnaryOperator op = new JsUnaryOperator(symbol, precedence,
44: mask);
45: return op;
46: }
47:
48: private JsUnaryOperator(String symbol, int precedence, int mask) {
49: super (symbol, precedence, mask);
50: }
51:
52: @Override
53: public boolean isKeyword() {
54: return this == DELETE || this == TYPEOF || this == VOID;
55: }
56:
57: public boolean isModifying() {
58: return this == DEC || this == INC || this == DELETE;
59: }
60: }
|