bugfix
This commit is contained in:
+5
-11
@@ -1,12 +1,6 @@
|
|||||||
|
|
||||||
p = 1;
|
if false
|
||||||
return p;
|
a = 1;
|
||||||
|
else
|
||||||
if true
|
a = 2;
|
||||||
{
|
return a;
|
||||||
x = 7;
|
|
||||||
2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
4;
|
|
||||||
return x;
|
|
||||||
+2
-22
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
Object *result = run(runtime, (Error*) &error, exe, 0, NULL, 0);
|
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);
|
fprintf(stderr, "RUNTIME ERROR: %s.\n", error.base.message);
|
||||||
|
|
||||||
@@ -213,28 +213,8 @@ int main(int argc, char **argv)
|
|||||||
Runtime_Free(runtime);
|
Runtime_Free(runtime);
|
||||||
return 1;
|
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);
|
Runtime_Free(runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -462,6 +462,10 @@ static _Bool step(Runtime *runtime, Error *error)
|
|||||||
Error_Report(error, 1, "Reference to undefined variable \"%s\"", ops[0].as_string);
|
Error_Report(error, 1, "Reference to undefined variable \"%s\"", ops[0].as_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Runtime_Push(runtime, error, obj))
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user