version 1.134, 2003/11/09 11:51:55
|
version 1.135, 2003/11/09 12:15:11
|
Line 1109 Cell compile_prim_dyn(PrimNum p, Cell *t
|
Line 1109 Cell compile_prim_dyn(PrimNum p, Cell *t
|
{ |
{ |
PrimInfo *pi=&priminfos[p]; |
PrimInfo *pi=&priminfos[p]; |
Cell *next_code_target=NULL; |
Cell *next_code_target=NULL; |
Cell codeaddr = (Cell)code_here; |
Address codeaddr; |
|
Address primstart; |
|
|
assert(p<npriminfos); |
assert(p<npriminfos); |
if (p==N_execute || p==N_perform || p==N_lit_perform) { |
if (p==N_execute || p==N_perform || p==N_lit_perform) { |
codeaddr = compile_prim1arg(N_set_next_code, &next_code_target); |
codeaddr = compile_prim1arg(N_set_next_code, &next_code_target); |
} |
primstart = append_prim(p); |
if (p==N_call) { |
goto other_prim; |
|
} else if (p==N_call) { |
codeaddr = compile_call2(tcp[1], &next_code_target); |
codeaddr = compile_call2(tcp[1], &next_code_target); |
} else if (p==N_does_exec) { |
} else if (p==N_does_exec) { |
struct doesexecinfo *dei = &doesexecinfos[ndoesexecinfos++]; |
struct doesexecinfo *dei = &doesexecinfos[ndoesexecinfos++]; |
Line 1136 Cell compile_prim_dyn(PrimNum p, Cell *t
|
Line 1138 Cell compile_prim_dyn(PrimNum p, Cell *t
|
set_rel_target(branch_target,vm_prims[p]); |
set_rel_target(branch_target,vm_prims[p]); |
} else { |
} else { |
unsigned j; |
unsigned j; |
Address old_code_here = append_prim(p); |
|
|
codeaddr = primstart = append_prim(p); |
|
other_prim: |
for (j=0; j<pi->nimmargs; j++) { |
for (j=0; j<pi->nimmargs; j++) { |
struct immarg *ia = &(pi->immargs[j]); |
struct immarg *ia = &(pi->immargs[j]); |
Cell argval = tcp[pi->nimmargs - j]; /* !! specific to prims */ |
Cell argval = tcp[pi->nimmargs - j]; /* !! specific to prims */ |
if (ia->rel) { /* !! assumption: relative refs are branches */ |
if (ia->rel) { /* !! assumption: relative refs are branches */ |
register_branchinfo(old_code_here + ia->offset, argval); |
register_branchinfo(primstart + ia->offset, argval); |
} else /* plain argument */ |
} else /* plain argument */ |
*(Cell *)(old_code_here + ia->offset) = argval; |
*(Cell *)(primstart + ia->offset) = argval; |
} |
} |
} |
} |
if (next_code_target!=NULL) |
if (next_code_target!=NULL) |
*next_code_target = (Cell)code_here; |
*next_code_target = (Cell)code_here; |
return codeaddr; |
return (Cell)codeaddr; |
} |
} |
#else /* !defined(NO_IP) */ |
#else /* !defined(NO_IP) */ |
Cell compile_prim_dyn(PrimNum p, Cell *tcp) |
Cell compile_prim_dyn(PrimNum p, Cell *tcp) |