forked from OctaForge/libcubescript
make set_macro an API again (no point in blocking it for now)
parent
edd32bf56b
commit
839dd29299
2
cs_vm.cc
2
cs_vm.cc
|
@ -372,7 +372,7 @@ static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, Tagged
|
|||
|
||||
case CODE_MACRO: {
|
||||
ostd::Uint32 len = op >> 8;
|
||||
cs_set_macro(args[numargs++], reinterpret_cast<Bytecode const *>(code), len);
|
||||
args[numargs++].set_macro(reinterpret_cast<Bytecode const *>(code), len);
|
||||
code += len / sizeof(ostd::Uint32) + 1;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -380,20 +380,6 @@ void TaggedValue::cleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
/* XXX: nasty */
|
||||
struct InternalTval: IdentValue {
|
||||
int type;
|
||||
};
|
||||
|
||||
void cs_set_macro(
|
||||
TaggedValue &tv, Bytecode const *val, ostd::Size len
|
||||
) {
|
||||
InternalTval &itv = reinterpret_cast<InternalTval &>(tv);
|
||||
itv.type = VAL_MACRO;
|
||||
itv.len = len;
|
||||
itv.code = val;
|
||||
}
|
||||
|
||||
void TaggedValue::force_null() {
|
||||
if (get_type() == VAL_NULL) return;
|
||||
cleanup();
|
||||
|
@ -588,7 +574,7 @@ void Ident::get_val(TaggedValue &r) const {
|
|||
void Ident::get_cstr(TaggedValue &v) const {
|
||||
switch (get_valtype()) {
|
||||
case VAL_MACRO:
|
||||
cs_set_macro(v, val.code, val.len);
|
||||
v.set_macro(val.code, val.len);
|
||||
break;
|
||||
case VAL_STR:
|
||||
case VAL_CSTR:
|
||||
|
@ -609,7 +595,7 @@ void Ident::get_cstr(TaggedValue &v) const {
|
|||
void Ident::get_cval(TaggedValue &v) const {
|
||||
switch (get_valtype()) {
|
||||
case VAL_MACRO:
|
||||
cs_set_macro(v, val.code, val.len);
|
||||
v.set_macro(val.code, val.len);
|
||||
break;
|
||||
case VAL_STR:
|
||||
case VAL_CSTR:
|
||||
|
|
|
@ -117,6 +117,11 @@ struct OSTD_EXPORT TaggedValue: IdentValue {
|
|||
p_type = VAL_IDENT;
|
||||
id = val;
|
||||
}
|
||||
void set_macro(Bytecode const *val, ostd::Size ln) {
|
||||
p_type = VAL_MACRO;
|
||||
len = ln;
|
||||
code = val;
|
||||
}
|
||||
|
||||
void set(TaggedValue &tv) {
|
||||
*this = tv;
|
||||
|
|
Loading…
Reference in New Issue