A bit of cleanup and warning-hushing.

This commit is contained in:
Sage Vaillancourt 2022-03-31 14:12:52 -04:00 committed by Sage Vaillancourt
parent ac04fa1a96
commit 2fb6643326
6 changed files with 7 additions and 35 deletions

View File

@ -37,12 +37,14 @@ Object fetchFromEnvironment(const char* name, struct Environment* env)
} }
for (int i = 0; i < env->capacity; i++) { for (int i = 0; i < env->capacity; i++) {
if (env->strings[i] == NULL) { printd("Try %d (NULL)\n", i); if (env->strings[i] == NULL) {
printd("Try %d (NULL)\n", i);
break; break;
} }
printd("Try %d (%s)\n", i, env->strings[i]); printd("Try %d (%s)\n", i, env->strings[i]);
if (strcmp(name, env->strings[i]) == 0) { printd("Returning!\n"); if (strcmp(name, env->strings[i]) == 0) {
printd("Returning!\n");
return cloneObject(env->objects[i]); return cloneObject(env->objects[i]);
} }
} }

View File

@ -680,7 +680,7 @@ inline Object numberObject(int num)
inline Object boolObject(int b) inline Object boolObject(int b)
{ {
Object o = newObject(TYPE_BOOL); Object o = newObject(TYPE_BOOL);
o.number = !!b; o.number = b != 0;
return o; return o;
} }

View File

@ -11,7 +11,7 @@
#ifdef DEBUG #ifdef DEBUG
#define printd(...) printf(__VA_ARGS__) #define printd(...) printf(__VA_ARGS__)
#else #else
#define printd(...) ; #define printd(...) do { } while (0)
#endif #endif
#endif #endif

View File

@ -9,7 +9,6 @@
#include <string.h> #include <string.h>
#include "tokens.h" #include "tokens.h"
#include "plfunc.h"
#ifdef STANDALONE #ifdef STANDALONE

View File

@ -12,7 +12,7 @@
#define fnn(_name, _docs, ...) \ #define fnn(_name, _docs, ...) \
static const char * const _name ## Doc = _docs; \ static const char * const _name ## Doc = _docs; \
static const char * const _name ## Tests[] = {__VA_ARGS__}; \ __attribute__((unused)) static const char * const _name ## Tests[] = {__VA_ARGS__}; \
_Static_assert(array_length(_name ## Tests) % 2 == 0, "Array of test strings must have exactly one expected result for each test."); \ _Static_assert(array_length(_name ## Tests) % 2 == 0, "Array of test strings must have exactly one expected result for each test."); \
Object _name(Object* params, int length, struct Environment* env) Object _name(Object* params, int length, struct Environment* env)
@ -53,8 +53,6 @@ Object parseEval(const char* input, struct Environment* env);
Object evalList(const Object* obj, struct Environment* env); Object evalList(const Object* obj, struct Environment* env);
void copySlice(char* dest, struct Slice* src);
Object evalLambdaArgs(const Object* arg_forms, struct Environment* env); Object evalLambdaArgs(const Object* arg_forms, struct Environment* env);
Object listEvalLambda(Object* lambda, const Object* remaining, int evalLength, Object listEvalLambda(Object* lambda, const Object* remaining, int evalLength,

View File

@ -2,33 +2,6 @@
#include <pebble.h> #include <pebble.h>
struct tm* getTime()
{
time_t t = time(NULL);
return localtime(&t);
}
Object getSeconds(Object o1, Object o2, struct Environment* env)
{
return numberObject(getTime()->tm_sec);
}
Object getMinutes(Object o1, Object o2, struct Environment* env)
{
return numberObject(getTime()->tm_min);
}
Object getHours(Object o1, Object o2, struct Environment* env)
{
return numberObject(getTime()->tm_hour);
}
Object getTwelveHours(Object o1, Object o2, struct Environment* env)
{
int hour = (getTime()->tm_hour % 12) ?: 12;
return numberObject(hour);
}
Object doVibe(Object patternList, Object o2, struct Environment* env) Object doVibe(Object patternList, Object o2, struct Environment* env)
{ {
int length = listLength(&patternList); int length = listLength(&patternList);