mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-06 22:48:30 +01:00
Breakpad processor: Support evaluating a postfix expression to produce a value.
This adds an EvaluateForValue member function to PostfixEvaluator, and along with appropriate unit tests. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@511 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
6a9ffff696
commit
89e07bf2c7
3 changed files with 151 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// -*- mode: C++ -*-
|
||||
|
||||
// Copyright (c) 2010, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -93,15 +95,21 @@ class PostfixEvaluator {
|
|||
PostfixEvaluator(DictionaryType *dictionary, const MemoryRegion *memory)
|
||||
: dictionary_(dictionary), memory_(memory), stack_() {}
|
||||
|
||||
// Evaluate the expression. The results of execution will be stored
|
||||
// in one (or more) variables in the dictionary. Returns false if any
|
||||
// failures occure during execution, leaving variables in the dictionary
|
||||
// in an indeterminate state. If assigned is non-NULL, any keys set in
|
||||
// the dictionary as a result of evaluation will also be set to true in
|
||||
// assigned, providing a way to determine if an expression modifies any
|
||||
// of its input variables.
|
||||
// Evaluate the expression, starting with an empty stack. The results of
|
||||
// execution will be stored in one (or more) variables in the dictionary.
|
||||
// Returns false if any failures occur during execution, leaving
|
||||
// variables in the dictionary in an indeterminate state. If assigned is
|
||||
// non-NULL, any keys set in the dictionary as a result of evaluation
|
||||
// will also be set to true in assigned, providing a way to determine if
|
||||
// an expression modifies any of its input variables.
|
||||
bool Evaluate(const string &expression, DictionaryValidityType *assigned);
|
||||
|
||||
// Like Evaluate, but provides the value left on the stack to the
|
||||
// caller. If evaluation succeeds and leaves exactly one value on
|
||||
// the stack, pop that value, store it in *result, and return true.
|
||||
// Otherwise, return false.
|
||||
bool EvaluateForValue(const string &expression, ValueType *result);
|
||||
|
||||
DictionaryType* dictionary() const { return dictionary_; }
|
||||
|
||||
// Reset the dictionary. PostfixEvaluator does not take ownership.
|
||||
|
|
@ -137,6 +145,12 @@ class PostfixEvaluator {
|
|||
// Pushes a new value onto the stack.
|
||||
void PushValue(const ValueType &value);
|
||||
|
||||
// Evaluate expression, updating *assigned if it is non-zero. Return
|
||||
// true if evaluation completes successfully. Do not clear the stack
|
||||
// upon successful evaluation.
|
||||
bool EvaluateInternal(const string &expression,
|
||||
DictionaryValidityType *assigned);
|
||||
|
||||
// The dictionary mapping constant and variable identifiers (strings) to
|
||||
// values. Keys beginning with '$' are treated as variable names, and
|
||||
// PostfixEvaluator is free to create and modify these keys. Weak pointer.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue