ID_VAR is now ID_IVAR

master
Daniel Kolesa 2016-08-14 16:15:56 +01:00
parent e518679451
commit 52d8c23a4d
5 changed files with 23 additions and 23 deletions

View File

@ -230,7 +230,7 @@ static void compilelookup(GenState &gs, int ltype, int prevargs = MaxResults) {
lookupid:
Ident *id = gs.cs.new_ident(lookup.get());
if (id) switch (id->type) {
case ID_VAR:
case ID_IVAR:
gs.code.push(CODE_IVAR | cs_ret_code(ltype, RET_INT) | (id->index << 8));
switch (ltype) {
case VAL_POP:
@ -491,7 +491,7 @@ static bool compileblocksub(GenState &gs, int prevargs) {
lookupid:
Ident *id = gs.cs.new_ident(lookup.get());
if (id) switch (id->type) {
case ID_VAR:
case ID_IVAR:
gs.code.push(CODE_IVAR | (id->index << 8));
goto done;
case ID_FVAR:
@ -767,7 +767,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs)
if (!(more = compilearg(gs, VAL_ANY, prevargs))) gs.gen_str();
gs.code.push((id->index < MaxArguments ? CODE_ALIASARG : CODE_ALIAS) | (id->index << 8));
goto endstatement;
case ID_VAR:
case ID_IVAR:
if (!(more = compilearg(gs, VAL_INT, prevargs))) gs.gen_int();
gs.code.push(CODE_IVAR1 | (id->index << 8));
goto endstatement;
@ -1040,7 +1040,7 @@ compilecomv:
}
}
break;
case ID_VAR:
case ID_IVAR:
if (!(more = compilearg(gs, VAL_INT, prevargs))) gs.code.push(CODE_PRINT | (id->index << 8));
else if (!(id->flags & IDF_HEX) || !(more = compilearg(gs, VAL_INT, prevargs + 1))) gs.code.push(CODE_IVAR1 | (id->index << 8));
else if (!(more = compilearg(gs, VAL_INT, prevargs + 2))) gs.code.push(CODE_IVAR2 | (id->index << 8));

View File

@ -678,7 +678,7 @@ static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, Tagged
aval; \
continue; \
case ID_SVAR: arg.cleanup(); sval; continue; \
case ID_VAR: arg.cleanup(); ival; continue; \
case ID_IVAR: arg.cleanup(); ival; continue; \
case ID_FVAR: arg.cleanup(); fval; continue; \
case ID_COMMAND: \
{ \
@ -1012,7 +1012,7 @@ noid:
for (ostd::Size j = 0; j < ostd::Size(callargs); ++j) args[offset + j].id->pop_alias();
goto exit;
}
case ID_VAR:
case ID_IVAR:
if (callargs <= 0) cs.print_var(id);
else cs.set_var_int_checked(id, ostd::iter(&args[offset], callargs));
FORCERESULT;
@ -1072,7 +1072,7 @@ void CsState::run_ret(Ident *id, TvalRange args, TaggedValue &ret) {
} else callcommand(*this, id, args.data(), ret, nargs, false);
nargs = 0;
break;
case ID_VAR:
case ID_IVAR:
if (args.empty()) print_var(id);
else set_var_int_checked(id, args);
break;

View File

@ -14,7 +14,7 @@ static constexpr int MaxArguments = 25;
static constexpr int MaxResults = 7;
enum {
ID_UNKNOWN = -1, ID_VAR, ID_FVAR, ID_SVAR, ID_COMMAND, ID_ALIAS,
ID_UNKNOWN = -1, ID_IVAR, ID_FVAR, ID_SVAR, ID_COMMAND, ID_ALIAS,
ID_LOCAL, ID_DO, ID_DOARGS, ID_IF, ID_RESULT, ID_NOT, ID_AND, ID_OR
};

View File

@ -51,10 +51,10 @@ bool cs_check_num(ostd::ConstCharRange s) {
Ident::Ident(): type(ID_UNKNOWN) {}
/* ID_VAR */
/* ID_IVAR */
Ident::Ident(ostd::ConstCharRange n, int m, int x, int *s,
VarCb f, int flagsv)
: type(ID_VAR), flags(flagsv | (m > x ? IDF_READONLY : 0)), name(n),
: type(ID_IVAR), flags(flagsv | (m > x ? IDF_READONLY : 0)), name(n),
minval(m), maxval(x), cb_var(ostd::move(f)) {
storage.ip = s;
}
@ -151,7 +151,7 @@ void CsState::clear_override(Ident &id) {
id.val.s = cs_dup_ostr("");
id.val.len = 0;
break;
case ID_VAR:
case ID_IVAR:
*id.storage.ip = id.overrideval.i;
id.changed();
break;
@ -222,7 +222,7 @@ bool CsState::reset_var(ostd::ConstCharRange name) {
void CsState::touch_var(ostd::ConstCharRange name) {
Ident *id = idents.at(name);
if (id) switch (id->type) {
case ID_VAR:
case ID_IVAR:
case ID_FVAR:
case ID_SVAR:
id->changed();
@ -240,7 +240,7 @@ void CsState::set_alias(ostd::ConstCharRange name, TaggedValue &v) {
else
id->set_alias(*this, v);
return;
case ID_VAR:
case ID_IVAR:
set_var_int_checked(id, v.get_int());
break;
case ID_FVAR:
@ -292,7 +292,7 @@ void CsState::print_var_str(Ident *id, ostd::ConstCharRange s) {
void CsState::print_var(Ident *id) {
switch (id->type) {
case ID_VAR:
case ID_IVAR:
print_var_int(id, *id->storage.ip);
break;
case ID_FVAR:
@ -725,7 +725,7 @@ bool cs_override_var(CsState &cs, Ident *id, SF sf, RF rf, CF cf) {
void CsState::set_var_int(ostd::ConstCharRange name, int v,
bool dofunc, bool doclamp) {
Ident *id = idents.at(name);
if (!id || id->type != ID_VAR)
if (!id || id->type != ID_IVAR)
return;
bool success = cs_override_var(*this, id,
[&id]() { id->overrideval.i = *id->storage.ip; },
@ -776,7 +776,7 @@ void CsState::set_var_str(ostd::ConstCharRange name, ostd::ConstCharRange v,
ostd::Maybe<int> CsState::get_var_int(ostd::ConstCharRange name) {
Ident *id = idents.at(name);
if (!id || id->type != ID_VAR)
if (!id || id->type != ID_IVAR)
return ostd::nothing;
return *id->storage.ip;
}
@ -797,14 +797,14 @@ ostd::Maybe<ostd::String> CsState::get_var_str(ostd::ConstCharRange name) {
ostd::Maybe<int> CsState::get_var_min_int(ostd::ConstCharRange name) {
Ident *id = idents.at(name);
if (!id || id->type != ID_VAR)
if (!id || id->type != ID_IVAR)
return ostd::nothing;
return id->minval;
}
ostd::Maybe<int> CsState::get_var_max_int(ostd::ConstCharRange name) {
Ident *id = idents.at(name);
if (!id || id->type != ID_VAR)
if (!id || id->type != ID_IVAR)
return ostd::nothing;
return id->maxval;
}

View File

@ -66,7 +66,7 @@ struct Ident;
struct IdentValue {
union {
int i; /* ID_VAR, VAL_INT */
int i; /* ID_IVAR, VAL_INT */
float f; /* ID_FVAR, VAL_FLOAT */
Bytecode const *code; /* VAL_CODE */
Ident *id; /* VAL_IDENT */
@ -162,7 +162,7 @@ struct IdentStack {
};
union IdentValuePtr {
int *ip; /* ID_VAR */
int *ip; /* ID_IVAR */
float *fp; /* ID_FVAR */
char **sp; /* ID_SVAR */
};
@ -187,9 +187,9 @@ struct OSTD_EXPORT Ident {
int index;
ostd::String name;
union {
struct { /* ID_VAR, ID_FVAR, ID_SVAR */
struct { /* ID_IVAR, ID_FVAR, ID_SVAR */
union {
struct { /* ID_VAR */
struct { /* ID_IVAR */
int minval, maxval;
};
struct { /* ID_FVAR */
@ -214,7 +214,7 @@ struct OSTD_EXPORT Ident {
Ident();
/* ID_VAR */
/* ID_IVAR */
Ident(
ostd::ConstCharRange n, int m, int x, int *s,
VarCb f = VarCb(), int flags = 0