37 lines
606 B
C
37 lines
606 B
C
![]() |
#include <stdio.h>
|
||
|
|
||
|
#include "util.h"
|
||
|
|
||
|
void printValue(object input);
|
||
|
|
||
|
void print(object input)
|
||
|
{
|
||
|
printf("\n; Value: ");
|
||
|
printValue(input);
|
||
|
printf("\n\n");
|
||
|
}
|
||
|
|
||
|
void printValue(object input)
|
||
|
{
|
||
|
if (input.type == nilObject)
|
||
|
{
|
||
|
printf("nil");
|
||
|
}
|
||
|
else if (input.type == numberObject)
|
||
|
{
|
||
|
printf("%lld", *((long long *) input.address));
|
||
|
}
|
||
|
else if (input.type == symbolObject)
|
||
|
{
|
||
|
printf("%s", (char *) input.address);
|
||
|
}
|
||
|
else if (input.type == consObject)
|
||
|
{
|
||
|
printf("(");
|
||
|
printValue(((cons *) input.address)->car);
|
||
|
printf(" . ");
|
||
|
printValue(((cons *) input.address)->cdr);
|
||
|
printf(")");
|
||
|
}
|
||
|
}
|