blob: 2d955b71887b4b0315a041d85589b8b70728d7c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*******************************************************************************
* Copyright (c) 2015, 2016 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
package org.eclipse.qvtd.compiler.internal.qvtp2qvts.impl;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.NodeRole;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.RegionUtil;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.Role;
public class NodeRoleImpl extends AbstractRoleImpl implements NodeRole
{
private static final @NonNull NodeRole CONSTANT_NODE = new NodeRoleImpl(Role.Phase.CONSTANT);
private static final @NonNull NodeRole LOADED_NODE = new NodeRoleImpl(Role.Phase.LOADED);
private static final @NonNull NodeRole PREDICATED_NODE = new NodeRoleImpl(Role.Phase.PREDICATED);
private static final @NonNull NodeRole REALIZED_NODE = new NodeRoleImpl(Role.Phase.REALIZED);
private static final @NonNull NodeRole SPECULATED_NODE = new NodeRoleImpl(Role.Phase.SPECULATED);
private static final @NonNull NodeRole SPECULATION_NODE = new NodeRoleImpl(Role.Phase.SPECULATION);
private static final @NonNull NodeRole OTHER_NODE = new NodeRoleImpl(Role.Phase.OTHER);
public static @NonNull NodeRole getNodeRole(Role.@NonNull Phase phase) {
switch (phase) {
case CONSTANT: return CONSTANT_NODE;
case LOADED: return LOADED_NODE;
case PREDICATED: return PREDICATED_NODE;
case REALIZED: return REALIZED_NODE;
case SPECULATED: return SPECULATED_NODE;
case SPECULATION: return SPECULATION_NODE;
case OTHER: return OTHER_NODE;
}
throw new UnsupportedOperationException();
}
protected NodeRoleImpl(@NonNull Phase phase) {
super(phase);
}
@Override
public @NonNull NodeRole asPhase(@NonNull Phase phase) {
return getNodeRole(phase);
}
@Override
public @NonNull NodeRole asPredicated() {
return asPhase(Phase.PREDICATED);
}
@Override
public @NonNull NodeRole asSpeculated() {
return asPhase(Phase.SPECULATED);
}
@Override
public @NonNull NodeRole asSpeculation() {
return asPhase(Phase.SPECULATION);
}
@Override
public final @NonNull String getFillColor() {
switch (phase) {
case CONSTANT: return LIGHT_CONSTANT_COLOR;
case LOADED: return LIGHT_LOADED_COLOR;
case PREDICATED: return LIGHT_PREDICATED_COLOR;
case REALIZED: return LIGHT_REALIZED_COLOR;
case SPECULATION: return LIGHT_SPECULATION_COLOR;
case SPECULATED: return LIGHT_SPECULATED_COLOR;
default: return LIGHT_OTHER_COLOR;
}
}
@Override
public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
Phase mergedPhase = RegionUtil.mergeToMoreKnownPhase(this, nodeRole).getPhase();
return getNodeRole(mergedPhase);
}
}
|