Skip to content

Commit

Permalink
Address misnomer, rename newMapVarToGrow to newMapVar #106
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwvj committed Aug 9, 2017
1 parent e1fb95e commit e6209c2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions c/vdmclib/src/main/VdmMap.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TVP newMapGC(TVP *from)


/* Not a very useful function, but here to support the map comprehension mechanism. */
TVP newMapVarToGrow(size_t size, size_t expected_size, ...)
TVP newMapVar(size_t size, size_t expected_size, ...)
{
struct Map* ptr;
TVP key;
Expand Down Expand Up @@ -149,7 +149,7 @@ TVP newMapVarToGrow(size_t size, size_t expected_size, ...)
}

/* Not a very useful function, but here to support the map comprehension mechanism. */
TVP newMapVarToGrowGC(size_t size, size_t expected_size, TVP *from, ...)
TVP newMapVarGC(size_t size, size_t expected_size, TVP *from, ...)
{
struct Map* ptr;
TVP key;
Expand Down
4 changes: 2 additions & 2 deletions c/vdmclib/src/main/VdmMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct Map* cloneMap(struct Map *m);
void vdmMapAdd(TVP map,TVP key, TVP value);
void vdmMapUpdate(TVP map, TVP key, TVP value);

TVP newMapVarToGrow(size_t, size_t, ...);
TVP newMapVarToGrowGC(size_t size, size_t expected_size, TVP *from, ...);
TVP newMapVar(size_t, size_t, ...);
TVP newMapVarGC(size_t size, size_t expected_size, TVP *from, ...);
void vdmMapGrow(TVP, TVP, TVP);
void vdmMapFit(TVP);

Expand Down
12 changes: 6 additions & 6 deletions c/vdmclib/src/test/ExpressionsMap_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,16 @@ TEST(Expression_Map, mapEquals1)
TEST(Expression_Map, mapEquals2)
{
// {1 |-> 2}
TVP m1 = newMapVarToGrow(1, 5, newInt(1), newInt(2));
TVP m1 = newMapVar(1, 5, newInt(1), newInt(2));

// {3 |-> 4}
TVP m2 = newMapVarToGrow(1, 5, newInt(3), newInt(4));
TVP m2 = newMapVar(1, 5, newInt(3), newInt(4));

// m1 union m2
TVP mapUnionResult = vdmMapMunion(m1,m2);

// {1 |-> 2, 3 |-> 4}
TVP expectedResult = newMapVarToGrow(2, 5, newInt(3), newInt(4), newInt(1), newInt(2));
TVP expectedResult = newMapVar(2, 5, newInt(3), newInt(4), newInt(1), newInt(2));

TVP res = vdmEquals(mapUnionResult, expectedResult);
bool b = res->value.boolVal;
Expand All @@ -425,16 +425,16 @@ TEST(Expression_Map, mapEquals2)



TEST(Expression_Map, newMapVarToGrow)
TEST(Expression_Map, newMapVar)
{
TVP theMap;
TVP val;
TVP res;

theMap = newMapVarToGrow(0, 10);
theMap = newMapVar(0, 10);
vdmFree(theMap);

theMap = newMapVarToGrow(3, 10, newChar('a'), newInt(1), newChar('b'), newInt(2), newChar('c'), newInt(3));
theMap = newMapVar(3, 10, newChar('a'), newInt(1), newChar('b'), newInt(2), newChar('c'), newInt(3));

val = vdmMapApply(theMap, newChar('a'));
res = vdmEquals(val, newInt(1));
Expand Down
2 changes: 1 addition & 1 deletion c/vdmclib/src/test/ExpressionsSeq_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ TEST(Expression_Seq, seqMod)

TVP s = newSequence(2,arr);

TVP m = newMapVarToGrow(2, 5, newInt(1), newInt(5), newInt(2), newInt(10)) ;
TVP m = newMapVar(2, 5, newInt(1), newInt(5), newInt(2), newInt(10)) ;

TVP res = vdmSeqMod(s,m);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ColTrans extends DepthFirstAnalysisCAdaptor implements IApplyAssist

public static final String SEQ_VAR = "newSeqVar";
public static final String SET_VAR = "newSetVar";
public static final String MAP_VAR = "newMapVarToGrow";
public static final String MAP_VAR = "newMapVar";

// Sequence operations
public static final String SEQ_TAIL = "vdmSeqTl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void initNames()
// Collections
gcNames.put(ColTrans.SEQ_VAR, "newSeqVarGC");
gcNames.put(ColTrans.SET_VAR, "newSetVarGC");
gcNames.put(ColTrans.MAP_VAR, "newMapVarToGrowGC");
gcNames.put(ColTrans.MAP_VAR, "newMapVarGC");

// Sequence operations
gcNames.put(ColTrans.SEQ_TAIL, "vdmSeqTlGC");
Expand Down Expand Up @@ -194,8 +194,8 @@ private void changeToGcCall(SExpIR node, LinkedList<SExpIR> args,
}
else if(isMap(oldName) || isSetVarToGrow(oldName))
{
// The signature of 'newMapVarToGrowGC' is:
// TVP newMapVarToGrowGC(size_t size, size_t expected_size, TVP *from, ...);
// The signature of 'newMapVarGC' is:
// TVP newMapVarGC(size_t size, size_t expected_size, TVP *from, ...);
// TVP newSetVarToGrowGC(size_t size, size_t expected_size, TVP *from, ...)
// Therefore, 'from' is the third argument (at index 2)
args.add(2, consReference(node));
Expand Down

0 comments on commit e6209c2

Please sign in to comment.