3 Commits

3 changed files with 16 additions and 7 deletions

View File

@@ -705,7 +705,7 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
return gv; return gv;
} }
if (ci != currentInstruction) { if (ci != currentInstruction) {
i = currentInstruction; i = ci;
} }
currentInstruction++; currentInstruction++;
} }
@@ -1181,11 +1181,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
char buf[256]; char buf[256];
switch (value->type) { switch (value->type) {
case INT: { case INT: {
snprintf(buf, sizeof(buf) * 256, "%" PRId64, value->data.intVal); snprintf(buf, sizeof(buf), "%" PRId64, value->data.intVal);
break; break;
} }
case DOUBLE: { case DOUBLE: {
snprintf(buf, sizeof(buf) * 256, "%f", value->data.doubleVal); snprintf(buf, sizeof(buf), "%f", value->data.doubleVal);
break; break;
} }
case STRING: { case STRING: {
@@ -1886,23 +1886,23 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
char* envPath = getenv("GROUND_LIBS"); char* envPath = getenv("GROUND_LIBS");
if (envPath) { if (envPath) {
snprintf(path, sizeof(path), "%s/%s", envPath, libName); snprintf(path, sizeof(path), "%s/%s.grnd", envPath, libName);
if (access(path, F_OK) == 0) found = 1; if (access(path, F_OK) == 0) found = 1;
} }
if (!found) { if (!found) {
snprintf(path, sizeof(path), "/usr/lib/ground/%s", libName); snprintf(path, sizeof(path), "/usr/lib/ground/%s.grnd", libName);
if (access(path, F_OK) == 0) found = 1; if (access(path, F_OK) == 0) found = 1;
} }
if (!found) { if (!found) {
snprintf(path, sizeof(path), "%s", libName); snprintf(path, sizeof(path), "./%s.grnd", libName);
if (access(path, F_OK) == 0) found = 1; if (access(path, F_OK) == 0) found = 1;
} }
if (!found) { if (!found) {
char errorMsg[1100]; char errorMsg[1100];
snprintf(errorMsg, sizeof(errorMsg), "Could not find library: %s", libName); snprintf(errorMsg, sizeof(errorMsg), "Could not find library: %s.grnd", libName);
runtimeError(FIXME, errorMsg, in, currentInstruction); runtimeError(FIXME, errorMsg, in, currentInstruction);
} }

7
tests/lib.grnd Normal file
View File

@@ -0,0 +1,7 @@
fun !lib_PrintHello -int
println "Hello, world!"
return 0
endfun
println "Hello!"
println "Hello!"

2
tests/use.grnd Normal file
View File

@@ -0,0 +1,2 @@
use "lib"
call !lib_PrintHello &tmp