This commit is contained in:
cozis
2021-11-01 16:22:34 +00:00
parent d93f578eb2
commit a1f2db9aa9
3 changed files with 11 additions and 33 deletions
+5 -11
View File
@@ -1,12 +1,6 @@
p = 1;
return p;
if true
{
x = 7;
2;
}
else
4;
return x;
if false
a = 1;
else
a = 2;
return a;
+2 -22
View File
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
Object *result = run(runtime, (Error*) &error, exe, 0, NULL, 0);
if(result == NULL)
if(result == NULL || !Object_Print(result, stderr, (Error*) &error))
{
fprintf(stderr, "RUNTIME ERROR: %s.\n", error.base.message);
@@ -213,28 +213,8 @@ int main(int argc, char **argv)
Runtime_Free(runtime);
return 1;
}
else
{
if(Object_IsInt(result))
{
long long int val = Object_ToInt(result, (Error*) &error);
assert(error.base.occurred == 0);
fprintf(stderr, "%lld\n", val);
}
else if(Object_IsFloat(result))
{
double val = Object_ToFloat(result, (Error*) &error);
assert(error.base.occurred == 0);
fprintf(stderr, "%f\n", val);
}
else
{
fprintf(stderr, "Not printing returned value since it's not an int or a float.\n");
}
}
fprintf(stderr, "\n");
Runtime_Free(runtime);
}
+4
View File
@@ -462,6 +462,10 @@ static _Bool step(Runtime *runtime, Error *error)
Error_Report(error, 1, "Reference to undefined variable \"%s\"", ops[0].as_string);
return 0;
}
if(!Runtime_Push(runtime, error, obj))
return 0;
return 1;
}