Newer
Older
/*
* EDG, a library to generate and slice Expression Dependence Graphs.
* Copyright (c) 2021. David Insa, Sergio Pérez, Josep Silva, Salvador Tamarit.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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
package edg.constraint;
import java.util.List;
import edg.graph.Edge;
import edg.slicing.Phase;
public class AsteriskConstraint extends EdgeConstraint
{
private static AsteriskConstraint constraint = new AsteriskConstraint();
public static AsteriskConstraint getConstraint()
{
return AsteriskConstraint.constraint;
}
private AsteriskConstraint()
{
}
public boolean equals(Object object)
{
return object instanceof AsteriskConstraint;
}
public String toString()
{
return "*";
}
protected List<Constraints> resolve(Phase phase, Edge edge, Constraints constraints, int productionDepth)
{
return super.wrap(constraints);
}
protected List<Constraints> resolve(Phase phase, Edge edge, Constraints constraints, AccessConstraint topConstraint, int productionDepth)
{
if (phase.isInstanceof(Phase.Slicing))
return super.wrap(new Constraints());
super.check(phase, Phase.SummaryGeneration);
if (topConstraint.operation == AccessConstraint.Operation.Remove)
return super.wrap(super.push(phase, constraints));
super.check(topConstraint.operation, AccessConstraint.Operation.Add);
final Constraints newConstraints = super.pop(constraints);
if (newConstraints.isEdgeConstraintsEmpty())
return super.wrap(newConstraints);
final EdgeConstraint peekConstraint = newConstraints.peekEdgeConstraint();
return super.resolve(phase, edge, newConstraints, peekConstraint, productionDepth);
}
protected List<Constraints> resolve(Phase phase, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
{
super.check(phase, Phase.SummaryGeneration);
return super.wrap(super.push(phase, constraints));
}
protected List<Constraints> resolve(Phase phase, Edge edge, Constraints constraints, SeekingConstraint topConstraint, int productionDepth)
{
if (phase.isInstanceof(Phase.Slicing))
return super.wrap(new Constraints());
super.check(phase, Phase.SummaryGeneration);
if (topConstraint.operation == SeekingConstraint.Operation.LetThrough || topConstraint.operation == SeekingConstraint.Operation.Remove)
return super.wrap(super.push(phase, constraints));
super.check(topConstraint.operation, SeekingConstraint.Operation.Add);
final Constraints newConstraints = super.pop(constraints);
if (newConstraints.isEdgeConstraintsEmpty())
return super.wrap(newConstraints);
final EdgeConstraint peekConstraint = newConstraints.peekEdgeConstraint();
return super.resolve(phase, edge, newConstraints, peekConstraint, productionDepth);
}
protected List<Constraints> resolve(Phase phase, Edge edge, Constraints constraints, AsteriskConstraint topConstraint, int productionDepth)
{
super.check(phase, Phase.SummaryGeneration);
return super.wrap(constraints);
}
}