Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalOrNode.java @ 13821:b16ec83edc73
Documentation and more refactoring of Simple Language
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 29 Jan 2014 20:45:43 -0800 |
parents | 7c418666c6c9 |
children | 64c77f0577bb |
comparison
equal
deleted
inserted
replaced
13820:20e7727588e8 | 13821:b16ec83edc73 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.nodes.expression; | 23 package com.oracle.truffle.sl.nodes.expression; |
24 | 24 |
25 import com.oracle.truffle.api.dsl.*; | 25 import com.oracle.truffle.api.dsl.*; |
26 import com.oracle.truffle.api.nodes.*; | |
26 import com.oracle.truffle.sl.nodes.*; | 27 import com.oracle.truffle.sl.nodes.*; |
27 | 28 |
29 @NodeInfo(shortName = "||") | |
28 @SuppressWarnings("unused") | 30 @SuppressWarnings("unused") |
29 public abstract class SLLogicalOrNode extends SLBinaryNode { | 31 public abstract class SLLogicalOrNode extends SLBinaryNode { |
30 | 32 |
31 @ShortCircuit("rightNode") | 33 @ShortCircuit("rightNode") |
32 public boolean needsRightNode(boolean left) { | 34 protected boolean needsRightNode(boolean left) { |
33 return !left; | 35 return !left; |
34 } | 36 } |
35 | 37 |
36 @ShortCircuit("rightNode") | 38 @ShortCircuit("rightNode") |
37 public boolean needsRightNode(Object left) { | 39 protected boolean needsRightNode(Object left) { |
38 return left instanceof Boolean && needsRightNode(((Boolean) left).booleanValue()); | 40 return left instanceof Boolean && needsRightNode(((Boolean) left).booleanValue()); |
39 } | 41 } |
40 | 42 |
41 @Specialization | 43 @Specialization |
42 public boolean doBoolean(boolean left, boolean hasRight, boolean right) { | 44 protected boolean doBoolean(boolean left, boolean hasRight, boolean right) { |
43 return left || right; | 45 return left || right; |
44 } | 46 } |
45 | |
46 @Generic | |
47 public Object doGeneric(Object left, boolean hasRight, Object right) { | |
48 throw new RuntimeException("operation not defined for type " + left.getClass().getSimpleName()); | |
49 } | |
50 } | 47 } |