LEFT | RIGHT |
(no file at all) | |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 /* | 3 /* |
4 ********************************************************************** | 4 ********************************************************************** |
5 * Copyright (c) 2002-2016, International Business Machines | 5 * Copyright (c) 2002-2016, International Business Machines |
6 * Corporation and others. All Rights Reserved. | 6 * Corporation and others. All Rights Reserved. |
7 ********************************************************************** | 7 ********************************************************************** |
8 */ | 8 */ |
9 // | 9 // |
10 // rbbitblb.cpp | 10 // rbbitblb.cpp |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 int32_t RBBITableBuilder::getTableSize() const { | 1088 int32_t RBBITableBuilder::getTableSize() const { |
1089 int32_t size = 0; | 1089 int32_t size = 0; |
1090 int32_t numRows; | 1090 int32_t numRows; |
1091 int32_t numCols; | 1091 int32_t numCols; |
1092 int32_t rowSize; | 1092 int32_t rowSize; |
1093 | 1093 |
1094 if (fTree == NULL) { | 1094 if (fTree == NULL) { |
1095 return 0; | 1095 return 0; |
1096 } | 1096 } |
1097 | 1097 |
1098 size = sizeof(RBBIStateTable) - 4; // The header, with no rows to the
table. | 1098 size = offsetof(RBBIStateTable, fTableData); // The header, with no ro
ws to the table. |
1099 | 1099 |
1100 numRows = fDStates->size(); | 1100 numRows = fDStates->size(); |
1101 numCols = fRB->fSetBuilder->getNumCharCategories(); | 1101 numCols = fRB->fSetBuilder->getNumCharCategories(); |
1102 | 1102 |
1103 // Note The declaration of RBBIStateTableRow is for a table of two columns
. | 1103 rowSize = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_t)*numCols
; |
1104 // Therefore we subtract two from numCols when determining | |
1105 // how much storage to add to a row for the total columns. | |
1106 rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-2); | |
1107 size += numRows * rowSize; | 1104 size += numRows * rowSize; |
1108 return size; | 1105 return size; |
1109 } | 1106 } |
1110 | 1107 |
1111 | 1108 |
1112 | 1109 |
1113 //----------------------------------------------------------------------------- | 1110 //----------------------------------------------------------------------------- |
1114 // | 1111 // |
1115 // exportTable() export the state transition table in the format required | 1112 // exportTable() export the state transition table in the format required |
1116 // by the runtime engine. getTableSize() bytes of memory | 1113 // by the runtime engine. getTableSize() bytes of memory |
1117 // must be available at the output address "where". | 1114 // must be available at the output address "where". |
1118 // | 1115 // |
1119 //----------------------------------------------------------------------------- | 1116 //----------------------------------------------------------------------------- |
1120 void RBBITableBuilder::exportTable(void *where) { | 1117 void RBBITableBuilder::exportTable(void *where) { |
1121 RBBIStateTable *table = (RBBIStateTable *)where; | 1118 RBBIStateTable *table = (RBBIStateTable *)where; |
1122 uint32_t state; | 1119 uint32_t state; |
1123 int col; | 1120 int col; |
1124 | 1121 |
1125 if (U_FAILURE(*fStatus) || fTree == NULL) { | 1122 if (U_FAILURE(*fStatus) || fTree == NULL) { |
1126 return; | 1123 return; |
1127 } | 1124 } |
1128 | 1125 |
1129 if (fRB->fSetBuilder->getNumCharCategories() > 0x7fff || | 1126 int32_t catCount = fRB->fSetBuilder->getNumCharCategories(); |
| 1127 if (catCount > 0x7fff || |
1130 fDStates->size() > 0x7fff) { | 1128 fDStates->size() > 0x7fff) { |
1131 *fStatus = U_BRK_INTERNAL_ERROR; | 1129 *fStatus = U_BRK_INTERNAL_ERROR; |
1132 return; | 1130 return; |
1133 } | 1131 } |
1134 | 1132 |
1135 table->fRowLen = sizeof(RBBIStateTableRow) + | 1133 table->fRowLen = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_
t) * catCount; |
1136 sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCate
gories() - 2); | |
1137 table->fNumStates = fDStates->size(); | 1134 table->fNumStates = fDStates->size(); |
1138 table->fFlags = 0; | 1135 table->fFlags = 0; |
1139 if (fRB->fLookAheadHardBreak) { | 1136 if (fRB->fLookAheadHardBreak) { |
1140 table->fFlags |= RBBI_LOOKAHEAD_HARD_BREAK; | 1137 table->fFlags |= RBBI_LOOKAHEAD_HARD_BREAK; |
1141 } | 1138 } |
1142 if (fRB->fSetBuilder->sawBOF()) { | 1139 if (fRB->fSetBuilder->sawBOF()) { |
1143 table->fFlags |= RBBI_BOF_REQUIRED; | 1140 table->fFlags |= RBBI_BOF_REQUIRED; |
1144 } | 1141 } |
1145 table->fReserved = 0; | 1142 table->fReserved = 0; |
1146 | 1143 |
1147 for (state=0; state<table->fNumStates; state++) { | 1144 for (state=0; state<table->fNumStates; state++) { |
1148 RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(sta
te); | 1145 RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(sta
te); |
1149 RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + sta
te*table->fRowLen); | 1146 RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + sta
te*table->fRowLen); |
1150 U_ASSERT (-32768 < sd->fAccepting && sd->fAccepting <= 32767); | 1147 U_ASSERT (-32768 < sd->fAccepting && sd->fAccepting <= 32767); |
1151 U_ASSERT (-32768 < sd->fLookAhead && sd->fLookAhead <= 32767); | 1148 U_ASSERT (-32768 < sd->fLookAhead && sd->fLookAhead <= 32767); |
1152 row->fAccepting = (int16_t)sd->fAccepting; | 1149 row->fAccepting = (int16_t)sd->fAccepting; |
1153 row->fLookAhead = (int16_t)sd->fLookAhead; | 1150 row->fLookAhead = (int16_t)sd->fLookAhead; |
1154 row->fTagIdx = (int16_t)sd->fTagsIdx; | 1151 row->fTagIdx = (int16_t)sd->fTagsIdx; |
1155 for (col=0; col<fRB->fSetBuilder->getNumCharCategories(); col++) { | 1152 for (col=0; col<catCount; col++) { |
1156 row->fNextState[col] = (uint16_t)sd->fDtran->elementAti(col); | 1153 row->fNextState[col] = (uint16_t)sd->fDtran->elementAti(col); |
1157 } | 1154 } |
1158 } | 1155 } |
1159 } | 1156 } |
1160 | 1157 |
1161 | 1158 |
1162 | 1159 |
1163 //----------------------------------------------------------------------------- | 1160 //----------------------------------------------------------------------------- |
1164 // | 1161 // |
1165 // printSet Debug function. Print the contents of a UVector | 1162 // printSet Debug function. Print the contents of a UVector |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 delete fDtran; | 1276 delete fDtran; |
1280 delete fTagVals; | 1277 delete fTagVals; |
1281 fPositions = NULL; | 1278 fPositions = NULL; |
1282 fDtran = NULL; | 1279 fDtran = NULL; |
1283 fTagVals = NULL; | 1280 fTagVals = NULL; |
1284 } | 1281 } |
1285 | 1282 |
1286 U_NAMESPACE_END | 1283 U_NAMESPACE_END |
1287 | 1284 |
1288 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ | 1285 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ |
LEFT | RIGHT |