struct M_Vector_ live_values;
uint16_t stack_depth;
uint16_t ref;
- bool is_prepared;
+// bool is_prepared;
bool builtin;
bool callback;
bool is_memoize;
ANN uint32_t gw_rand(uint32_t s[2]);
ANN void gw_seed(uint32_t s[2], const uint64_t);
ANN void handle(VM_Shred shred, const m_str effect);
+#define xfun_handle(shred, effect) {\
+ shred->mem -= ((Instr)vector_at(&shred->code->instr, shred->pc-1))->m_val2; \
+ handle(shred, effect); \
+}
+
ANN bool unwind(const VM_Shred shred, const Symbol effect, const m_uint size);
#define BBQ_POS_MAX 16777216
-Subproject commit 14c74b7ff5f56000c30668fed553d585862deb87
+Subproject commit c3d0108ef59d40a6079f8da1b7a1c79dc1c80d96
}
static MFUN(fptr_default) {
- handle(shred, "EmptyFunctionPointer");
+ xfun_handle(shred, "EmptyFunctionPointer");
}
static GACK(gack_function) { INTERP_PRINTF("%s", t->name); }
const M_Object arg = *(M_Object*)MEM(0);
const m_float ret = basic_locale(STRING(arg));
if(ret == -1.0)
- handle(shred, "invalid value for locale");
+ xfun_handle(shred, "invalid value for locale");
*(m_float*)RETURN = ret;
}
const m_uint offset = !instr->m_val ? SZ_INT : 0;
shred->reg -= SZ_INT * 2 - offset;
const M_Object o = *(M_Object *)(shred->reg + SZ_INT - offset);
- if (!o) {
- handle(shred, "NullPtrException");
- return;
- }
struct UUGen_ *uu = UGEN(o)->module.gen.data;
if (uu->shred) {
free_vm_shred(uu->shred);
}
}
}
- handle(shred, "InvalidShredRequest");
+ xfun_handle(shred, "InvalidShredRequest");
}
static MFUN(shred_args) {
if (s->info->args.ptr && idx >= 0 && (m_uint)idx < vector_size(&s->info->args)) {
const m_str str = (m_str)vector_at(&s->info->args, *(m_uint *)MEM(SZ_INT));
*(M_Object *)RETURN = new_string(shred->info->vm->gwion, str);
- } else
- handle(shred, "InvalidShredArgumentRequest");
+ } else xfun_handle(shred, "InvalidShredArgumentRequest");
}
#ifndef BUILD_ON_WINDOWS
break;
}
if (len - start - end <= 0) {
- handle(shred, "InvalidStringTrimRequest");
+ xfun_handle(shred, "InvalidStringTrimRequest");
return;
}
char c[len - start - end + 1];
const m_uint len = strlen(str);
len_insert = strlen(insert);
if (index >= (m_int)len || index < 0 || (index + len_insert + 1) <= 0) {
- handle(shred, "InvalidStringReplace");
+ xfun_handle(shred, "InvalidStringReplace");
return;
}
char c[index + len_insert + 1];
const m_int _len = *(m_int *)MEM(SZ_INT * 2);
if (!arg || index > (m_int)strlen(STRING(o)) ||
_len > (m_int)strlen(STRING(arg))) {
- handle(shred, "InvalidStringReplace");
+ xfun_handle(shred, "InvalidStringReplace");
return;
}
char insert[strlen(STRING(arg)) + 1];
const m_int size = len - rem + 1;
const m_int start = _start >= 0 ? _start : len - _start;
if (start >= len || size <= 0) {
- handle(shred, "InvalidStringErase");
+ xfun_handle(shred, "InvalidStringErase");
return;
}
char c[size];
const m_str path = STRING(*(M_Object*)MEM(SZ_INT));
FILE *f = fopen(path, "w");
if(!f) {
- handle(shred, "StringLoadException");
+ xfun_handle(shred, "StringLoadException");
return;
}
const m_str str = STRING(o);
const m_str path = STRING(*(M_Object*)MEM(0));
FILE *f = fopen(path, "r");
if(!f) {
- handle(shred, "StringLoadException");
+ xfun_handle(shred, "StringLoadException");
return;
}
fseek(f, 0, SEEK_END);
char *endptr = NULL;
if(!(*(m_int*)RETURN = strtol(str, &endptr, 10))) {
if(errno == EINVAL) {
- handle(shred, "ErrorInvalidValue");
+ xfun_handle(shred, "ErrorInvalidValue");
return;
}
if(errno == ERANGE) {
- handle(shred, "ValueOutOfRange");
+ xfun_handle(shred, "ValueOutOfRange");
return;
}
}
else if (i >= 0 && (m_uint)i < UGEN(o)->connect.multi->n_chan)
*(M_Object *)RETURN = UGEN(o)->connect.multi->channel[i];
else
- handle(shred, "InvalidChannelRequest");
+ xfun_handle(shred, "InvalidChannelRequest");
}
static MFUN(ugen_get_op) { *(m_uint *)RETURN = UGEN(o)->op + 1; }
Nspc nspc = env->curr;
do {
const Value v = nspc_lookup_value0(nspc, sym);
- if (v) return shadow_err(env, v, loc);
+ if (v && !env->func->def->builtin) return shadow_err(env, v, loc);
} while ((nspc = nspc->parent));
return GW_OK;
}
MUTEX_UNLOCK(shred->mutex);
const m_uint size =
shred->info->frame.ptr ? vector_size(&shred->info->frame) : 0;
- unwind(shred, (Symbol)-1, size);
+ if(size) unwind(shred, (Symbol)-1, size);
vector_rem2(&s->active_shreds, (vtype)shred);
release(shred->info->me, shred);
}