Commit 2ed05f42 authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

reuse zero arg data constructors + correct semantics with forwarding

parent 3d02c031
......@@ -274,8 +274,16 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case CT_THUNK:
{
// TODO: set forward
set_return(root_frame_ptr, &((ThunkEntry*) expr)->thunk);
Thunk* target = get_dst(root_frame_ptr);
Thunk* thunk = &((ThunkEntry*) expr)->thunk;
if(target != NULL)
{
target->desc = (Desc*) __FORWARD_PTR__;
target->_forward_ptr = thunk;
}
set_return(root_frame_ptr, thunk);
destroy_stack_frame(root_frame_ptr);
return;
}
......
......@@ -312,15 +312,13 @@ Code* parseApp(char **ptr, bool dynamic) {
Desc* desc = parseFunName(ptr); // can fail
if(desc != NULL) desc = get_slice(desc, nrArgs);
/*
if(desc->type == FT_ADT || desc->type == FT_SLICE)
if(desc != NULL && (desc->type == FT_ADT || desc->type == FT_SLICE))
{
struct ThunkEntry* entry = (ThunkEntry*) alloc_code(sizeof (ThunkEntry));
entry->base.type = CT_THUNK;
entry->thunk.desc = desc;
return (Code*) entry;
}
*/
entry = (AppEntry*) alloc_code(sizeof (AppEntry));
entry->f = desc;
......
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