Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: compiler/java/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java

Issue 9479013: Remove backends. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 package com.google.dart.compiler.backend.js.ast;
6
7 /**
8 * A JavaScript prefix operation.
9 */
10 public final class JsPrefixOperation extends JsUnaryOperation implements CanBool eanEval {
11
12 public JsPrefixOperation(JsUnaryOperator op) {
13 this(op, null);
14 }
15
16 public JsPrefixOperation(JsUnaryOperator op, JsExpression arg) {
17 super(op, arg);
18 }
19
20 @Override
21 public boolean isBooleanFalse() {
22 if (getOperator() == JsUnaryOperator.VOID) {
23 return true;
24 }
25 if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEv al) {
26 CanBooleanEval eval = (CanBooleanEval) getArg();
27 return eval.isBooleanTrue();
28 }
29 return false;
30 }
31
32 @Override
33 public boolean isBooleanTrue() {
34 if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEv al) {
35 CanBooleanEval eval = (CanBooleanEval) getArg();
36 return eval.isBooleanFalse();
37 }
38 if (getOperator() == JsUnaryOperator.TYPEOF) {
39 return true;
40 }
41 return false;
42 }
43
44 @Override
45 public boolean isDefinitelyNotNull() {
46 if (getOperator() == JsUnaryOperator.TYPEOF) {
47 return true;
48 }
49 return getOperator() != JsUnaryOperator.VOID;
50 }
51
52 @Override
53 public boolean isDefinitelyNull() {
54 return getOperator() == JsUnaryOperator.VOID;
55 }
56
57 @Override
58 public void traverse(JsVisitor v, JsContext ctx) {
59 if (v.visit(this, ctx)) {
60 super.traverse(v, ctx);
61 }
62 v.endVisit(this, ctx);
63 }
64
65 @Override
66 public NodeKind getKind() {
67 return NodeKind.PREFIX_OP;
68 }
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698