forked from ground/ground
Compare commits
3 Commits
master
...
a0a8cb69cc
| Author | SHA1 | Date | |
|---|---|---|---|
| a0a8cb69cc | |||
| 1acc20db82 | |||
| b6e2a594e9 |
@@ -705,7 +705,7 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
|
||||
return gv;
|
||||
}
|
||||
if (ci != currentInstruction) {
|
||||
i = currentInstruction;
|
||||
i = ci;
|
||||
}
|
||||
currentInstruction++;
|
||||
}
|
||||
@@ -1181,11 +1181,11 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
char buf[256];
|
||||
switch (value->type) {
|
||||
case INT: {
|
||||
snprintf(buf, sizeof(buf) * 256, "%" PRId64, value->data.intVal);
|
||||
snprintf(buf, sizeof(buf), "%" PRId64, value->data.intVal);
|
||||
break;
|
||||
}
|
||||
case DOUBLE: {
|
||||
snprintf(buf, sizeof(buf) * 256, "%f", value->data.doubleVal);
|
||||
snprintf(buf, sizeof(buf), "%f", value->data.doubleVal);
|
||||
break;
|
||||
}
|
||||
case STRING: {
|
||||
@@ -1886,23 +1886,23 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
char* envPath = getenv("GROUND_LIBS");
|
||||
|
||||
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 (!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 (!found) {
|
||||
snprintf(path, sizeof(path), "%s", libName);
|
||||
snprintf(path, sizeof(path), "./%s.grnd", libName);
|
||||
if (access(path, F_OK) == 0) found = 1;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
7
tests/lib.grnd
Normal file
7
tests/lib.grnd
Normal 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
2
tests/use.grnd
Normal file
@@ -0,0 +1,2 @@
|
||||
use "lib"
|
||||
call !lib_PrintHello &tmp
|
||||
Reference in New Issue
Block a user