Moved time header includes, comment tweaks

This commit is contained in:
2023-01-13 15:39:22 +00:00
parent 65e5905011
commit 0649a141dd
7 changed files with 9 additions and 16 deletions

View File

@@ -1,8 +1,10 @@
#include "lib_standard.h" #include "lib_standard.h"
#include "toy_common.h"
#include "memory.h" #include "memory.h"
#include <time.h>
#include <sys/time.h>
static int nativeClock(Interpreter* interpreter, LiteralArray* arguments) { static int nativeClock(Interpreter* interpreter, LiteralArray* arguments) {
//no arguments //no arguments
if (arguments->count != 0) { if (arguments->count != 0) {

View File

@@ -1,9 +1,10 @@
#include "lib_timer.h" #include "lib_timer.h"
#include "toy_common.h"
#include "memory.h" #include "memory.h"
#include <stdio.h> #include <stdio.h>
#include <time.h>
#include <sys/time.h>
//GOD DAMN IT: https://stackoverflow.com/questions/15846762/timeval-subtract-explanation //GOD DAMN IT: https://stackoverflow.com/questions/15846762/timeval-subtract-explanation
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) { int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) {

View File

@@ -100,7 +100,7 @@ int main(int argc, const char* argv[]) {
return 0; return 0;
} }
//TODO: remove this when the interpreter meets the specification //version
if (command.verbose) { if (command.verbose) {
printf(NOTICE "Toy Programming Language Version %d.%d.%d\n" RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH); printf(NOTICE "Toy Programming Language Version %d.%d.%d\n" RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH);
} }

View File

@@ -250,7 +250,7 @@ union _node {
NodeFnDecl fnDecl; NodeFnDecl fnDecl;
NodeFnCall fnCall; NodeFnCall fnCall;
NodeFnReturn returns; NodeFnReturn returns;
NodeIf pathIf; //TODO: rename these to ifStmt? NodeIf pathIf;
NodeWhile pathWhile; NodeWhile pathWhile;
NodeFor pathFor; NodeFor pathFor;
NodeBreak pathBreak; NodeBreak pathBreak;

View File

@@ -380,7 +380,7 @@ int hashLiteral(Literal lit) {
case LITERAL_FUNCTION: case LITERAL_FUNCTION:
case LITERAL_FUNCTION_NATIVE: case LITERAL_FUNCTION_NATIVE:
return 0; //TODO: find a way to hash these properly return 0; //can't hash these
case LITERAL_IDENTIFIER: case LITERAL_IDENTIFIER:
return HASH_I(lit); //pre-computed return HASH_I(lit); //pre-computed
@@ -564,7 +564,6 @@ void printLiteralCustom(Literal literal, void (printFn)(const char*)) {
} }
break; break;
//TODO: functions
case LITERAL_FUNCTION: case LITERAL_FUNCTION:
case LITERAL_FUNCTION_NATIVE: case LITERAL_FUNCTION_NATIVE:
printFn("(function)"); printFn("(function)");

View File

@@ -77,8 +77,6 @@ bool setLiteralArray(LiteralArray* array, Literal index, Literal value) {
return false; return false;
} }
//TODO: implicit push when referencing one-past-the-end?
freeLiteral(array->literals[idx]); freeLiteral(array->literals[idx]);
array->literals[idx] = copyLiteral(value); array->literals[idx] = copyLiteral(value);

View File

@@ -9,22 +9,15 @@
#define TOY_VERSION_PATCH 5 #define TOY_VERSION_PATCH 5
#define TOY_VERSION_BUILD __DATE__ " " __TIME__ #define TOY_VERSION_BUILD __DATE__ " " __TIME__
//NOTE: I don't know why the time headers are here, need to try moving them back to the correct spots again //platform-specific specifications
//platform exports/imports
#if defined(__linux__) #if defined(__linux__)
#define TOY_API extern #define TOY_API extern
#include <time.h>
#include <sys/time.h>
#elif defined(_WIN32) || defined(WIN32) #elif defined(_WIN32) || defined(WIN32)
#define TOY_API #define TOY_API
#include <time.h>
#include <sys/time.h>
#else #else
#define TOY_API #define TOY_API
#include <time.h>
#include <sys/time.h>
#endif #endif