Skip to content

Commit

Permalink
eval_expression: Rewrite of eval_expression().
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeakohn committed Oct 19, 2024
1 parent 1ff0631 commit e5c3ee0
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 219 deletions.
2 changes: 2 additions & 0 deletions common/Operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ bool Operator::set_operator(const char *token)
{
switch (token[0])
{
#if 0
case '~':
precedence = PREC_NOT;
operation = OPER_NOT;
break;
#endif
case '*':
precedence = PREC_MUL;
operation = OPER_MUL;
Expand Down
16 changes: 15 additions & 1 deletion common/Operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ class Operator
{
}

Operator(const Operator &o)
{
operation = o.operation;
precedence = o.precedence;
}

Operator & operator= (const Operator &s)
{
operation = s.operation;
precedence = s.precedence;

return *this;
}

bool is_unset() { return operation == OPER_UNSET; }
bool is_set() { return operation != OPER_UNSET; }

Expand All @@ -32,7 +46,7 @@ class Operator
precedence = PREC_UNSET;
}

bool is_math_operator(const char *token);
static bool is_math_operator(const char *token);
bool set_operator(const char *token);
int execute(Var &var_d, Var &var_s);
const char *to_string();
Expand Down
5 changes: 5 additions & 0 deletions common/Var.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class Var
}
}

void complement()
{
value_int = ~value_int;
}

uint32_t get_bin32();
uint64_t get_bin64();
int mul(Var &var_d, Var &var_s);
Expand Down
Loading

0 comments on commit e5c3ee0

Please sign in to comment.