Commit 1e6aaa69 authored by Sergio Pérez's avatar Sergio Pérez
Browse files

Fix ValueStructureEdges traversal in generators

parent ffc8b55c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ public abstract class AccessConstraint extends EdgeConstraint {

		return super.wrap(super.push(phase, constraints));
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth) {
		return super.wrap();
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ public class AddNodeConstraint extends EdgeConstraint {
		constraints.nodeConstraints.add(this.nodeConstraint);
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth) {
		constraints.nodeConstraints.add(this.nodeConstraint);
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+19 −0
Original line number Diff line number Diff line
@@ -52,6 +52,25 @@ public class AsteriskConstraint extends EdgeConstraint
		final EdgeConstraint peekConstraint = newConstraints.peekEdgeConstraint();
		return super.resolve(phase, edg, edge, newConstraints, peekConstraint, productionDepth);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth) {
		if (phase.isInstanceof(Phase.Slicing))
			return super.wrap(new Constraints());
		super.check(phase, Phase.SummaryGeneration);

		if (existsPreviousAsteriskConstraint(constraints))
			return super.wrap(this.popToAsteriskConstraint(constraints));

		if (topConstraint.getConstraint().operation == AccessConstraint.Operation.Remove)
			return super.wrap(super.push(phase, constraints));
		super.check(topConstraint.getConstraint().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, edg, edge, newConstraints, peekConstraint, productionDepth);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ public abstract class EdgeConstraint extends Constraint
			return this.resolve(phase, edg, edge, constraints, (ListComprehensionConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof AccessConstraint)
			return this.resolve(phase, edg, edge, constraints, (AccessConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof StructuralConstraint)
			return this.resolve(phase, edg, edge, constraints, (StructuralConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof EmptyConstraint)
			return this.resolve(phase, edg, edge, constraints, (EmptyConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof PhaseConstraint)
@@ -33,6 +35,8 @@ public abstract class EdgeConstraint extends Constraint

	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, int productionDepth);
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, AccessConstraint topConstraint, int productionDepth);
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth);

	protected final List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, AddNodeConstraint topConstraint, int productionDepth)
	{
		throw new RuntimeException("The add node constraint should not be on the stack");
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ public class EmptyConstraint extends EdgeConstraint
	{
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth)
	{
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
Loading