#ifndef __COMPILE
#define __COMPILE
--m_uint compile_filename_values(struct Gwion_ *vm, const m_str filename, MP_Vector*);
--m_uint compile_string_values(struct Gwion_ *vm, const m_str filename,
-- const m_str data, MP_Vector*);
--m_uint compile_file_values(struct Gwion_ *vm, const m_str filename, FILE *file, MP_Vector*);
--m_uint compile_filename_xid_values(struct Gwion_ *vm, const m_str filename,
++m_uint compile_filename_values(struct Gwion_ *vm, const char * filename, MP_Vector*);
++m_uint compile_string_values(struct Gwion_ *vm, const char * filename,
++ const char * data, MP_Vector*);
++m_uint compile_file_values(struct Gwion_ *vm, const char * filename, FILE *file, MP_Vector*);
++m_uint compile_filename_xid_values(struct Gwion_ *vm, const char * filename,
const m_uint xid, MP_Vector*);
--m_uint compile_string_xid_values(struct Gwion_ *vm, const m_str filename,
-- const m_str data, const m_uint xid, MP_Vector*);
--m_uint compile_file_xid_values(struct Gwion_ *vm, const m_str filename, FILE *file,
++m_uint compile_string_xid_values(struct Gwion_ *vm, const char * filename,
++ const char * data, const m_uint xid, MP_Vector*);
++m_uint compile_file_xid_values(struct Gwion_ *vm, const char * filename, FILE *file,
const m_uint xid, MP_Vector*);
#define compile_filename(a, b) compile_filename_values(a, b, NULL)
#define compile_string(a, b, c) compile_string_values(a, b, c, NULL)
ANN static inline void emit_push_code(const Emitter emit, const m_str name) {
vector_add(&emit->stack, (vtype)emit->code);
emit->code = new_code(emit, name);
-- if (emit->info->debug) emit_add_instr(emit, DebugLine);
++ if (emit->info->debug) {
++ const Instr instr = emit_add_instr(emit, DebugLine);
++ instr->m_val = emit->status.line;
++ }
}
ANN static inline void emit_pop_code(const Emitter emit) {
m_str name;
Nspc nspc;
struct TypeInfo_ *info;
-- uint64_t size;
-- uint64_t actual_size;
--// struct Vector_ effects; // pre-ctor effects
-- uint32_t array_depth;
++ uint32_t size;
++ uint32_t actual_size;
++ uint32_t array_depth; // TODO: encode in array type
uint16_t ref;
uint16_t weight;
ae_flag flag;
ANN bool gwi_typedef_ini(const Gwi gwi, const restrict m_str type,
const restrict m_str name);
ANN bool gwi_typedef_exp(const Gwi gwi, const restrict m_str data);
--ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag);
++ANN bool gwi_typedef_end(const Gwi gwi, const ae_flag flag);
ANN void ck_clean_tdef(MemPool, ImportCK *);
ANN Type mk_primitive(const Env env, const m_str name, const m_uint size);
ANN bool gwimport_event(const Gwi gwi);
ANN bool gwimport_ugen(const Gwi gwi);
ANN bool gwimport_array(const Gwi gwi);
++ANN bool gwimport_vector(const Gwi gwi);
ANN bool gwimport_xork(const Gwi gwi);
ANN bool gwimport_modules(const Gwi gwi);
ANN bool gwimport_object_op(const Gwi gwi);
ePerformEffect,
eNoOp,
eDebugLine,
-- eDebugValue,
eDebugPush,
eDebugPop,
eEOC,
#define PerformEffect (f_instr)ePerformEffect
#define NoOp (f_instr)eNoOp
#define DebugLine (f_instr)eDebugLine
--#define DebugValue (f_instr)eDebugValue
#define DebugPush (f_instr)eDebugPush
#define DebugPop (f_instr)eDebugPop
#define EOC (f_instr)eEOC
gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val);
gw_out("\n");
break;
-- case eDebugValue:
-- gw_out("{Y}┃{0}{-}% 4lu{0}: DebugValue ", j);
-- gw_out("\n");
-- break;
case eDebugPush:
gw_out("{Y}┃{0}{-}% 4lu{0}: DebugPush ", j);
gw_out("\n");
ANN void* op_get(const Env env, struct Op_Import *opi);
ANN Type op_check(const Env, struct Op_Import *);
ANN bool op_emit(const Emitter, const struct Op_Import *);
--ANN bool operator_set_func(const struct Op_Import *);
++ANN bool operator_set_func(const Env, const struct Op_Import *);
ANN void free_op_map(Map map, struct Gwion_ *gwion);
ANN void free_op_tmpl(Vector v, struct Gwion_ *gwion);
--ANN void operator_suspend(const Nspc, struct Op_Import *);
++ANN void operator_suspend(const Gwion, struct Op_Import *);
ANN static inline void operator_resume(struct Op_Import *opi) {
assert(opi->ret);
*(uintptr_t *)opi->ret = opi->data;
ANN static inline void vm_run(const VM *vm) {
vm_prepare(vm, NULL);
}
++void vm_force_run(const VM *vm);
ANN void vm_run_audio(const VM *vm);
ANEW VM * new_vm(MemPool, const bool);
ANN void vm_lock(VM const *);
PerformEffect
NoOp
DebugLine~u
--DebugValue
DebugPush
DebugPop
EOC
enum compile_type { COMPILE_NAME, COMPILE_MSTR, COMPILE_FILE };
struct Compiler {
-- const m_str base;
++ const char *base;
m_str name;
union {
-- m_str data;
-- FILE * file;
++ const char* data;
++ FILE * file;
};
Ast ast;
struct Vector_ args;
xfree(name);
return c->name ? !!(c->file = fopen(c->name, "r")) : false;
} else if (c->type == COMPILE_MSTR) {
-- c->file = c->data ? fmemopen(c->data, strlen(c->data), "r") : NULL;
++ c->file = c->data ? fmemopen((void*)c->data, strlen(c->data), "r") : NULL;
return !!c->file;
}
return true;
load_context(ctx, env);
for(uint32_t i = 0; i < mp_vector_len(c->values); i++) {
const Value v = *mp_vector_at(c->values, Value, i);
-- set_vflag(v, vflag_builtin);
++ set_vflag(v, vflag_builtin); // TODO: we should copy the values, maybe
if(isa(v->type, gwion->type[et_class])) {
const Type t = (Type)v->d.ptr;
type_addref(t);
return ret;
}
--ANN m_uint compile_filename_values(struct Gwion_ *gwion, const m_str filename, MP_Vector *values) {
++ANN m_uint compile_filename_values(struct Gwion_ *gwion, const char *filename, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_NAME, .values=values};
return compile(gwion, &c);
}
--ANN m_uint compile_string_values(struct Gwion_ *gwion, const m_str filename,
-- const m_str data, MP_Vector *values) {
++ANN m_uint compile_string_values(struct Gwion_ *gwion, const char *filename,
++ const char *data, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_MSTR, .data = data, .values=values};
return compile(gwion, &c);
}
--ANN m_uint compile_file_values(struct Gwion_ *gwion, const m_str filename,
++ANN m_uint compile_file_values(struct Gwion_ *gwion, const char *filename,
FILE *file, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_FILE, .file = file, .values=values};
return compile(gwion, &c);
}
--ANN m_uint compile_filename_xid_values(struct Gwion_ *gwion, const m_str filename,
++ANN m_uint compile_filename_xid_values(struct Gwion_ *gwion, const char* filename,
const m_uint xid, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_NAME, .values=values};
if (!compile(gwion, &c)) return 0;
return c.shred->tick->xid = xid;
}
--ANN m_uint compile_string_xid_values(struct Gwion_ *gwion, const m_str filename,
-- const m_str data, const m_uint xid, MP_Vector *values) {
++ANN m_uint compile_string_xid_values(struct Gwion_ *gwion, const char *filename,
++ const char *data, const m_uint xid, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_MSTR, .data = data, .values=values};
if (!compile(gwion, &c)) return 0;
assert(c.shred);
return c.shred->tick->xid = xid;
}
--ANN m_uint compile_file_xid_values(struct Gwion_ *gwion, const m_str filename,
++ANN m_uint compile_file_xid_values(struct Gwion_ *gwion, const char * filename,
FILE *file, const m_uint xid, MP_Vector *values) {
struct Compiler c = {.base = filename, .type = COMPILE_FILE, .file = file, .values=values};
if (!compile(gwion, &c)) return 0;
return env_push_global(emit->env);
}
--static inline void emit_debug(const Emitter emit, const Value v) {
-- if (!emit->info->debug) return;
-- const Instr instr = emit_add_instr(emit, DebugValue);
-- instr->m_val = (m_uint)v;
--}
ANEW static Frame *new_frame(MemPool p) {
Frame *frame = mp_calloc(p, Frame);
ANN void emit_push_scope(const Emitter emit) {
frame_push(emit->code->frame);
vector_add(&emit->info->pure, 0);
-- if (emit->info->debug) emit_add_instr(emit, DebugPush);
++ //if (emit->info->debug) emit_add_instr(emit, DebugPush);
++ if (emit->info->debug) {
++
++ const Instr instr = emit_add_instr(emit, DebugPush);
++ instr->m_val = emit->status.line;
++ }
}
ANN m_uint emit_code_offset(const Emitter emit) {
const MP_Vector *v =(MP_Vector*)instr->m_val;
for(uint32_t i = 0; i < v->len; i++) {
const Func f = *mp_vector_at(v, Func, i);
-- const Instr instr = (Instr)vector_front(&f->code->instr);
-- instr->m_val2++;
++ for(m_uint j = 0; i < vector_size(&f->code->instr); j++) {
++ const Instr instr = (Instr)vector_at(&f->code->instr, j);
++ if(instr->execute == FuncWait) {
++ instr->m_val2++;
++ break;
++ }
++ }
}
}
ANN static void used_by(const Emitter emit, const Value v) {
++puts("emit used by");
MP_Vector *vec = new_mp_vector(emit->gwion->mp, Func, 0);
for(uint32_t i = 0; i < v->used_by->len; i++) {
const Func f = *mp_vector_at(v->used_by, Func, i);
++ if(f->_wait) puts("Adding to wait list");
if(f->_wait) mp_vector_add(emit->gwion->mp, &vec, Func, f);
}
free_mp_vector(emit->gwion->mp, Func, v->used_by);
else CHECK_B(emit_exp(emit, decl->args));
}
f_instr *exec = (f_instr *)allocmember;
-- if (!emit->env->scope->depth) emit_debug(emit, v);
if (!vflag(v, vflag_member)) {
if(v->used_by) used_by(emit, v);
v->from->offset = decl_non_static_offset(emit, decl, type);
ANN2(1) /*static */ bool emit_exp(const Emitter emit, /* const */ Exp* e) {
Exp* exp = e;
do {
-- if (emit->info->debug && emit->status.line < e->loc.first.line) {
++ if (emit->info->debug){
++
++printf("debug line: %i\n", e->loc.first.line);
++ if(emit->status.line < e->loc.first.line) {
const Instr instr = emit_add_instr(emit, DebugLine);
instr->m_val = emit->status.line = e->loc.first.line;
}
++ emit->status.line = e->loc.first.line;
++ }
CHECK_B(emit_exp_func[exp->exp_type](emit, &exp->d));
if (exp->cast_to) CHECK_B(emit_implicit_cast(emit, exp, exp->cast_to));
if (is_object(emit->gwion, exp->type) &&
stmt->var.value->from->offset = val_offset;
//value_addref(stmt->v);
_nspc_add_value(emit->env->curr, stmt->var.tag.sym, stmt->var.value);
-- emit_debug(emit, stmt->var.value);
if (stmt->idx.tag.sym) {
stmt->idx.value->from->offset = key_offset;
_nspc_add_value(emit->env->curr, stmt->idx.tag.sym, stmt->var.value);
//value_addref(stmt->idx->v);
-- emit_debug(emit, stmt->idx.value);
}
struct Looper loop = {.exp = stmt->exp,
.stmt = stmt->body,
ANN static inline void emit_func_def_init(const Emitter emit, const Func func) {
emit_push_code(emit, func->name);
if(mp_vector_len(func->_wait)) {
++puts("wait");
const Instr instr = emit_add_instr(emit, FuncWait);
instr->m_val = (m_uint) func;
}
const Type type = arg->var.vd.value->type;
emit->code->stack_depth += type->size;
arg->var.vd.value->from->offset = emit_localn(emit, type);
-- emit_debug(emit, arg->var.vd.value);
_nspc_add_value(emit->env->curr, insert_symbol(arg->var.vd.value->name), arg->var.vd.value);
}
}
ANN2(1) void emit_fast_except(const Emitter emit, const ValueFrom *vf, const loc_t loc) {
const Instr instr = emit_add_instr(emit, fast_except);
-- if(vf) {
++ if(!emit->info->debug && vf) {
struct FastExceptInfo *info = mp_malloc2(emit->gwion->mp, sizeof(struct FastExceptInfo));
info->file = emit->env->name;
info->loc = loc;
#include "emit.h"
#include "escape.h"
--char escape_table[256] = {
++static char escape_table[256] = {
['0'] = '0',
['\''] = '\'',
['"'] = '"',
}
} else {
char out;
-- CHECK_B((*str++ = (char)get_escape(emit, (char)c, &out, loc)));
++ CHECK_B(get_escape(emit, (char)c, &out, loc));
++ *str++ = out;
}
} else
*str++ = (char)*str_lit;
ANN Type find_type(const Env env, Type_Decl *td) {
DECL_O(Type, type, = find_initial(env, td->tag.sym));
while ((td = td->next) && type && type->nspc) {
-- const Nspc nspc = type->nspc;
-- if(!(type = find_in_parent(type, td->tag.sym)))
- ERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
-s_name(td->tag.sym), nspc->name);
++// const Nspc nspc = type->nspc;
++// if(!(type = find_in_parent(type, td->tag.sym)))
++//
++ //enERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
++//s_name(td->tag.sym), nspc->name);
++
+
-/*
- if(!type)
- ERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
- s_name(td->tag.sym), nspc->name);
+ Type_Decl *next = td->next;
+ td->next = NULL;
+ env_push_type(env, type);
+ type = known_type(env, td);
++ if(!type)
+ ERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
- s_name(td->tag.sym), nspc->name);
++ s_name(td->tag.sym), env->class_def->name);
+ env_pop(env, 0); // respect scope depth // use env scope
+ td->next = next;
-*/
++
}
return type;
}
ANN void print_signature(const Gwion gwion, const Func f) {
struct GwfmtState ls = {.minimize=true, .ppa = gwion->ppa};
++// gwfmt_state_init(&ls);
text_init(&ls.text, gwion->mp);
Gwfmt l = {.mp = gwion->mp, .st = gwion->st, .ls = &ls, .line = 1, .last = cht_nl };
gwfmt_func_def(&l, f->def);
}
*/
env_pop(gwi->gwion->env, 0);
-- return false;
++ return true;
}
ANEW ANN m_str tl2str(const Gwion gwion, const TmplArg_List tl,
const loc_t loc NUSED) {
struct GwfmtState ls = {.minimize=true, .ppa = gwion->ppa};
++// gwfmt_state_init(&ls);
text_init(&ls.text, gwion->mp);
Gwfmt l = {.mp = gwion->mp, .st = gwion->st, .ls = &ls, .line = 1, .last = cht_nl };
struct td_info info = {.tl = tl, .fmt = &l };
ANN static bool run_with_doc(const Gwi gwi, bool (*f)(const Gwi)) {
struct GwfmtState ls = {.builtin = true, .nindent = 4};
++// gwfmt_state_init(&ls);
text_init(&ls.text, gwi->gwion->mp);
Gwfmt gwfmter = {.mp = gwi->gwion->mp, .ls = &ls, .st = gwi->gwion->st };
gwfmt_indent(&gwfmter);
return true;
}
--ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
++ANN bool gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
CHECK_O(ck_ok(gwi, ck_tdef));
Type_Decl *td = gwi->ck->td;
td->flag |= flag;
new_type_def(gwi->gwion->mp, td, gwi->ck->sym, gwi->loc);
if (gwi->ck->when) tdef->when = gwi->ck->when;
if (gwi->ck->tmpl) tdef->tmpl = gwi_tmpl(gwi);
- return 1;
+
+ if (safe_tflag(gwi->gwion->env->class_def, tflag_tmpl)) {
+ Section section = MK_SECTION(
+ type, type_def, tdef, gwi->loc
+ );
+ gwi_body(gwi, §ion);
+ ck_end(gwi);
++ return true;
+ }
+
gwi->ck->td = NULL;
gwi->ck->tmpl = NULL;
const bool ret = traverse_type_def(gwi->gwion->env, tdef);
tflag_emit);
free_type_def(gwi->gwion->mp, tdef);
ck_end(gwi);
-- return ret ? t : NULL;
++ return ret;
}
ANN void ck_clean_tdef(MemPool mp, ImportCK *ck) {
set_tflag(t_time, tflag_float);
gwidoc(gwi, "internal time for `{/}now{0}{-}`.");
-- const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, "time");
++ const Type t_now = gwi_mk_type(gwi, "Now", SZ_FLOAT, "time");
GWI_B(gwi_add_type(gwi, t_now))
struct SpecialId_ spid = {.type = t_now, .exec = RegPushNow, .is_const = 1};
gwi_specialid(gwi, "now", &spid);
GWI_B(gwimport_object_op(gwi))
GWI_B(gwimport_values(gwi))
GWI_B(gwimport_union(gwi))
--
GWI_B(gwimport_array(gwi))
+ GWI_B(gwimport_vector(gwi))
GWI_B(gwimport_event(gwi))
GWI_B(gwimport_ugen(gwi))
GWI_B(gwimport_xork(gwi))
GWI_B(gwi_func_ini(gwi, "void", "broadcast"))
GWI_B(gwi_func_end(gwi, event_broadcast, ae_flag_none))
GWI_B(gwi_class_end(gwi))
-- GWI_B(gwi_oper_ini(gwi, "Event", "@now", "int"))
++ GWI_B(gwi_oper_ini(gwi, "Event", "Now", "int"))
GWI_B(gwi_oper_end(gwi, "=>", EventWait))
return true;
}
shred->reg += SZ_INT;
}
++// TODO: do not add info in debug mode
++// maybe
INSTR(FuncWait) {
const Func f = (Func)instr->m_val;
if(f->_wait->len - instr->m_val2) {
GWI_B(gwi_oper_ini(gwi, "dur", "time", "time"))
CHECK_FF(":=>", rassign, r_assign)
GWI_B(gwi_oper_end(gwi, "+", float_add))
-- GWI_B(gwi_oper_ini(gwi, "dur", "@now", "time"))
++ GWI_B(gwi_oper_ini(gwi, "dur", "Now", "time"))
_CHECK_OP("=>", now, Dur_Advance)
GWI_B(gwi_oper_ini(gwi, "time", "time", "bool"))
GWI_B(gwi_oper_end(gwi, "=>", Time_Advance))
if (env->func && strcmp(env->func->name, "in spork")) {
// if(vflag(v, vflag_fglobal) /*&& !vflag(v, vflag_builtin) */&& !is_func(env->gwion, v->type)) {
-- if((GET_FLAG(v, global) || vflag(v, vflag_fglobal)) && !vflag(v, vflag_builtin) && !is_func(env->gwion, v->type)) {
++ if(GET_FLAG(v, global) && !vflag(v, vflag_builtin) && !is_func(env->gwion, v->type)) {
if(!env->func->_wait)
env->func->_wait = new_mp_vector(env->gwion->mp, Value, 0);
if (!v->used_by) {
struct Op_Import opi = {};
if (fbflag(fdef->base, fbflag_op)) {
func_operator(f, &opi);
-- operator_suspend(env->curr, &opi);
++ operator_suspend(env->gwion, &opi);
}
if(fdef->captures) {
uint32_t offset = fdef->stack_depth;
const Value v = new_value(env, targ.d.exp->type, MK_TAG(spec.tag.sym, targ.d.exp->loc));
valuefrom(env, v->from);
set_vflag(v, vflag_valid);
-- //nspc_add_value(nspc, spec.tag.sym, v);
-- nspc_add_value_front(t->nspc, spec.tag.sym, v);
++ nspc_add_value(t->nspc, spec.tag.sym, v);
SET_FLAG(v, const| ae_flag_static);
set_vflag(v, vflag_builtin);
}
}
ANN bool check_class_def(const Env env, const Class_Def cdef) {
-- if (tmpl_base(cdef->base.tmpl)) return true;
++ if (tmpl_base(cdef->base.tmpl))
++ return true;
const Type t = cdef->base.type;
if (tflag(t, tflag_check)) return true;
set_tflag(t, tflag_check);
return NULL;
}
--ANN void operator_suspend(const Nspc n, struct Op_Import *opi) {
++ANN Nspc get_nspc(const Env env) {
++ if(SAFE_FLAG(env->func, private)) // how come
++ return env->curr;
++ Type t = env->class_def;
++ while (t) {
++ if(GET_FLAG(t, private))
++ return t->nspc;
++ t = t->info->value->from->owner_class;
++ }
++ // does not take global into account tho
++ // or does it?
++ if(env->curr == env->global_nspc)
++ return env->curr;
++ return env->context
++ ? env->context->nspc
++ : env->curr;
++}
++
++// 1st arg could be Env
++ANN void operator_suspend(const Gwion gwion, struct Op_Import *opi) {
++ // Nspc n = gwion->env->context
++ // ? gwion->env->context->nspc
++ // : gwion->env->curr;
++ const Nspc n = get_nspc(gwion->env);
const m_int idx = map_index(&n->operators->map, (vtype)opi->op);
const Vector v = (Vector)&VVAL(&n->operators->map, idx);
for (m_uint i = vector_size(v) + 1; --i;) {
CHECK_B(op_exist(&ock, n));
}
} while ((n = n->parent));
-- if (!gwion->env->curr->operators)
-- gwion->env->curr->operators = mp_calloc(gwion->mp, NspcOp);
-- if (!gwion->env->curr->operators->map.ptr)
-- map_init(&gwion->env->curr->operators->map);
++ // Nspc nspc = gwion->env->context
++ // ? gwion->env->context->nspc
++ // : gwion->env->curr;
++ const Nspc nspc = get_nspc(gwion->env);
++ if (!nspc->operators)
++ nspc->operators = mp_calloc(gwion->mp, NspcOp);
++ if (!nspc->operators->map.ptr)
++ map_init(&nspc->operators->map);
struct OpChecker ock = {
-- .env = gwion->env, .map = &gwion->env->curr->operators->map, .opi = opi};
++ .env = gwion->env, .map = &nspc->operators->map, .opi = opi};
const Vector v = op_vector(&ock);
const M_Operator *mo = new_mo(gwion->mp, opi);
vector_add(v, (vtype)mo);
if (!strcmp(op, "$") && opi->rhs == opi->lhs)
return opi->rhs;
if (!strcmp(op, "@func_check")) return NULL;
-- if(!strcmp(op, "=>") && !strcmp(opi->rhs->name, "@now")) {
++ if(!strcmp(op, "=>") && !strcmp(opi->rhs->name, "Now")) {
gwlog_error(_("no match found for operator"), "expected duration", env->name, opi->loc, 0);
gwlog_hint(_("did you try converting to `dur`?"), env->name, opi->loc);
env_set_error(env, true);
return NULL;
}
--ANN bool operator_set_func(const struct Op_Import *opi) {
-- const Nspc nspc = ((Func)opi->data)->value_ref->from->owner;
++ANN bool operator_set_func(const Env env, const struct Op_Import *opi) {
++ //const Nspc nspc = ((Func)opi->data)->value_ref->from->owner;
++ //const Nspc nspc = ((Func)opi->data)->value_ref->from->ctx->nspc;
++ const Nspc nspc = get_nspc(env);
const m_int idx = map_index(&nspc->operators->map, (vtype)opi->op);
const Vector v = (Vector)&VVAL(&nspc->operators->map, idx);
DECL_B(M_Operator *, mo, = operator_find(v, opi->lhs, opi->rhs));
.func = &opfunc};
func_operator(f, &opi);
CHECK_B(add_op(env->gwion, &opi));
-- operator_set_func(&opi);
++ operator_set_func(env, &opi);
return true;
}
ANN m_str tdpp(MemPool mp, SymTable *st, const Type_Decl *td,
const bool no_color, const bool minimize) {
struct GwfmtState ls = { .minimize = minimize,};
++// gwfmt_state_init(&ls);
text_init(&ls.text, mp);
Gwfmt gwfmter = {.mp = mp, .ls = &ls, .st = st };
bool has_color = tcol_has_color();
}
loc_t loc = {.first = {.line = line, .column = 1},
.last = {.line = line, .column = 1}};
-- gwlog_related("called from here", code_name(shred->code->name, true), loc);
-- gw_err(" {M}┗━╸{0} {-}in code{0} {+W}%s{0}{-}:{0}\n", shred->code->name);
++ char *filename = strrchr(shred->code->name, '@');
++ char *better_name = filename ? filename + 1: code_name(shred->code->name, true);
++ puts(better_name);
++ //gwlog_related("called from here", code_file(shred->code->name, true), loc);
++ gwlog_related("called from here", better_name, loc);
++ gw_err(" {+B}┗━╸{0} {-}in code{0} {+W}%s{0}{-}:{0}\n", better_name);
if (shred->mem == (m_bit *)shred + sizeof(struct VM_Shred_) + SIZEOF_REG)
return;
shred_unwind(shred);
&&unionother, &&unionaddr, &&staticint, &&staticfloat, &&staticother,
&&dotfunc, &&gacktype, &&gackend, &&gack, &&try_ini,
&&try_end, &&handleeffect, &&performeffect, &&noop, &&debugline,
-- &&debugvalue, &&debugpush, &&debugpop, &&eoc, &&vmin, &&other};
++ &&debugpush, &&debugpop, &&eoc, &&vmin, &&other};
// &®pushimm};
if(!prepare_code) {
vector_set(&shred->info->line, sz - 1, VAL);
}
DISPATCH();
-- debugvalue:
-- DISPATCH();
debugpush:
if (!shred->info->line.ptr) vector_init(&shred->info->line);
vector_add(&shred->info->line, 0);
&&_unionother, &&_unionaddr, &&_staticint, &&_staticfloat, &&_staticother,
&&_dotfunc, &&_gacktype, &&_gackend, &&_gack, &&_try_ini,
&&_try_end, &&_handleeffect, &&_performeffect, &&_noop, &&_debugline,
-- &&_debugvalue, &&_debugpush, &&_debugpop, &&_eoc, &&_vmin, &&_other};
++ &&_debugpush, &&_debugpop, &&_eoc, &&_vmin, &&_other};
#define PREPARE(a) \
_##a: \
}
PREPARE(vmin);
PREPARE(debugline);
-- PREPARE(debugvalue);
PREPARE(debugpush);
PREPARE(debugpop);
_eoc:
compute_audio(vm);
}
++void vm_force_run(const VM *vm) {
++ const bool is_running = vm->shreduler->bbq->is_running;
++ vm_run(vm);
++ vm->shreduler->bbq->is_running = is_running;
++}
++
VM *new_vm(MemPool p, const bool audio) {
VM *vm = (VM *)mp_calloc(p, VM);
vector_init(&vm->ugen);