Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/NestedBooleanOptionValue.java @ 21751:1524f4f7894d
fix rethrowException flag in exception dispatch state
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Fri, 05 Jun 2015 17:59:05 +0200 |
parents | b1530a6cce8c |
children |
rev | line source |
---|---|
19649
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
1 /* |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
4 * |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
8 * |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
14 * |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
18 * |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
21 * questions. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
22 */ |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19649
diff
changeset
|
23 package com.oracle.jvmci.options; |
19649
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
24 |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
25 /** |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
26 * A nested Boolean {@link OptionValue} that can be overridden by a {@link #masterOption master |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
27 * option}. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
28 * <p> |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
29 * <li>If the option is present on the command line the specified value is used. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
30 * <li>Otherwise {@link #getValue()} depends on the {@link #masterOption} and evaluates as follows: |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
31 * <ul> |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
32 * <li>If {@link #masterOption} is set, this value equals to {@link #initialValue}. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
33 * <li>Otherwise, if {@link #masterOption} is {@code false}, this option is {@code false}. |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
34 */ |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
35 public class NestedBooleanOptionValue extends OptionValue<Boolean> { |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
36 private final OptionValue<Boolean> masterOption; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
37 private final Boolean initialValue; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
38 |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
39 public NestedBooleanOptionValue(OptionValue<Boolean> masterOption, Boolean initialValue) { |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
40 super(null); |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
41 this.masterOption = masterOption; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
42 this.initialValue = initialValue; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
43 } |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
44 |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
45 public OptionValue<Boolean> getMasterOption() { |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
46 return masterOption; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
47 } |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
48 |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
49 @Override |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
50 public Boolean getValue() { |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
51 Boolean v = super.getValue(); |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
52 if (v == null) { |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
53 return initialValue && masterOption.getValue(); |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
54 } |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
55 return v; |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
56 } |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
57 |
4726801eedfc
Introduce NestedBooleanOptionValue.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
58 } |