Skip to content

Commit

Permalink
- Runtime library support for issameclass.
Browse files Browse the repository at this point in the history
-  Addresses #108.
  • Loading branch information
bandurvp committed Oct 4, 2017
1 parent 858fa3d commit 9b720d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions c/vdmclib/src/main/VdmBasicTypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ TVP isRecordGC(TVP val, int recID, TVP *from)
}
#endif

TVP isSameClass(TVP a, TVP b)
{
return newBool(((struct ClassType *)a->value.ptr)->classId == ((struct ClassType *)b->value.ptr)->classId);
}

TVP isSameClassGC(TVP a, TVP b, TVP *from)
{
return newBoolGC(((struct ClassType *)a->value.ptr)->classId == ((struct ClassType *)b->value.ptr)->classId, from);
}

TVP is(TVP v, char ot[])
{
int i;
Expand Down
4 changes: 4 additions & 0 deletions c/vdmclib/src/main/VdmBasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ TVP isToken(TVP val);
TVP isTokenGC(TVP val, TVP *from);
TVP isOfClass(TVP val, int classID);
TVP isOfClassGC(TVP val, int classID, TVP *from);
#ifndef NO_RECORDS
TVP isRecord(TVP val, int recID);
TVP isRecordGC(TVP val, int recID, TVP *from);
#endif
TVP isSameClass(TVP a, TVP b);
TVP isSameClassGC(TVP a, TVP b, TVP *from);
TVP is(TVP v, char ot[]);
int toInteger(TVP a);
double toDouble(TVP a);
Expand Down
10 changes: 10 additions & 0 deletions c/vdmclib/src/test/ClassATest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,14 @@ TEST(ClassATest, isA)
vdmFree(c);
}

TEST(ClassATest, isSameClass)
{
TVP c = A._new();
TVP res;

res = isSameClass(c, c);
EXPECT_TRUE(res->value.boolVal);
vdmFree(res);
}

}

0 comments on commit 9b720d0

Please sign in to comment.