blob: 92b019973a0a3995497ffb41c19a6ff05b267b02 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*******************************************************************************
* 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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.OperationCallExp;
import org.eclipse.ocl.pivot.StandardLibrary;
import org.eclipse.qvtd.pivot.schedule.AbstractAction;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
* The MultiRegion supervises the many Region instances that realize a transformation.
*/
public class MultiRegion
{
protected final @NonNull QVTp2QVTs qvtp2qvts;
/**
* The oclAsType(Type) casting property for each cast in use.
*/
// private final @NonNull Map<Type, Property> type2castProperty = new HashMap<>();
private final @NonNull List<@NonNull Region> allRegions = new ArrayList<>();
private @NonNull List<@NonNull Region> activeRegions = Collections.emptyList();
public MultiRegion(@NonNull QVTp2QVTs qvtp2qvts) {
this.qvtp2qvts = qvtp2qvts;
}
public void addRegion(@NonNull Region region) {
allRegions.add(region);
}
public @NonNull OperationRegion analyzeOperation(@NonNull OperationCallExp operationCallExp) {
return qvtp2qvts.analyzeOperation(this, operationCallExp);
}
public @NonNull List<@NonNull Region> getActiveRegions() {
return activeRegions;
}
/* public @NonNull Property getCastProperty(@NonNull Type type) {
Property castProperty = type2castProperty.get(type);
if (castProperty == null) {
castProperty = PivotFactory.eINSTANCE.createProperty();
castProperty.setName("as\\n" + type.toString());
castProperty.setType(type);
type2castProperty.put(type, castProperty);
}
return castProperty;
} */
public @NonNull MappingRegion getMappingRegion(@NonNull AbstractAction action) {
return qvtp2qvts.getMappingRegion(action);
}
public @NonNull Iterable<@NonNull OperationRegion> getOperationRegions() {
return Iterables.filter(allRegions, OperationRegion.class);
}
public @NonNull QVTp2QVTs getSchedulerConstants() {
return qvtp2qvts;
}
public @NonNull StandardLibrary getStandardLibrary() {
return qvtp2qvts.getStandardLibrary();
}
/* private @NonNull List<Region> growSequentialRegions(@NonNull List<Region> orderedRegions) {
List<Region> regions = new ArrayList<Region>();
for (@SuppressWarnings("null")@NonNull Region region : orderedRegions) {
if (region.getInvokingRegion() == null) {
SequentialRegion sequentialRegion = region.growSequentialRegion(null);
if (sequentialRegion != null) {
regions.add(sequentialRegion);
}
else {
regions.add(region);
}
}
}
return regions;
} */
// public @NonNull List<Region> identifyRegions() {
// List<Region> sequentialRegions = growSequentialRegions(guardedRegions);
// HierarchicalRegion.growHierarchicalRegions(sequentialRegions);
//
// return allRegions;
// }
public void setActiveRegions(@NonNull Iterable<@NonNull ? extends Region> activeRegions) { // FIXME eliminate
this.activeRegions = Lists.newArrayList(activeRegions);
}
}
|