Skip to content

Commit

Permalink
Bind functions to their program
Browse files Browse the repository at this point in the history
  • Loading branch information
softmattertheory committed Nov 24, 2024
1 parent 425d5f0 commit 153eb41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2928,6 2928,7 @@ static codeinfo compiler_function(compiler *c, syntaxtreenode *node, registerind
bindx=compiler_addinstruction(c, ENCODE_BYTE(OP_NOP), node);

objectfunction *func = object_newfunction(bindx 1, node->content, compiler_getcurrentfunction(c), 0);
program_bindobject(c->out, (object *) func);

/* Record the class is a method */
if (ismethod) func->klass=compiler_getcurrentclass(c);
Expand Down
1 change: 1 addition & 0 deletions src/datastructures/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 84,7 @@ instructionindx program_getentry(program *p) {
* @details Objects bound to the program are freed with the program; use for static data (e.g. held in constant tables) */
void program_bindobject(program *p, object *obj) {
if (!obj->next && /* Object is not already bound to the program (or something else) */
p->boundlist!=obj &&
obj->status==OBJECT_ISUNMANAGED && /* Object is unmanaged */
(!MORPHO_ISBUILTINFUNCTION(MORPHO_OBJECT(obj))) /* Object is not a built in function that is freed separately */
) {
Expand Down

0 comments on commit 153eb41

Please sign in to comment.