diff --git a/src/load.c b/src/load.c index af79643a..5a55df2b 100644 --- a/src/load.c +++ b/src/load.c @@ -127,12 +127,13 @@ HArr* comps_curr; B rt_undo, rt_select, rt_slash, rt_insert, rt_depth, rt_group, rt_under, rt_find; -Block* load_buildBlock(B x, B src, B path, Scope* sc, i32 nsResult) { // consumes x,src +Block* load_buildBlock(B x, B src, B path, B name, Scope* sc, i32 nsResult) { // consumes x,src + B fullpath = q_N(name)? inc(path) : q_N(path)? inc(name) : path_rel(path, inc(name), "(load_buildBlock)"); SGet(x) usz xia = IA(x); if (xia!=6 & xia!=4) thrM("load_buildBlock: bad item count"); - Block* r = xia==6? compileAll(Get(x,0),Get(x,1),Get(x,2),Get(x,3),Get(x,4),Get(x,5), src, inc(path), sc, nsResult) - : compileAll(Get(x,0),Get(x,1),Get(x,2),Get(x,3),bi_N, bi_N, src, inc(path), sc, nsResult); + Block* r = xia==6? compileAll(Get(x,0),Get(x,1),Get(x,2),Get(x,3),Get(x,4),Get(x,5), src, fullpath, sc, nsResult) + : compileAll(Get(x,0),Get(x,1),Get(x,2),Get(x,3),bi_N, bi_N, src, fullpath, sc, nsResult); decG(x); return r; } @@ -170,7 +171,7 @@ void switchComp(void) { } #endif B compObj_c1(B t, B x) { - return evalFunBlockConsume(load_buildBlock(x, bi_N, bi_N, NULL, 0)); + return evalFunBlockConsume(load_buildBlock(x, bi_N, bi_N, bi_N, NULL, 0)); } B compObj_c2(B t, B w, B x) { change_def_comp(x); @@ -214,7 +215,7 @@ static NOINLINE Block* bqn_compc(B str, B state, B re) { // consumes str,state str = chr_squeeze(str); COMPS_PUSH(str, state, re); B* o = harr_ptr(re); - Block* r = load_buildBlock(c2G(o[re_comp], incG(o[re_compOpts]), inc(str)), str, COMPS_CREF(path), NULL, 0); + Block* r = load_buildBlock(c2G(o[re_comp], incG(o[re_compOpts]), inc(str)), str, COMPS_CREF(path), COMPS_CREF(name), NULL, 0); COMPS_POP; popCatch(); return r; } @@ -238,7 +239,7 @@ Block* bqn_compScc(B str, B state, B re, Scope* sc, bool loose, bool noNS) { csc = csc->psc; depth++; } - Block* r = load_buildBlock(c2G(o[re_comp], m_lvB_4(incG(o[re_rt]), incG(bi_sys), vName, vDepth), inc(str)), str, COMPS_CREF(path), sc, sc!=NULL? (noNS? -1 : 1) : 0); + Block* r = load_buildBlock(c2G(o[re_comp], m_lvB_4(incG(o[re_rt]), incG(bi_sys), vName, vDepth), inc(str)), str, COMPS_CREF(path), COMPS_CREF(name), sc, sc!=NULL? (noNS? -1 : 1) : 0); COMPS_POP; popCatch(); return r; } diff --git a/src/ns.c b/src/ns.c index 038b6f4a..61b94987 100644 --- a/src/ns.c +++ b/src/ns.c @@ -112,7 +112,7 @@ Body* m_nnsDescF(i32 n, char** names) { Comp* comp = mm_alloc(sizeof(Comp), t_comp); comp->indices = bi_N; comp->src = bi_N; - comp->path = bi_N; + comp->fullpath = bi_N; comp->objs = c(HArr, emptyHVec()); comp->blockAm = 0; comp->nameList = HARR_FV(nl); diff --git a/src/vm.c b/src/vm.c index fdd201b7..4137ea7f 100644 --- a/src/vm.c +++ b/src/vm.c @@ -453,7 +453,7 @@ Block* compileBlock(B block, Comp* comp, bool* bDone, u32* bc, usz bcIA, B allBl // consumes all; assumes arguments are valid (verifies some stuff, but definitely not everything) // if sc isn't NULL, this block must only be evaluated directly in that scope precisely once -NOINLINE Block* compileAll(B bcq, B objs, B allBlocks, B allBodies, B indices, B tokenInfo, B src, B path, Scope* sc, i32 nsResult) { +NOINLINE Block* compileAll(B bcq, B objs, B allBlocks, B allBodies, B indices, B tokenInfo, B src, B fullpath, Scope* sc, i32 nsResult) { usz bIA = IA(allBlocks); I32Arr* bca = toI32Arr(bcq); u32* bc = (u32*)bca->a; @@ -462,7 +462,7 @@ NOINLINE Block* compileAll(B bcq, B objs, B allBlocks, B allBodies, B indices, B NOGC_S; comp->indices = indices; comp->src = src; - comp->path = path; + comp->fullpath = fullpath; B nameList; if (q_N(tokenInfo)) { nameList = emptyHVec(); @@ -1088,7 +1088,7 @@ DEF_FREE(block) { i32 am = c->bodyCount; for (i32 i = 0; i < am; i++) ptr_decR(c->bodies[i]); } -DEF_FREE(comp) { Comp* c = (Comp *)x; if (c->objs!=NULL) ptr_decR(c->objs); decR(c->src); decR(c->indices); decR(c->path); decR(c->nameList); } +DEF_FREE(comp) { Comp* c = (Comp *)x; if (c->objs!=NULL) ptr_decR(c->objs); decR(c->src); decR(c->indices); decR(c->fullpath); decR(c->nameList); } DEF_FREE(funBl) { FunBlock* c = (FunBlock*)x; ptr_dec(c->sc); ptr_decR(c->bl); } DEF_FREE(md1Bl) { Md1Block* c = (Md1Block*)x; ptr_dec(c->sc); ptr_decR(c->bl); } DEF_FREE(md2Bl) { Md2Block* c = (Md2Block*)x; ptr_dec(c->sc); ptr_decR(c->bl); } @@ -1122,7 +1122,7 @@ void block_visit(Value* x) { i32 am = c->bodyCount; for (i32 i = 0; i < am; i++) mm_visitP(c->bodies[i]); } -void comp_visit(Value* x) { Comp* c = (Comp *)x; if (c->objs!=NULL) mm_visitP(c->objs); mm_visit(c->src); mm_visit(c->indices); mm_visit(c->path); mm_visit(c->nameList); } +void comp_visit(Value* x) { Comp* c = (Comp *)x; if (c->objs!=NULL) mm_visitP(c->objs); mm_visit(c->src); mm_visit(c->indices); mm_visit(c->fullpath); mm_visit(c->nameList); } void funBl_visit(Value* x) { FunBlock* c = (FunBlock*)x; mm_visitP(c->sc); mm_visitP(c->bl); } void md1Bl_visit(Value* x) { Md1Block* c = (Md1Block*)x; mm_visitP(c->sc); mm_visitP(c->bl); } void md2Bl_visit(Value* x) { Md2Block* c = (Md2Block*)x; mm_visitP(c->sc); mm_visitP(c->bl); } @@ -1371,7 +1371,7 @@ NOINLINE void vm_printPos(Comp* comp, i32 bcPos, i64 pos) { #endif if (CATCH) { freeThrown(); goto native_print; } - B msg = vm_fmtPoint(src, emptyCVec(), comp->path, cs, ce); + B msg = vm_fmtPoint(src, emptyCVec(), comp->fullpath, cs, ce); fprintsB(stderr, msg); dec(msg); fputc('\n', stderr); @@ -1557,7 +1557,7 @@ usz profiler_getResults(B* compListRes, B* mapListRes, bool keyPath) { while (c!=profiler_buf_c) { usz bcPos = c->bcPos; Comp* comp = c->comp; - B path = comp->path; + B path = comp->fullpath; i32 idx = profiler_index(&map, q_N(path) || isPathREPL(path)? tag(comp, OBJ_TAG) : path); if (idx == compCount) { compList = vec_addN(compList, tag(comp, OBJ_TAG)); @@ -1602,9 +1602,9 @@ void profiler_displayResults(void) { usz ia = IA(mapObj); for (usz i = 0; i < ia; i++) sum+= m[i]; - if (q_N(c->path)) printf("(anonymous)"); - else if (isPathREPL(c->path)) printf("(REPL)"); - else printsB(c->path); + if (q_N(c->fullpath)) printf("(anonymous)"); + else if (isPathREPL(c->fullpath)) printf("(REPL)"); + else printsB(c->fullpath); if (q_N(c->src)) { printf(": "N64d" samples\n", sum); } else { diff --git a/src/vm.h b/src/vm.h index e80f0c21..4f29c801 100644 --- a/src/vm.h +++ b/src/vm.h @@ -86,7 +86,7 @@ typedef struct ScopeExt ScopeExt; typedef struct Comp { struct Value; B src; - B path; + B fullpath; B indices; B nameList; HArr* objs;