42 lines
595 B
C
42 lines
595 B
C
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include "inheritance.h"
|
|
#include "struct.h"
|
|
#include "compare.h"
|
|
|
|
int compare_values(
|
|
const struct value* a,
|
|
const struct value* b)
|
|
{
|
|
ENTER;
|
|
|
|
int cmp = 0;
|
|
|
|
if (a == b)
|
|
{
|
|
cmp = 0;
|
|
}
|
|
else if (a->kind > b->kind)
|
|
{
|
|
cmp = +1;
|
|
}
|
|
else if (a->kind < b->kind)
|
|
{
|
|
cmp = -1;
|
|
}
|
|
else
|
|
{
|
|
assert(a);
|
|
assert(a->inheritance);
|
|
assert(a->inheritance->compare);
|
|
|
|
cmp = (a->inheritance->compare)(a, b);
|
|
}
|
|
|
|
EXIT;
|
|
return cmp;
|
|
}
|
|
|