2016-09-07 20:57:28 +00:00
|
|
|
#include "cubescript/cubescript.hh"
|
2016-09-06 17:27:54 +00:00
|
|
|
#include "cs_vm.hh"
|
|
|
|
#include "cs_util.hh"
|
|
|
|
|
|
|
|
namespace cscript {
|
|
|
|
|
2016-09-06 18:06:49 +00:00
|
|
|
template<typename T, typename U>
|
2016-09-07 16:58:56 +00:00
|
|
|
static inline T &csv_get(U &stor) {
|
2016-09-06 18:06:49 +00:00
|
|
|
/* ugly, but internal and unlikely to cause bugs */
|
|
|
|
return const_cast<T &>(reinterpret_cast<T const &>(stor));
|
|
|
|
}
|
|
|
|
|
2016-09-06 21:54:28 +00:00
|
|
|
template<typename T>
|
2016-09-07 16:58:56 +00:00
|
|
|
static inline void csv_cleanup(CsValueType tv, T &stor) {
|
2016-09-06 21:54:28 +00:00
|
|
|
switch (tv) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
2016-09-06 21:54:28 +00:00
|
|
|
delete[] csv_get<char *>(stor);
|
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Code: {
|
2016-09-06 21:54:28 +00:00
|
|
|
ostd::Uint32 *bcode = csv_get<ostd::Uint32 *>(stor);
|
2016-09-07 18:20:36 +00:00
|
|
|
if (bcode[-1] == CsCodeStart) {
|
2016-09-06 21:54:28 +00:00
|
|
|
delete[] bcode;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 20:23:03 +00:00
|
|
|
CsValue::CsValue():
|
2016-09-07 17:42:12 +00:00
|
|
|
p_stor(), p_len(0), p_type(CsValueType::Null)
|
2016-09-06 20:23:03 +00:00
|
|
|
{}
|
|
|
|
|
2016-09-06 20:57:10 +00:00
|
|
|
CsValue::~CsValue() {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-06 20:57:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:23:03 +00:00
|
|
|
CsValue::CsValue(CsValue const &v): CsValue() {
|
|
|
|
*this = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsValue::CsValue(CsValue &&v): CsValue() {
|
|
|
|
*this = ostd::move(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
CsValue &CsValue::operator=(CsValue const &v) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Null;
|
2016-09-06 20:23:03 +00:00
|
|
|
switch (v.get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
|
|
|
case CsValueType::Float:
|
|
|
|
case CsValueType::Ident:
|
2016-09-06 20:23:03 +00:00
|
|
|
p_len = v.p_len;
|
|
|
|
p_type = v.p_type;
|
2016-09-06 20:57:10 +00:00
|
|
|
p_stor = v.p_stor;
|
2016-09-06 20:23:03 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Cstring:
|
|
|
|
case CsValueType::Macro:
|
2016-09-06 20:23:03 +00:00
|
|
|
set_str(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(v.p_stor), v.p_len)
|
|
|
|
);
|
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Code:
|
2016-09-06 20:23:03 +00:00
|
|
|
set_code(cs_copy_code(v.get_code()));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsValue &CsValue::operator=(CsValue &&v) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
|
|
|
p_stor = v.p_stor;
|
|
|
|
p_type = v.p_type;
|
|
|
|
p_len = v.p_len;
|
2016-09-07 17:42:12 +00:00
|
|
|
v.p_type = CsValueType::Null;
|
2016-09-06 20:23:03 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-09-06 17:27:54 +00:00
|
|
|
CsValueType CsValue::get_type() const {
|
|
|
|
return p_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_int(CsInt val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Int;
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<CsInt>(p_stor) = val;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_float(CsFloat val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Float;
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<CsFloat>(p_stor) = val;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_str(CsString val) {
|
|
|
|
if (val.size() == 0) {
|
|
|
|
/* ostd zero length strings cannot be disowned */
|
|
|
|
char *buf = new char[1];
|
|
|
|
buf[0] = '\0';
|
|
|
|
set_mstr(buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ostd::CharRange cr = val.iter();
|
|
|
|
val.disown();
|
|
|
|
set_mstr(cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_null() {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Null;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_code(CsBytecode *val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Code;
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<CsBytecode *>(p_stor) = val;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_cstr(ostd::ConstCharRange val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Cstring;
|
2016-09-06 17:27:54 +00:00
|
|
|
p_len = val.size();
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<char const *>(p_stor) = val.data();
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_mstr(ostd::CharRange val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::String;
|
2016-09-06 17:27:54 +00:00
|
|
|
p_len = val.size();
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<char *>(p_stor) = val.data();
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_ident(CsIdent *val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Ident;
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<CsIdent *>(p_stor) = val;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::set_macro(ostd::ConstCharRange val) {
|
2016-09-06 21:54:28 +00:00
|
|
|
csv_cleanup(p_type, p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
p_type = CsValueType::Macro;
|
2016-09-06 17:27:54 +00:00
|
|
|
p_len = val.size();
|
2016-09-06 18:06:49 +00:00
|
|
|
csv_get<char const *>(p_stor) = val.data();
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::force_null() {
|
2016-09-07 17:42:12 +00:00
|
|
|
if (get_type() == CsValueType::Null) {
|
2016-09-06 17:27:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
set_null();
|
|
|
|
}
|
|
|
|
|
|
|
|
CsFloat CsValue::force_float() {
|
|
|
|
CsFloat rf = 0.0f;
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
rf = csv_get<CsInt>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
rf = cs_parse_float(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsFloat>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
set_float(rf);
|
|
|
|
return rf;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsInt CsValue::force_int() {
|
|
|
|
CsInt ri = 0;
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
ri = csv_get<CsFloat>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
ri = cs_parse_int(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsInt>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
set_int(ri);
|
|
|
|
return ri;
|
|
|
|
}
|
|
|
|
|
|
|
|
ostd::ConstCharRange CsValue::force_str() {
|
|
|
|
CsString rs;
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
rs = ostd::move(floatstr(csv_get<CsFloat>(p_stor)));
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
rs = ostd::move(intstr(csv_get<CsInt>(p_stor)));
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
rs = ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
2016-09-06 18:06:49 +00:00
|
|
|
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
set_str(ostd::move(rs));
|
2016-09-06 18:06:49 +00:00
|
|
|
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CsInt CsValue::get_int() const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
return CsInt(csv_get<CsFloat>(p_stor));
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsInt>(p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
return cs_parse_int(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsFloat CsValue::get_float() const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsFloat>(p_stor);
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
return CsFloat(csv_get<CsInt>(p_stor));
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
return cs_parse_float(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsBytecode *CsValue::get_code() const {
|
2016-09-07 17:42:12 +00:00
|
|
|
if (get_type() != CsValueType::Code) {
|
2016-09-06 17:27:54 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsBytecode *>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CsIdent *CsValue::get_ident() const {
|
2016-09-07 17:42:12 +00:00
|
|
|
if (get_type() != CsValueType::Ident) {
|
2016-09-06 17:27:54 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsIdent *>(p_stor);
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CsString CsValue::get_str() const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
return intstr(csv_get<CsInt>(p_stor));
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
return floatstr(csv_get<CsFloat>(p_stor));
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CsString("");
|
|
|
|
}
|
|
|
|
|
|
|
|
ostd::ConstCharRange CsValue::get_strr() const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
return ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ostd::ConstCharRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CsValue::get_val(CsValue &r) const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
r.set_str(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
r.set_int(csv_get<CsInt>(p_stor));
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
r.set_float(csv_get<CsFloat>(p_stor));
|
2016-09-06 17:27:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
r.set_null();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OSTD_EXPORT bool cs_code_is_empty(CsBytecode *code) {
|
|
|
|
if (!code) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return (
|
2016-09-07 18:20:36 +00:00
|
|
|
*reinterpret_cast<ostd::Uint32 *>(code) & CsCodeOpMask
|
|
|
|
) == CsCodeExit;
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CsValue::code_is_empty() const {
|
2016-09-07 17:42:12 +00:00
|
|
|
if (get_type() != CsValueType::Code) {
|
2016-09-06 17:27:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-06 18:06:49 +00:00
|
|
|
return cscript::cs_code_is_empty(csv_get<CsBytecode *>(p_stor));
|
2016-09-06 17:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool cs_get_bool(ostd::ConstCharRange s) {
|
|
|
|
if (s.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ostd::ConstCharRange end = s;
|
|
|
|
CsInt ival = cs_parse_int(end, &end);
|
|
|
|
if (end.empty()) {
|
|
|
|
return !!ival;
|
|
|
|
}
|
|
|
|
end = s;
|
|
|
|
CsFloat fval = cs_parse_float(end, &end);
|
|
|
|
if (end.empty()) {
|
|
|
|
return !!fval;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CsValue::get_bool() const {
|
|
|
|
switch (get_type()) {
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Float:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsFloat>(p_stor) != 0;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::Int:
|
2016-09-06 18:06:49 +00:00
|
|
|
return csv_get<CsInt>(p_stor) != 0;
|
2016-09-07 17:42:12 +00:00
|
|
|
case CsValueType::String:
|
|
|
|
case CsValueType::Macro:
|
|
|
|
case CsValueType::Cstring:
|
2016-09-06 18:06:49 +00:00
|
|
|
return cs_get_bool(
|
|
|
|
ostd::ConstCharRange(csv_get<char const *>(p_stor), p_len)
|
|
|
|
);
|
2016-09-06 17:27:54 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 20:23:03 +00:00
|
|
|
/* stacked value for easy stack management */
|
|
|
|
|
|
|
|
CsStackedValue::CsStackedValue(CsIdent *id):
|
|
|
|
CsValue(), p_a(nullptr), p_stack(), p_pushed(false)
|
|
|
|
{
|
|
|
|
set_alias(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
CsStackedValue::~CsStackedValue() {
|
|
|
|
pop();
|
2016-09-06 21:54:28 +00:00
|
|
|
static_cast<CsValue *>(this)->~CsValue();
|
2016-09-06 20:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CsStackedValue &CsStackedValue::operator=(CsValue const &v) {
|
|
|
|
*static_cast<CsValue *>(this) = v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsStackedValue &CsStackedValue::operator=(CsValue &&v) {
|
|
|
|
*static_cast<CsValue *>(this) = ostd::move(v);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CsStackedValue::set_alias(CsIdent *id) {
|
|
|
|
if (!id || !id->is_alias()) {
|
|
|
|
return false;
|
2016-09-06 18:06:49 +00:00
|
|
|
}
|
2016-09-06 20:23:03 +00:00
|
|
|
p_a = static_cast<CsAlias *>(id);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CsAlias *CsStackedValue::get_alias() const {
|
|
|
|
return p_a;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CsStackedValue::has_alias() const {
|
|
|
|
return p_a != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CsStackedValue::push() {
|
|
|
|
if (!p_a) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CsAliasInternal::push_arg(p_a, *this, p_stack);
|
|
|
|
p_pushed = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CsStackedValue::pop() {
|
|
|
|
if (!p_pushed || !p_a) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CsAliasInternal::pop_arg(p_a);
|
|
|
|
p_pushed = false;
|
|
|
|
return true;
|
2016-09-06 18:06:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 17:27:54 +00:00
|
|
|
} /* namespace cscript */
|