Commit b9ecfe99 authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

fix bug

parent be8a06f3
......@@ -173,7 +173,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
switch (expr->type) {
case CT_APP_PRIM1:
{
if(get_dst(root_frame_ptr) == NULL)
if(get_dst(root_frame_ptr) == NULL && (((AppEntry*) expr)->f)->unboxable_return)
{
Thunk* tmp = (Thunk*) alloc_heap(sizeof(Thunk));
set_return(root_frame_ptr, tmp);
......@@ -201,7 +201,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case CT_APP_PRIM2:
{
if(get_dst(root_frame_ptr) == NULL)
if(get_dst(root_frame_ptr) == NULL && (((AppEntry*) expr)->f)->unboxable_return)
{
Thunk* tmp = (Thunk*) alloc_heap(sizeof(Thunk));
set_return(root_frame_ptr, tmp);
......@@ -258,7 +258,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case CT_APP_PRIM:
{
if(get_dst(root_frame_ptr) == NULL)
if(get_dst(root_frame_ptr) == NULL && (((AppEntry*) expr)->f)->unboxable_return)
{
Thunk* tmp = (Thunk*) alloc_heap(sizeof(Thunk));
set_return(root_frame_ptr, tmp);
......
......@@ -19,6 +19,7 @@ struct Desc {
unsigned int arity : 8; // LIMITATION: maximum 32 arguments
unsigned int thunk_size : 10; // It gives false result for strings and arrays
unsigned int hnf : 1; // TODO: unused, remove?
unsigned int unboxable_return : 1;
};
void (*eval)();
......
......@@ -385,7 +385,7 @@ void __trace(int dst_idx)
}
}
void add_prim(int arity, int boxingMap, char* name, void (*exec)(int)) {
void add_prim(int arity, int boxingMap, int unboxableReturn, char* name, void (*exec)(int)) {
int nameLength = strlen(name);
// before the PrimEntry there are "arity" number of SliceEntries
......@@ -396,6 +396,7 @@ void add_prim(int arity, int boxingMap, char* name, void (*exec)(int)) {
entry->base.arity = arity;
entry->base.thunk_size = thunk_size_f(arity);
entry->base.hnf = false;
entry->base.unboxable_return = unboxableReturn;
entry->boxingMap = boxingMap;
entry->exec = exec;
......@@ -410,34 +411,34 @@ void add_prim(int arity, int boxingMap, char* name, void (*exec)(int)) {
}
void init_prim() {
add_prim(2, 0b011, "addI", &__addI);
add_prim(2, 0b011, "subI", &__subI);
add_prim(2, 0b011, "multI", &__multI);
add_prim(2, 0b011, "divI", &__divI);
add_prim(2, 0b011, "gtI", &__gtI);
add_prim(2, 0b011, "geI", &__geI);
add_prim(2, 0b011, "geC", &__geC);
add_prim(2, 0b011, "ltI", &__ltI);
add_prim(2, 0b011, "eqI", &__eqI);
add_prim(2, 0b011, "neqI", &__neqI);
add_prim(2, 0b011, "eqB", &__eqB);
add_prim(2, 0b011, "eqC", &__eqC);
add_prim(1, 0b001, "not", &__not);
add_prim(2, 0b011, "and", &__and);
add_prim(2, 0b011, "or", &__or);
add_prim(2, 0b011, "mod", &__mod);
add_prim(1, 0b001, "C2I", &__C2I);
add_prim(1, 0b001, "I2C", &__I2C);
add_prim(2, 0b011, 1, "addI", &__addI);
add_prim(2, 0b011, 1, "subI", &__subI);
add_prim(2, 0b011, 1, "multI", &__multI);
add_prim(2, 0b011, 1, "divI", &__divI);
add_prim(2, 0b011, 1, "gtI", &__gtI);
add_prim(2, 0b011, 1, "geI", &__geI);
add_prim(2, 0b011, 1, "geC", &__geC);
add_prim(2, 0b011, 1, "ltI", &__ltI);
add_prim(2, 0b011, 1, "eqI", &__eqI);
add_prim(2, 0b011, 1, "neqI", &__neqI);
add_prim(2, 0b011, 1, "eqB", &__eqB);
add_prim(2, 0b011, 1, "eqC", &__eqC);
add_prim(1, 0b001, 1, "not", &__not);
add_prim(2, 0b011, 1, "and", &__and);
add_prim(2, 0b011, 1, "or", &__or);
add_prim(2, 0b011, 1, "mod", &__mod);
add_prim(1, 0b001, 1, "C2I", &__C2I);
add_prim(1, 0b001, 1, "I2C", &__I2C);
add_prim(1, 0b000, "string_size", &__string_size);
add_prim(2, 0b010, "string_select", &__string_select);
add_prim(1, 0b001, "string_create1", &__string_create1);
add_prim(2, 0b011, "string_create2", &__string_create2);
add_prim(3, 0b110, "string_update", &__string_update);
add_prim(3, 0b110, "string_slice", &__string_slice);
add_prim(2, 0b000, "string_append", &__string_append);
add_prim(2, 0b000, "eqS", &__eqS);
add_prim(1, 0b001, "C2S", &__C2S);
add_prim(1, 0b000, 1, "string_size", &__string_size);
add_prim(2, 0b010, 1, "string_select", &__string_select);
add_prim(1, 0b001, 0, "string_create1", &__string_create1);
add_prim(2, 0b011, 0, "string_create2", &__string_create2);
add_prim(3, 0b110, 0, "string_update", &__string_update);
add_prim(3, 0b110, 0, "string_slice", &__string_slice);
add_prim(2, 0b000, 0, "string_append", &__string_append);
add_prim(2, 0b000, 1, "eqS", &__eqS);
add_prim(1, 0b001, 0, "C2S", &__C2S);
add_prim(1, 0b000, "_trace", &__trace);
add_prim(1, 0b000, 0, "_trace", &__trace);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment