| Index: source/common/rbbinode.cpp
|
| diff --git a/source/common/rbbinode.cpp b/source/common/rbbinode.cpp
|
| index 49e0ad3dfa43a8e4bd367be7a0370a6059a084c7..8c1ee8baf82418e5b89b4b0ae80e399c000709d0 100644
|
| --- a/source/common/rbbinode.cpp
|
| +++ b/source/common/rbbinode.cpp
|
| @@ -1,6 +1,8 @@
|
| +// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
| +// License & terms of use: http://www.unicode.org/copyright.html
|
| /*
|
| ***************************************************************************
|
| -* Copyright (C) 2002-2008 International Business Machines Corporation *
|
| +* Copyright (C) 2002-2016 International Business Machines Corporation *
|
| * and others. All rights reserved. *
|
| ***************************************************************************
|
| */
|
| @@ -23,6 +25,8 @@
|
| #include "unicode/uniset.h"
|
| #include "unicode/uchar.h"
|
| #include "unicode/parsepos.h"
|
| +
|
| +#include "cstr.h"
|
| #include "uvector.h"
|
|
|
| #include "rbbirb.h"
|
| @@ -56,6 +60,8 @@ RBBINode::RBBINode(NodeType t) : UMemory() {
|
| fLastPos = 0;
|
| fNullable = FALSE;
|
| fLookAheadEnd = FALSE;
|
| + fRuleRoot = FALSE;
|
| + fChainIn = FALSE;
|
| fVal = 0;
|
| fPrecedence = precZero;
|
|
|
| @@ -86,6 +92,8 @@ RBBINode::RBBINode(const RBBINode &other) : UMemory(other) {
|
| fLastPos = other.fLastPos;
|
| fNullable = other.fNullable;
|
| fVal = other.fVal;
|
| + fRuleRoot = FALSE;
|
| + fChainIn = other.fChainIn;
|
| UErrorCode status = U_ZERO_ERROR;
|
| fFirstPosSet = new UVector(status); // TODO - get a real status from somewhere
|
| fLastPosSet = new UVector(status);
|
| @@ -161,6 +169,8 @@ RBBINode *RBBINode::cloneTree() {
|
| }
|
| }
|
| }
|
| + n->fRuleRoot = this->fRuleRoot;
|
| + n->fChainIn = this->fChainIn;
|
| return n;
|
| }
|
|
|
| @@ -272,7 +282,13 @@ void RBBINode::findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &s
|
| //
|
| //-------------------------------------------------------------------------
|
| #ifdef RBBI_DEBUG
|
| -void RBBINode::printNode() {
|
| +
|
| +static int32_t serial(const RBBINode *node) {
|
| + return (node == NULL? -1 : node->fSerialNum);
|
| +}
|
| +
|
| +
|
| +void RBBINode::printNode(const RBBINode *node) {
|
| static const char * const nodeTypeNames[] = {
|
| "setRef",
|
| "uset",
|
| @@ -292,14 +308,16 @@ void RBBINode::printNode() {
|
| "opLParen"
|
| };
|
|
|
| - if (this==NULL) {
|
| - RBBIDebugPrintf("%10p", (void *)this);
|
| + if (node==NULL) {
|
| + RBBIDebugPrintf("%10p", (void *)node);
|
| } else {
|
| - RBBIDebugPrintf("%10p %12s %10p %10p %10p %4d %6d %d ",
|
| - (void *)this, nodeTypeNames[fType], (void *)fParent, (void *)fLeftChild, (void *)fRightChild,
|
| - fSerialNum, fFirstPos, fVal);
|
| - if (fType == varRef) {
|
| - RBBI_DEBUG_printUnicodeString(fText);
|
| + RBBIDebugPrintf("%10p %5d %12s %c%c %5d %5d %5d %6d %d ",
|
| + (void *)node, node->fSerialNum, nodeTypeNames[node->fType],
|
| + node->fRuleRoot?'R':' ', node->fChainIn?'C':' ',
|
| + serial(node->fLeftChild), serial(node->fRightChild), serial(node->fParent),
|
| + node->fFirstPos, node->fVal);
|
| + if (node->fType == varRef) {
|
| + RBBI_DEBUG_printUnicodeString(node->fText);
|
| }
|
| }
|
| RBBIDebugPrintf("\n");
|
| @@ -308,16 +326,8 @@ void RBBINode::printNode() {
|
|
|
|
|
| #ifdef RBBI_DEBUG
|
| -U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth)
|
| -{
|
| - int i;
|
| - for (i=0; i<s.length(); i++) {
|
| - RBBIDebugPrintf("%c", s.charAt(i));
|
| - // putc(s.charAt(i), stdout);
|
| - }
|
| - for (i=s.length(); i<minWidth; i++) {
|
| - RBBIDebugPrintf(" ");
|
| - }
|
| +U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth) {
|
| + RBBIDebugPrintf("%*s", minWidth, CStr(s)());
|
| }
|
| #endif
|
|
|
| @@ -328,23 +338,25 @@ U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth)
|
| //
|
| //-------------------------------------------------------------------------
|
| #ifdef RBBI_DEBUG
|
| -void RBBINode::printTree(UBool printHeading) {
|
| +void RBBINode::printNodeHeader() {
|
| + RBBIDebugPrintf(" Address serial type LeftChild RightChild Parent position value\n");
|
| +}
|
| +
|
| +void RBBINode::printTree(const RBBINode *node, UBool printHeading) {
|
| if (printHeading) {
|
| - RBBIDebugPrintf( "-------------------------------------------------------------------\n"
|
| - " Address type Parent LeftChild RightChild serial position value\n"
|
| - );
|
| + printNodeHeader();
|
| }
|
| - this->printNode();
|
| - if (this != NULL) {
|
| + printNode(node);
|
| + if (node != NULL) {
|
| // Only dump the definition under a variable reference if asked to.
|
| // Unconditinally dump children of all other node types.
|
| - if (fType != varRef) {
|
| - if (fLeftChild != NULL) {
|
| - fLeftChild->printTree(FALSE);
|
| + if (node->fType != varRef) {
|
| + if (node->fLeftChild != NULL) {
|
| + printTree(node->fLeftChild, FALSE);
|
| }
|
|
|
| - if (fRightChild != NULL) {
|
| - fRightChild->printTree(FALSE);
|
| + if (node->fRightChild != NULL) {
|
| + printTree(node->fRightChild, FALSE);
|
| }
|
| }
|
| }
|
|
|