mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Wrote value, chunk, memory sections, tested value
chunk and memory remain untested for now
This commit is contained in:
21
source/toy_value.c
Normal file
21
source/toy_value.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "toy_value.h"
|
||||
|
||||
#include "toy_console_colors.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
bool Toy_private_isTruthy(Toy_Value value) {
|
||||
//null is an error
|
||||
if (TOY_VALUE_IS_NULL(value)) {
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: 'null' is neither true nor false\n" TOY_CC_RESET);
|
||||
return false;
|
||||
}
|
||||
|
||||
//only 'false' is falsy
|
||||
if (TOY_VALUE_IS_BOOLEAN(value)) {
|
||||
return TOY_VALUE_AS_BOOLEAN(value);
|
||||
}
|
||||
|
||||
//anything else is truthy
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user