diff options
Diffstat (limited to 'deps/icu-small/source/common/rbbitblb.h')
-rw-r--r-- | deps/icu-small/source/common/rbbitblb.h | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/deps/icu-small/source/common/rbbitblb.h b/deps/icu-small/source/common/rbbitblb.h index 09b57b5cf0..eea243e4cd 100644 --- a/deps/icu-small/source/common/rbbitblb.h +++ b/deps/icu-small/source/common/rbbitblb.h @@ -17,6 +17,7 @@ #include "unicode/utypes.h" #include "unicode/uobject.h" #include "unicode/rbbi.h" +#include "rbbirb.h" #include "rbbinode.h" @@ -37,22 +38,28 @@ class UVector32; class RBBITableBuilder : public UMemory { public: - RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode); + RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode, UErrorCode &status); ~RBBITableBuilder(); - void build(); - int32_t getTableSize() const; // Return the runtime size in bytes of - // the built state table + void buildForwardTable(); + + /** Return the runtime size in bytes of the built state table. */ + int32_t getTableSize() const; /** Fill in the runtime state table. Sufficient memory must exist at the specified location. */ void exportTable(void *where); - /** Find duplicate (redundant) character classes, beginning after the specifed - * pair, within this state table. This is an iterator-like function, used to - * identify char classes (state table columns) that can be eliminated. + /** + * Find duplicate (redundant) character classes. Begin looking with categories.first. + * Duplicate, if found are returned in the categories parameter. + * This is an iterator-like function, used to identify character classes + * (state table columns) that can be eliminated. + * @param categories in/out parameter, specifies where to start looking for duplicates, + * and returns the first pair of duplicates found, if any. + * @return true if duplicate char classes were found, false otherwise. */ - bool findDuplCharClassFrom(int &baseClass, int &duplClass); + bool findDuplCharClassFrom(IntPair *categories); /** Remove a column from the state table. Used when two character categories * have been found equivalent, and merged together, to eliminate the uneeded table column. @@ -62,6 +69,16 @@ public: /** Check for, and remove dupicate states (table rows). */ void removeDuplicateStates(); + /** Build the safe reverse table from the already-constructed forward table. */ + void buildSafeReverseTable(UErrorCode &status); + + /** Return the runtime size in bytes of the built safe reverse state table. */ + int32_t getSafeTableSize() const; + + /** Fill in the runtime safe state table. Sufficient memory must exist at the specified location. + */ + void exportSafeTable(void *where); + private: void calcNullable(RBBINode *n); @@ -84,20 +101,36 @@ private: void addRuleRootNodes(UVector *dest, RBBINode *node); - /** Find the next duplicate state. An iterator function. - * @param firstState (in/out) begin looking at this state, return the first of the - * pair of duplicates. - * @param duplicateState returns the duplicate state of fistState - * @return true if a duplicate pair of states was found. + /** + * Find duplicate (redundant) states, beginning at the specified pair, + * within this state table. This is an iterator-like function, used to + * identify states (state table rows) that can be eliminated. + * @param states in/out parameter, specifies where to start looking for duplicates, + * and returns the first pair of duplicates found, if any. + * @return true if duplicate states were found, false otherwise. + */ + bool findDuplicateState(IntPair *states); + + /** Remove a duplicate state. + * @param duplStates The duplicate states. The first is kept, the second is removed. + * All references to the second in the state table are retargeted + * to the first. */ - bool findDuplicateState(int32_t &firstState, int32_t &duplicateState); + void removeState(IntPair duplStates); - /** Remove a duplicate state/ - * @param keepState First of the duplicate pair. Keep it. - * @param duplState Duplicate state. Remove it. Redirect all references to the duplicate state - * to refer to keepState instead. + /** Find the next duplicate state in the safe reverse table. An iterator function. + * @param states in/out parameter, specifies where to start looking for duplicates, + * and returns the first pair of duplicates found, if any. + * @return true if a duplicate pair of states was found. */ - void removeState(int32_t keepState, int32_t duplState); + bool findDuplicateSafeState(IntPair *states); + + /** Remove a duplicate state from the safe table. + * @param duplStates The duplicate states. The first is kept, the second is removed. + * All references to the second in the state table are retargeted + * to the first. + */ + void removeSafeState(IntPair duplStates); // Set functions for UVector. // TODO: make a USet subclass of UVector @@ -113,11 +146,13 @@ public: void printPosSets(RBBINode *n /* = NULL*/); void printStates(); void printRuleStatusTable(); + void printReverseTable(); #else #define printSet(s) #define printPosSets(n) #define printStates() #define printRuleStatusTable() + #define printReverseTable() #endif private: @@ -126,10 +161,14 @@ private: // table for. UErrorCode *fStatus; + /** State Descriptors, UVector<RBBIStateDescriptor> */ UVector *fDStates; // D states (Aho's terminology) // Index is state number // Contents are RBBIStateDescriptor pointers. + /** Synthesized safe table, UVector of UnicodeString, one string per table row. */ + UVector *fSafeTable; + RBBITableBuilder(const RBBITableBuilder &other); // forbid copying of this class RBBITableBuilder &operator=(const RBBITableBuilder &other); // forbid copying of this class |