mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-06-03 16:18:26 +00:00
Add support for @ operator to PostfixEvaluator
R=mark at http://breakpad.appspot.com/349002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@923 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
80bcce941e
commit
f2e937f1cb
|
@ -83,7 +83,8 @@ bool PostfixEvaluator<ValueType>::EvaluateInternal(
|
||||||
BINARY_OP_SUBTRACT,
|
BINARY_OP_SUBTRACT,
|
||||||
BINARY_OP_MULTIPLY,
|
BINARY_OP_MULTIPLY,
|
||||||
BINARY_OP_DIVIDE_QUOTIENT,
|
BINARY_OP_DIVIDE_QUOTIENT,
|
||||||
BINARY_OP_DIVIDE_MODULUS
|
BINARY_OP_DIVIDE_MODULUS,
|
||||||
|
BINARY_OP_ALIGN
|
||||||
};
|
};
|
||||||
|
|
||||||
BinaryOperation operation = BINARY_OP_NONE;
|
BinaryOperation operation = BINARY_OP_NONE;
|
||||||
|
@ -97,6 +98,8 @@ bool PostfixEvaluator<ValueType>::EvaluateInternal(
|
||||||
operation = BINARY_OP_DIVIDE_QUOTIENT;
|
operation = BINARY_OP_DIVIDE_QUOTIENT;
|
||||||
else if (token == "%")
|
else if (token == "%")
|
||||||
operation = BINARY_OP_DIVIDE_MODULUS;
|
operation = BINARY_OP_DIVIDE_MODULUS;
|
||||||
|
else if (token == "@")
|
||||||
|
operation = BINARY_OP_ALIGN;
|
||||||
|
|
||||||
if (operation != BINARY_OP_NONE) {
|
if (operation != BINARY_OP_NONE) {
|
||||||
// Get the operands.
|
// Get the operands.
|
||||||
|
@ -126,6 +129,10 @@ bool PostfixEvaluator<ValueType>::EvaluateInternal(
|
||||||
case BINARY_OP_DIVIDE_MODULUS:
|
case BINARY_OP_DIVIDE_MODULUS:
|
||||||
result = operand1 % operand2;
|
result = operand1 % operand2;
|
||||||
break;
|
break;
|
||||||
|
case BINARY_OP_ALIGN:
|
||||||
|
result =
|
||||||
|
operand1 & (reinterpret_cast<ValueType>(-1) ^ (operand2 - 1));
|
||||||
|
break;
|
||||||
case BINARY_OP_NONE:
|
case BINARY_OP_NONE:
|
||||||
// This will not happen, but compilers will want a default or
|
// This will not happen, but compilers will want a default or
|
||||||
// BINARY_OP_NONE case.
|
// BINARY_OP_NONE case.
|
||||||
|
|
|
@ -44,10 +44,12 @@
|
||||||
// either literal values suitable for ValueType, or constants or variables,
|
// either literal values suitable for ValueType, or constants or variables,
|
||||||
// which reference the dictionary. The supported binary operators are +
|
// which reference the dictionary. The supported binary operators are +
|
||||||
// (addition), - (subtraction), * (multiplication), / (quotient of division),
|
// (addition), - (subtraction), * (multiplication), / (quotient of division),
|
||||||
// and % (modulus of division). The unary ^ (dereference) operator is also
|
// % (modulus of division), and @ (data alignment). The alignment operator (@)
|
||||||
// provided. These operators allow any operand to be either a literal
|
// accepts a value and an alignment size, and produces a result that is a
|
||||||
// value, constant, or variable. Assignment (=) of any type of operand into
|
// multiple of the alignment size by truncating the input value.
|
||||||
// a variable is also supported.
|
// The unary ^ (dereference) operator is also provided. These operators
|
||||||
|
// allow any operand to be either a literal value, constant, or variable.
|
||||||
|
// Assignment (=) of any type of operand into a variable is also supported.
|
||||||
//
|
//
|
||||||
// The dictionary is provided as a map with string keys. Keys beginning
|
// The dictionary is provided as a map with string keys. Keys beginning
|
||||||
// with the '$' character are treated as variables. All other keys are
|
// with the '$' character are treated as variables. All other keys are
|
||||||
|
|
|
@ -148,7 +148,8 @@ static bool RunTests() {
|
||||||
{ "$rSub 9 6 - =", true }, // $rSub = 9 - 6 = 3
|
{ "$rSub 9 6 - =", true }, // $rSub = 9 - 6 = 3
|
||||||
{ "$rDivQ 9 6 / =", true }, // $rDivQ = 9 / 6 = 1
|
{ "$rDivQ 9 6 / =", true }, // $rDivQ = 9 / 6 = 1
|
||||||
{ "$rDivM 9 6 % =", true }, // $rDivM = 9 % 6 = 3
|
{ "$rDivM 9 6 % =", true }, // $rDivM = 9 % 6 = 3
|
||||||
{ "$rDeref 9 ^ =", true } // $rDeref = ^9 = 10 (FakeMemoryRegion)
|
{ "$rDeref 9 ^ =", true }, // $rDeref = ^9 = 10 (FakeMemoryRegion)
|
||||||
|
{ "$rAlign 36 8 @ =", true }, // $rAlign = 36 @ 8
|
||||||
};
|
};
|
||||||
map<string, unsigned int> validate_data_0;
|
map<string, unsigned int> validate_data_0;
|
||||||
validate_data_0["$rAdd"] = 8;
|
validate_data_0["$rAdd"] = 8;
|
||||||
|
@ -158,6 +159,7 @@ static bool RunTests() {
|
||||||
validate_data_0["$rDivQ"] = 1;
|
validate_data_0["$rDivQ"] = 1;
|
||||||
validate_data_0["$rDivM"] = 3;
|
validate_data_0["$rDivM"] = 3;
|
||||||
validate_data_0["$rDeref"] = 10;
|
validate_data_0["$rDeref"] = 10;
|
||||||
|
validate_data_0["$rAlign"] = 32;
|
||||||
|
|
||||||
// The second test set simulates a couple of MSVC program strings.
|
// The second test set simulates a couple of MSVC program strings.
|
||||||
// The data is fudged a little bit because the tests use FakeMemoryRegion
|
// The data is fudged a little bit because the tests use FakeMemoryRegion
|
||||||
|
|
Loading…
Reference in a new issue