Skip to content

Commit

Permalink
Support map iteration #108
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwvj committed Oct 18, 2017
1 parent 4e7ab1e commit 6c440d7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class ColTrans extends DepthFirstAnalysisCAdaptor implements IApplyAssist
public static final String MAP_RES_DOM_BY = "vdmMapDomRestrictBy";
public static final String MAP_RES_RNG_TO = "vdmMapRngRestrictTo";
public static final String MAP_RES_RNG_BY = "vdmMapRngRestrictBy";
public static final String MAP_ITERATE = "vdmMapIterate";

private TransAssistantIR assist;

Expand Down Expand Up @@ -284,7 +285,13 @@ public void caseARangeResByBinaryExpIR(ARangeResByBinaryExpIR node) throws Analy

rewriteToApply(this, node, MAP_RES_RNG_BY, node.getLeft(), node.getRight());
}


@Override
public void caseAMapIterationBinaryExpIR(AMapIterationBinaryExpIR node) throws AnalysisException {

rewriteToApply(this, node, MAP_ITERATE, node.getLeft(), node.getRight());
}

private void rewriteColEnumToApply(SExpIR node, String seqVar, List<SExpIR> members)
throws AnalysisException {
AExternalTypeIR extType = new AExternalTypeIR();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public void initNames()
gcNames.put(ColTrans.MAP_RES_DOM_BY, "vdmMapDomRestrictByGC");
gcNames.put(ColTrans.MAP_RES_RNG_TO, "vdmMapRngRestrictToGC");
gcNames.put(ColTrans.MAP_RES_RNG_BY, "vdmMapRngRestrictByGC");

gcNames.put(ColTrans.MAP_ITERATE, "vdmMapIterateGC");

// Tuples
gcNames.put(TupleTrans.TUPLE_EXP, "newProductVarGC");
gcNames.put(TupleTrans.TUPLE_FIELD_NUMBER_EXP, "productGetGC");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ TEST_F(TestFlowFunctions, mapRngResBy)
{
CHECK(CLASS_ExpressionMap__Z16mapRestrictRngByEV);
}

TEST_F(TestFlowFunctions, mapIterate)
{
CHECK(CLASS_ExpressionMap__Z12mapIterationEV);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ mapRestrictRngTo () == {1 |-> 2, 2 |-> 3} :> {3} = {2 |-> 3};
public mapRestrictRngBy : () -> bool
mapRestrictRngBy () == {1 |-> 2, 2 |-> 3} :-> {3} = {1 |-> 2};

public mapIteration : () -> bool
mapIteration () == {1 |-> 2, 2 |-> 1, 3 |-> 4, 4 |-> 3} ** 2 = {1 |-> 1, 2 |-> 2, 3 |-> 3, 4 |-> 4};

end ExpressionMap

0 comments on commit 6c440d7

Please sign in to comment.