Debugger expressions need to be signed, since some results can be negative.

This commit is contained in:
Stephen Anthony 2017-05-01 20:58:31 -02:30
parent 2973d03e01
commit 0af03a3916
2 changed files with 33 additions and 33 deletions

View File

@ -37,7 +37,7 @@ class BinAndExpression : public Expression
{
public:
BinAndExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() & myRHS->evaluate(); }
};
@ -46,7 +46,7 @@ class BinNotExpression : public Expression
{
public:
BinNotExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return ~(myLHS->evaluate()); }
};
@ -55,7 +55,7 @@ class BinOrExpression : public Expression
{
public:
BinOrExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() | myRHS->evaluate(); }
};
@ -64,7 +64,7 @@ class BinXorExpression : public Expression
{
public:
BinXorExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() ^ myRHS->evaluate(); }
};
@ -73,7 +73,7 @@ class ByteDerefExpression : public Expression
{
public:
ByteDerefExpression(Expression* left): Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return Debugger::debugger().peek(myLHS->evaluate()); }
};
@ -82,7 +82,7 @@ class ByteDerefOffsetExpression : public Expression
{
public:
ByteDerefOffsetExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return Debugger::debugger().peek(myLHS->evaluate() + myRHS->evaluate()); }
};
@ -91,7 +91,7 @@ class ConstExpression : public Expression
{
public:
ConstExpression(const int value) : Expression(), myValue(value) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myValue; }
private:
@ -103,7 +103,7 @@ class CpuMethodExpression : public Expression
{
public:
CpuMethodExpression(CpuMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().cpuDebug()); }
private:
@ -115,7 +115,7 @@ class DivExpression : public Expression
{
public:
DivExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ int denom = myRHS->evaluate();
return denom == 0 ? 0 : myLHS->evaluate() / denom; }
};
@ -125,7 +125,7 @@ class EqualsExpression : public Expression
{
public:
EqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() == myRHS->evaluate(); }
};
@ -134,7 +134,7 @@ class EquateExpression : public Expression
{
public:
EquateExpression(const string& label) : Expression(), myLabel(label) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return Debugger::debugger().cartDebug().getAddress(myLabel); }
private:
@ -146,7 +146,7 @@ class FunctionExpression : public Expression
{
public:
FunctionExpression(const string& label) : Expression(), myLabel(label) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return Debugger::debugger().getFunction(myLabel).evaluate(); }
private:
@ -158,7 +158,7 @@ class GreaterEqualsExpression : public Expression
{
public:
GreaterEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() >= myRHS->evaluate(); }
};
@ -167,7 +167,7 @@ class GreaterExpression : public Expression
{
public:
GreaterExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() > myRHS->evaluate(); }
};
@ -176,7 +176,7 @@ class HiByteExpression : public Expression
{
public:
HiByteExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return 0xff & (myLHS->evaluate() >> 8); }
};
@ -185,7 +185,7 @@ class LessEqualsExpression : public Expression
{
public:
LessEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() <= myRHS->evaluate(); }
};
@ -194,7 +194,7 @@ class LessExpression : public Expression
{
public:
LessExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() < myRHS->evaluate(); }
};
@ -203,7 +203,7 @@ class LoByteExpression : public Expression
{
public:
LoByteExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return 0xff & myLHS->evaluate(); }
};
@ -212,7 +212,7 @@ class LogAndExpression : public Expression
{
public:
LogAndExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() && myRHS->evaluate(); }
};
@ -221,7 +221,7 @@ class LogNotExpression : public Expression
{
public:
LogNotExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return !(myLHS->evaluate()); }
};
@ -230,7 +230,7 @@ class LogOrExpression : public Expression
{
public:
LogOrExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() || myRHS->evaluate(); }
};
@ -239,7 +239,7 @@ class MinusExpression : public Expression
{
public:
MinusExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() - myRHS->evaluate(); }
};
@ -248,7 +248,7 @@ class ModExpression : public Expression
{
public:
ModExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ int rhs = myRHS->evaluate();
return rhs == 0 ? 0 : myLHS->evaluate() % rhs; }
};
@ -258,7 +258,7 @@ class MultExpression : public Expression
{
public:
MultExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() * myRHS->evaluate(); }
};
@ -267,7 +267,7 @@ class NotEqualsExpression : public Expression
{
public:
NotEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() != myRHS->evaluate(); }
};
@ -276,7 +276,7 @@ class PlusExpression : public Expression
{
public:
PlusExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() + myRHS->evaluate(); }
};
@ -285,7 +285,7 @@ class CartMethodExpression : public Expression
{
public:
CartMethodExpression(CartMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().cartDebug()); }
private:
@ -297,7 +297,7 @@ class ShiftLeftExpression : public Expression
{
public:
ShiftLeftExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() << myRHS->evaluate(); }
};
@ -306,7 +306,7 @@ class ShiftRightExpression : public Expression
{
public:
ShiftRightExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myLHS->evaluate() >> myRHS->evaluate(); }
};
@ -315,7 +315,7 @@ class TiaMethodExpression : public Expression
{
public:
TiaMethodExpression(TiaMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().tiaDebug()); }
private:
@ -327,7 +327,7 @@ class UnaryMinusExpression : public Expression
{
public:
UnaryMinusExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return -(myLHS->evaluate()); }
};
@ -336,7 +336,7 @@ class WordDerefExpression : public Expression
{
public:
WordDerefExpression(Expression* left) : Expression(left) { }
uInt32 evaluate() const override
Int32 evaluate() const override
{ return Debugger::debugger().dpeek(myLHS->evaluate()); }
};

View File

@ -35,7 +35,7 @@ class Expression
: myLHS(lhs), myRHS(rhs) { }
virtual ~Expression() = default;
virtual uInt32 evaluate() const { return 0; }
virtual Int32 evaluate() const { return 0; }
protected:
unique_ptr<Expression> myLHS, myRHS;