mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Add functions to find the matching ELSE, ENDIF expressions
ExpressionId FindMatchingEndif(ExpressionId id) - Finds the closing ENDIF expression for a given IF expression. ExpressionId FindMatchingElse(ExpressionId id) - Finds the ELSE expression for a given IF expression. - Returns -1, if this IF doesn't have an else This patch is a preparation to the code analyzing required for various optimization passes. Change-Id: I893102a757c6a0bcacbcc1190c2b8ef08314eb97
This commit is contained in:
@@ -74,6 +74,35 @@ class ExpressionGraph {
|
||||
// can be used for further operations.
|
||||
ExpressionId InsertBack(const Expression& expression);
|
||||
|
||||
// Finds the closing ENDIF expression for a given IF expression. Calling this
|
||||
// method is only valid on IF expressions. If no suitable ENDIF is found,
|
||||
// kInvalidExpressionId is returned. Example:
|
||||
// <id> <expr> FindMatchingEndif(id)
|
||||
// 0 IF 7
|
||||
// 1 IF 3
|
||||
// 2 ELSE -
|
||||
// 3 ENDIF -
|
||||
// 4 ELSE -
|
||||
// 5 IF 6
|
||||
// 6 ENDIF -
|
||||
// 7 ENDIF -
|
||||
ExpressionId FindMatchingEndif(ExpressionId id) const;
|
||||
|
||||
// Similar to FindMatchingEndif, but returns the matching ELSE expression. If
|
||||
// no suitable ELSE is found, kInvalidExpressionId is returned.
|
||||
// FindMatchingElse does not throw an error is this case, because IF without
|
||||
// ELSE is allowed.
|
||||
// <id> <expr> FindMatchingEndif(id)
|
||||
// 0 IF 4
|
||||
// 1 IF 2
|
||||
// 2 ELSE -
|
||||
// 3 ENDIF -
|
||||
// 4 ELSE -
|
||||
// 5 IF kInvalidEpressionId
|
||||
// 6 ENDIF -
|
||||
// 7 ENDIF -
|
||||
ExpressionId FindMatchingElse(ExpressionId id) const;
|
||||
|
||||
private:
|
||||
// All Expressions are referenced by an ExpressionId. The ExpressionId is
|
||||
// the index into this array. Each expression has a list of ExpressionId as
|
||||
|
||||
Reference in New Issue
Block a user