KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > js > ast > JsUnaryOperator


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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, PREFIX);
27   public static final JsUnaryOperator NEG = create("-", 14, PREFIX);
28   public static final JsUnaryOperator NOT = create("!", 14, PREFIX);
29   public static final JsUnaryOperator DEC = create("--", 14, POSTFIX | PREFIX);
30   public static final JsUnaryOperator INC = create("++", 14, POSTFIX | PREFIX);
31   public static final JsUnaryOperator DELETE = create("delete", 14, PREFIX);
32   public static final JsUnaryOperator TYPEOF = create("typeof", 14, PREFIX);
33   public static final JsUnaryOperator VOID = create("void", 14, PREFIX);
34
35   private static JsUnaryOperator create(String JavaDoc symbol, int precedence, int mask) {
36     JsUnaryOperator op = new JsUnaryOperator(symbol, precedence, mask);
37     return op;
38   }
39
40   private JsUnaryOperator(String JavaDoc symbol, int precedence, int mask) {
41     super(symbol, precedence, mask);
42   }
43
44   public boolean isKeyword() {
45     return this == DELETE || this == TYPEOF || this == VOID;
46   }
47
48   public boolean isModifying() {
49     return this == DEC || this == INC || this == DELETE;
50   }
51 }
52
Popular Tags