make:
- gcc src/main.c -o build/idyll -DDESKTOP
+ mkdir -p bin
+ gcc src/main.c -g -o bin/idyll -DDESKTOP -DWORD64
+
+install:
+ mkdir -p bin
+ gcc src/main.c -o bin/idyll -DDESKTOP -DWORD64
+ sudo cp bin/idyll /usr/local/bin/
+
+remove:
+ sudo rm /usr/local/bin/idyll
+
+uninstall:
+ sudo rm /usr/local/bin/idyll
+
+clean:
+ rm -r bin
#ifdef DESKTOP
#include <stdio.h>
+#include <stdlib.h>
+#include <sys/sysinfo.h>
#define false 0
#define true 1
-unsigned char RAM[125000];
+unsigned char* RAM;
+ibword RAM_SIZE;
FILE *OPEN_FILE;
+void initRAM() {
+ RAM = malloc(1000);
+ RAM_SIZE = 1000;
+}
+
+void freeRAM() {
+ RAM_SIZE = 0;
+ free(RAM);
+}
+
//Get size of RAM.
ibword sizeRAM() {
- return 125000;
+ struct sysinfo info;
+ if (sysinfo(&info) == 0) {
+ unsigned long long available = (info.freeram * info.mem_unit) + (info.freeswap * info.mem_unit);
+ return (ibword)available;
+ }
+ return 32000;
}
//Read a byte from RAM.
char readRAM(ibword pos) {
+ if (pos >= RAM_SIZE) RAM = realloc(RAM, ++RAM_SIZE);
return RAM[pos];
}
-//Write a byte to RAM.
+//Write a byte to RAM.
void writeRAM(ibword pos, char b) {
+ if (pos >= RAM_SIZE) RAM = realloc(RAM, ++RAM_SIZE);
RAM[pos] = b;
}
#endif
#define undefined -1
#ifdef DESKTOP
+#ifdef WORD64
+typedef unsigned long long ibword;
+#endif
+#ifdef WORD32
typedef unsigned int ibword;
#endif
+#ifdef WORD16
+typedef unsigned short ibword;
+#endif
+#endif
#ifdef ARDUINO
typedef unsigned short ibword;
#endif
//Check if key exists.
ibword addr;
if (newstr == NULL)
+ {
addr = findNode(key);
- if (addr == (ibword)undefined && newstr == NULL)
- return ERROR_KEY_NOT_FOUND;
-
+ if (addr == (ibword)undefined && newstr == NULL)
+ return ERROR_KEY_NOT_FOUND;
+ }
+
//Skip to equal sign.
char isArray = 0;
while (c != '=' && !isEOL(c)) {
if (!copyStringIntoLineBuff(line))
return ERROR_SYNTAX;
return evalLine(0, 0);
-}
\ No newline at end of file
+}
#include "idyllic.c"
void main(int argc, char **args) {
+ initRAM();
if (argc == 2) {
if (!fileExistsOnDevice(args[1])) {
printf("File `%s` not found.\n", args[1]);
printString("Too long.\n");
}
}
+ freeRAM();
}
//Copies a numeric formula to EVAL_BUFF for numeric processing.
// Returns false if a variable didn't exist.
-char copyFormulaIntoEvalBuff();
+char copyFormulaIntoEvalBuff(ibword pos, ibword size);
//Copies a string or string formula to EVAL_BUFF for string processing.
// Returns false if a variable didn't exist.
-char copyStringIntoEvalBuff();
+char copyStringIntoEvalBuff(ibword pos, ibword size);
//If EVAL_BUFF contains a string formula, use this to read
// a character from it. Characters are shifted out of it.