m_uint compile_string(struct Gwion_ *vm, const m_str filename,
const m_str data);
m_uint compile_file(struct Gwion_ *vm, const m_str filename, FILE *file);
+m_uint compile_filename_xid(struct Gwion_ *vm, const m_str filename,
+ const m_uint xid);
+m_uint compile_string_xid(struct Gwion_ *vm, const m_str filename,
+ const m_str data, const m_uint xid);
+m_uint compile_file_xid(struct Gwion_ *vm, const m_str filename, FILE *file,
+ const m_uint xid);
#endif
}
ANN static Vector get_config(const char *name) {
- char * line = NULL;
- size_t len = 0;
- FILE * f = fopen(name, "r");
+ char * line = NULL;
+ size_t len = 0;
+ FILE * f = fopen(name, "r");
CHECK_OO(f);
const Vector v = (Vector)xmalloc(sizeof(struct Vector_));
vector_init(v);
FILE * file;
Ast ast;
struct Vector_ args;
+ VM_Shred shred;
enum compile_type type;
};
if (compiler_open(c) < 0) return 0;
if (_check(gwion, c) < 0) return 0;
if (gwion->emit->info->code) {
- const VM_Shred shred = new_vm_shred(gwion->mp, gwion->emit->info->code);
- shred->info->args.ptr = c->args.ptr;
- vm_add_shred(gwion->vm, shred);
+ c->shred = new_vm_shred(gwion->mp, gwion->emit->info->code);
+ c->shred->info->args.ptr = c->args.ptr;
+ vm_add_shred(gwion->vm, c->shred);
gwion->emit->info->code = NULL;
- return shred->tick->xid;
+ return c->shred->tick->xid;
}
return GW_OK;
}
struct Compiler c = {.base = filename, .type = COMPILE_FILE, .file = file};
return compile(gwion, &c);
}
+
+ANN m_uint compile_filename_xid(struct Gwion_ *gwion, const m_str filename,
+ const m_uint xid) {
+ struct Compiler c = {.base = filename, .type = COMPILE_NAME};
+ if (!compile(gwion, &c)) return 0;
+ return c.shred->tick->xid = xid;
+}
+
+ANN m_uint compile_string_xid(struct Gwion_ *gwion, const m_str filename,
+ const m_str data, const m_uint xid) {
+ struct Compiler c = {.base = filename, .type = COMPILE_MSTR, .data = data};
+ if (!compile(gwion, &c)) return 0;
+ return c.shred->tick->xid = xid;
+}
+
+ANN m_uint compile_file_xid(struct Gwion_ *gwion, const m_str filename,
+ FILE *file, const m_uint xid) {
+ struct Compiler c = {.base = filename, .type = COMPILE_FILE, .file = file};
+ if (!compile(gwion, &c)) return 0;
+ return c.shred->tick->xid = xid;
+}
}
typedef void (*cleaner)(MemPool, ImportCK *);
-static cleaner cleaners[] = {NULL, ck_clean_udef, ck_clean_tdef,
+static cleaner cleaners[] = {NULL, ck_clean_udef, ck_clean_tdef,
NULL, // ck_clean_oper,
ck_clean_item, ck_clean_fdef};
ANN void ck_clean(const Gwi gwi) {
- cleaners[gwi->ck->type](gwi->gwion->mp, gwi->ck);
+ const cleaner clean = cleaners[gwi->ck->type];
+ if (clean) clean(gwi->gwion->mp, gwi->ck);
memset(gwi->ck, 0, sizeof(ImportCK));
}
gwerr_basic(_("invalid operator decay"),
_("Decayed operators take two arguments"), NULL, env->name, loc,
0);
- if (fdef) gwerr_secondary("declared here", env->name, fdef->base->pos);
+ if (fdef) defined_here(fdef->base->func->value_ref);
env->context->error = true;
}
}
-
static m_bool op_call_narg(const Env env, Exp arg, const loc_t loc) {
m_uint narg = 0;
while (arg) {
gwerr_basic("invalid variable access", "is private", NULL, env->name,
exp_self(member)->pos, 0);
env_error_footer(env);
- gwerr_secondary("declared here", value->from->filename, value->from->loc);
+ defined_here(value);
env->context->error = true;
} else if (GET_FLAG(value, protect))
exp_setprot(exp_self(member), 1);
*done = true;
gw_err("{-/}did you mean{0}:\n");
}
- if (!vflag(value, vflag_builtin))
- gwerr_secondary("declared here", value->from->filename,
- value->from->loc);
+ if (!vflag(value, vflag_builtin)) defined_here(value);
}
}
}