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

* ValueStructural Dependence correctly traversed

* Arity added to tuple elements
* Stack states correctly updated (considers the previous traversed edge to differentiate states)
parent 1e6aaa69
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -245,16 +245,14 @@ public class EDGFactory {

	private void modifyDataConstructorArcs(Node dataConstructor, Node result)
	{
		final List<Node> dataConstructorChildren = edg.getChildren(dataConstructor);
		dataConstructorChildren.removeIf(n -> n.getType() == Node.Type.Result);

		final List<Node> dataConstructorChildren = edg.getChildrenNonResult(dataConstructor);
		final int dataConstructorChildrenCount = dataConstructorChildren.size();

		for (int childIndex = 0; childIndex < dataConstructorChildrenCount; childIndex++)
		{
			final Node dataConstructorChild = edg.getResFromNode(dataConstructorChildren.get(childIndex));
			final DataConstructorConstraint constraint = new DataConstructorConstraint(
					AccessConstraint.Operation.Remove, childIndex + "");
					AccessConstraint.Operation.Remove, childIndex + "/" + (dataConstructorChildrenCount-1));
			edg.addEdge(dataConstructorChild, result, new Edge(Edge.Type.Value, constraint));
		}

+11 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import java.util.List;
public class StructuralConstraint extends EdgeConstraint {
    private AccessConstraint constraint;

    public StructuralConstraint(Operation operation, int index) {
    public StructuralConstraint(Operation operation, String index) {
        constraint = new DataConstructorConstraint(operation, index + "S");
    }

@@ -64,8 +64,16 @@ public class StructuralConstraint extends EdgeConstraint {
        {
            if (this.constraint.operation == Operation.Add)
                return super.wrap(super.push(phase, constraints));
            if (this.cancels(topConstraint))
                return super.wrap(super.pop(constraints));
            if (!constraints.nodeConstraints.isEmpty())
                throw new IllegalStateException("NodeConstraints cannot be stacked in this implementation");
            Constraint bottomConstraint = constraints.edgeConstraints.firstElement();
            if (!(bottomConstraint instanceof StructuralConstraint))
                throw new IllegalStateException("The bottom constraint must be a Structural Constraint");
            StructuralConstraint headConstraint = (StructuralConstraint) bottomConstraint;
            if (this.cancels(headConstraint)) {
                constraints.edgeConstraints.remove(0);
                return super.wrap(constraints);
            }
            return super.wrap();
        }

+2 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class NodeWork extends Work

		if (!super.equals(nodeWork))
			return false;
		return this.currentNode == nodeWork.currentNode;
		return this.currentNode == nodeWork.currentNode &&
				previousEdgeType == nodeWork.previousEdgeType;
	}
}
 No newline at end of file
+26 −16
Original line number Diff line number Diff line
@@ -76,19 +76,25 @@ public class ValueEdgeGenerator {
				final Node dataConstructorChild = dataConstructorChildren.get(childIndex);
				final Node from = isPatternZone ? dataConstructor : dataConstructorChild;
				final Node to = isPatternZone ? dataConstructorChild : dataConstructor;
				final DataConstructorConstraint constraint = new DataConstructorConstraint(operation, childIndex + "");
				final DataConstructorConstraint constraint = new DataConstructorConstraint(operation,
						childIndex + "/" + (dataConstructorChildren.size()-1));
				this.last.addEdge(from, to, Edge.Type.Value, constraint);

				if (!isPatternZone){
					// In case the parent is a List this structure is also necessary
					final Node parent = this.last.getParent(dataConstructor);
					if (parent.getType() == Node.Type.List) {
						StructuralConstraint sDc = new StructuralConstraint(AccessConstraint.Operation.Remove,
							childIndex + "/" + (this.last.getChildren(parent).size()-1));
						this.last.addEdge(dataConstructor, parent, Edge.Type.ValueStructure, sDc);
					}
					switch(dataConstructorChild.getType()){
						case DataConstructor:
							StructuralConstraint sDc = new StructuralConstraint(AccessConstraint.Operation.Remove, childIndex);
						case List:
							StructuralConstraint sDc = new StructuralConstraint(AccessConstraint.Operation.Remove,
									childIndex + "/" + (dataConstructorChildren.size()-1));
							this.last.addEdge(dataConstructorChild, dataConstructor, Edge.Type.ValueStructure, sDc);
							break;
//						case Literal:
//							LiteralConstraint litc = new LiteralConstraint(AccessConstraint.Operation.Remove);
//							this.last.addEdge(dataConstructorChild, dataConstructor, Edge.Type.ValueStructure, litc);
//							break;
						default:
							break;
					}
@@ -212,22 +218,27 @@ public class ValueEdgeGenerator {
	private void generateGeneratorPatternStructureEdges(Node parent, Node pattern){
		switch(pattern.getType()){
			case List:
				ListConstraint lc = new ListConstraint(AccessConstraint.Operation.Remove, ListConstraint.Position.S);
				if (parent.getType() == Node.Type.Generator)
					this.last.addEdge(pattern, parent, Edge.Type.ValueStructure, EmptyConstraint.getConstraint());
				else {
					ListConstraint lc = new ListConstraint(AccessConstraint.Operation.Add, ListConstraint.Position.S);
					this.last.addEdge(pattern, parent, Edge.Type.ValueStructure, lc);
				}
				generateGeneratorPatternStructureEdges(pattern);
				break;
			case DataConstructor:
				StructuralConstraint sDc = new StructuralConstraint(AccessConstraint.Operation.Add, this.last.getChildIndex(pattern));
				if (parent.getType() == Node.Type.Generator)
					this.last.addEdge(pattern, parent, Edge.Type.ValueStructure, EmptyConstraint.getConstraint());
				else {
					StructuralConstraint sDc = new StructuralConstraint(AccessConstraint.Operation.Add,
							this.last.getChildIndex(pattern) + "/" + (this.last.getChildren(parent).size()-1));
					this.last.addEdge(pattern, parent, Edge.Type.ValueStructure, sDc);
				}
				generateGeneratorPatternStructureEdges(pattern);
				break;
			case Literal:
				if (parent.getType() == Node.Type.Generator)
					this.last.addEdge(pattern, parent, Edge.Type.Value, EmptyConstraint.getConstraint());
				else {
					final Node genNode = this.last.getAncestor(parent, Node.Type.Generator);
					this.last.addEdge(pattern, genNode, Edge.Type.Value, EmptyConstraint.getConstraint());
				}
				// generateGeneratorPatternStructureEdges(pattern);
				break;
			default:
@@ -239,8 +250,7 @@ public class ValueEdgeGenerator {
		List<Node> children = last.getChildrenNonResult(pattern);
		boolean allChildrenLeaves = true;
		for (Node child : children)
			if (child.getType() == Node.Type.DataConstructor || child.getType() == Node.Type.List
					|| child.getType() == Node.Type.Literal) {
			if (child.getType() == Node.Type.DataConstructor || child.getType() == Node.Type.List) {
				allChildrenLeaves = false;
				this.generateGeneratorPatternStructureEdges(pattern, child);
			}
+1 −5
Original line number Diff line number Diff line
@@ -8,11 +8,7 @@ main(Elements, Temp) ->

templessthan(Temp, Elem) ->
    [ 
     begin
         T2 = T * 2,
         T3 = T2 / 2,
         {Name, T3}
     end ||
     begin {Name, sliced} end ||
         {Name, _, T} <- Elem,
         T > Temp
    ].
Loading