alignRead(input);
final Definition[] myFields = new Definition[fFieldMap.size()];
StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldName, fFieldMap.keySet(), myFields);
-
- Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
- for (int i = 0; i < fFieldMap.size(); i++) {
- Map.Entry<String, IDeclaration> entry = iter.next();
- String name = entry.getKey();
- if (name == null) {
- throw new IllegalStateException();
- }
- myFields[i] = entry.getValue().createDefinition(structDefinition, name, input);
- }
+ fillStruct(input, myFields, structDefinition);
return structDefinition;
}
/**
- * Accelerated create definition
+ * Create a definition from this declaration. This is a faster constructor
+ * as it has a lexical scope and this does not need to look it up.
*
* @param definitionScope
- * the definition scope
+ * the definition scope, the parent where the definition will be
+ * placed
* @param fieldScope
- * the lexical scope of this element
+ * the scope of the definition
* @param input
- * the {@Link BitBuffer} to read
- * @return the Struct definition
+ * a bitbuffer to read from
+ * @return a reference to the definition
* @throws CTFReaderException
- * read error and such
+ * error in reading
* @since 3.1
*/
public StructDefinition createDefinition(IDefinitionScope definitionScope,
*/
@SuppressWarnings("null")
StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldScope, fieldScope.getName(), fFieldMap.keySet(), myFields);
- Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
- for (int i = 0; i < fFieldMap.size(); i++) {
- Map.Entry<String, IDeclaration> entry = iter.next();
- String fieldName = entry.getKey();
- if (fieldName == null) {
- throw new IllegalStateException();
- }
- myFields[i] = entry.getValue().createDefinition(structDefinition, fieldName, input);
- }
+ fillStruct(input, myFields, structDefinition);
return structDefinition;
}
fMaxAlign = Math.max(fMaxAlign, declaration.getAlignment());
}
+ @SuppressWarnings("null")
+ private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFReaderException {
+ Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
+ for (int i = 0; i < fFieldMap.size(); i++) {
+ Map.Entry<String, IDeclaration> entry = iter.next();
+ myFields[i] = entry.getValue().createDefinition(structDefinition, entry.getKey(), input);
+ }
+ }
+
@Override
public String toString() {
/* Only used for debugging */