GP-3001 - Decompiler - Added Double and Float convert actions

This commit is contained in:
dragonmacher 2023-01-11 10:11:53 -05:00
parent ce32122e3f
commit 761346d888
15 changed files with 268 additions and 86 deletions

View file

@ -44,7 +44,7 @@ public interface DataType {
/**
* Instance of void datatype (never use <code>==</code>)
*
*
* @deprecated should use {@link VoidDataType#dataType} instead
*/
@Deprecated
@ -61,7 +61,7 @@ public interface DataType {
/**
* Indicates if the length of this data-type is determined based upon the
* {@link DataOrganization} obtained from the associated {@link DataTypeManager}.
*
*
* @return true length is language/compiler-specification dependent, else false
*/
public boolean hasLanguageDependantLength();
@ -69,14 +69,14 @@ public interface DataType {
/**
* Get the list of settings definitions available for use with this datatype.
* <p>
* In the case of a {@link TypeDef}, the return list will include the
* In the case of a {@link TypeDef}, the return list will include the
* {@link TypeDefSettingsDefinition} list from the associated base data type.
* <p>
* Unlike {@link TypeDefSettingsDefinition} standard settings definitions
* generally support default, component-default and data-instance use.
* generally support default, component-default and data-instance use.
* In addition, standard settings definitions are never considered during
* {@link #isEquivalent(DataType)} checking or during the resolve process.
*
*
* @return list of the settings definitions for this datatype.
*/
public SettingsDefinition[] getSettingsDefinitions();
@ -84,10 +84,10 @@ public interface DataType {
/**
* Get the list of all settings definitions for this datatype that may be
* used for an associated {@link TypeDef}. When used for an associated
* {@link TypeDef}, these settings will be considered during a
* {@link TypeDef}, these settings will be considered during a
* {@link TypeDef#isEquivalent(DataType)} check and will be preserved
* during the resolve process.
*
*
* @return a list of the settings definitions for a {@link TypeDef}
* associated with this datatype.
*/
@ -112,14 +112,14 @@ public interface DataType {
* applicable.
* <p>
* This instance will be returned if this datatype's DataTypeManager matches the
* specified dtm. The recursion depth of a clone will stop on any datatype whose
* {@link DataTypeManager} matches the specified dtm and simply use the existing datatype
* specified dtm. The recursion depth of a clone will stop on any datatype whose
* {@link DataTypeManager} matches the specified dtm and simply use the existing datatype
* instance.
* <p>
* NOTE: In general, this method should not be used to obtain an instance to be modified.
* In most cases changes shuold be made directly to this instance if supported or to a
* {@link #copy(DataTypeManager)}.
*
* In most cases changes may be made directly to this instance if supported or to a
* {@link #copy(DataTypeManager)} of this type.
*
* @param dtm the data-type manager instance whose data-organization should apply.
* @return cloned instance which may be the same as this instance
*/
@ -130,7 +130,7 @@ public interface DataType {
* source archive association.
* <p>
* Any reference to other datatypes will use {@link #clone(DataTypeManager)}.
*
*
* @param dtm the data-type manager instance whose data-organization should apply.
* @return new instanceof of this datatype
*/
@ -138,21 +138,21 @@ public interface DataType {
/**
* Gets the categoryPath associated with this datatype
*
*
* @return the datatype's category path
*/
public CategoryPath getCategoryPath();
/**
* Returns the dataTypePath for this datatype;
*
*
* @return the dataTypePath for this datatype;
*/
public DataTypePath getDataTypePath();
/**
* Set the categoryPath associated with this datatype
*
*
* @param path the new path
* @throws DuplicateNameException if an attempt to place this datatype into the specified
* category resulted in a name collision. This should not occur for non-DB DataType
@ -165,21 +165,21 @@ public interface DataType {
* <p>
* This association should not be used to indicate whether this DataType has been resolved, but
* is intended to indicate whether the appropriate DataOrganization is being used.
*
*
* @return the DataTypeManager that is associated with this datatype.
*/
public DataTypeManager getDataTypeManager();
/**
* Gets the name for referring to this datatype.
*
*
* @return generic name for this Data Type (i.e.: Word)
*/
public String getDisplayName();
/**
* Get the name of this datatype.
*
*
* @return the name
*/
public String getName();
@ -188,14 +188,14 @@ public interface DataType {
* Get the full category path name that includes this datatype's name.
* <p>
* If the category is null, then this just the datatype's name is returned.
*
*
* @return the path, or just this type's name
*/
public String getPathName();
/**
* Sets the name of the datatype
*
*
* @param name the new name for this datatype.
* @throws InvalidNameException if the given name does not form a valid name.
* @throws DuplicateNameException if name change on stored {@link DataType} is a duplicate of
@ -206,7 +206,7 @@ public interface DataType {
/**
* Sets the name and category of a datatype at the same time.
*
*
* @param path the new category path.
* @param name the new name
* @throws InvalidNameException if the name is invalid
@ -219,7 +219,7 @@ public interface DataType {
/**
* Get the mnemonic for this DataType.
*
*
* @param settings settings which may influence the result or null
* @return the mnemonic for this DataType.
*/
@ -232,7 +232,7 @@ public interface DataType {
* {@link Dynamic} datatypes should return -1. If {@link #isZeroLength()} is true a length of 1
* should be returned. Where a zero-length datatype can be handled (e.g., {@link Composite}) the
* {@link #isZeroLength()} method should be used.
*
*
* @return the length of this DataType
*/
public int getLength();
@ -247,7 +247,7 @@ public interface DataType {
* datatypes used as a component within a {@link Composite} may, or may not, be assigned a
* component length of 0. The method {@link DataTypeComponent#usesZeroLengthComponent(DataType)}
* is used to make this determination.
*
*
* @return true if type definition has a length of 0, else false
*/
public boolean isZeroLength();
@ -257,7 +257,7 @@ public interface DataType {
* <p>
* Such datatypes should always return a {@link #getLength()} of 1 and true for
* {@link #isZeroLength()}. (example: empty structure)
*
*
* @return true if this type is not yet defined.
*/
public boolean isNotYetDefined();
@ -271,7 +271,7 @@ public interface DataType {
/**
* Sets a String briefly describing this DataType.
*
*
* @param description a one-liner describing this DataType.
* @throws UnsupportedOperationException if the description is not allowed to be set for this
* datatype.
@ -290,11 +290,11 @@ public interface DataType {
public URL getDocs();
/**
* Get the interpretted data value in the form of the appropriate Object for this DataType.
* Get the interpreted data value in the form of the appropriate Object for this DataType.
* This method must return a value consistent with {@link #getValueClass(Settings)}.
* <p>
* For instance, if this datatype is a {@link Pointer} an Address object or null should be returned.
* A Byte, returns a {@link Scalar} object.
* For instance, if this datatype is a {@link Pointer} an Address object or null should be returned.
* A Byte, returns a {@link Scalar} object.
*
* @param buf the data buffer.
* @param settings the settings to use.
@ -310,7 +310,7 @@ public interface DataType {
* {@link #encodeRepresentation(String, MemBuffer, Settings, int)} will always throw an
* exception. Actions which rely on either {@code encode} method should not be displayed if the
* applicable datatype is not encodable.
*
*
* @return true if encoding is supported
*/
public boolean isEncodable();
@ -322,7 +322,7 @@ public interface DataType {
* seek the nearest encoding to the specified value, since the object may come from a user
* script. For example, a floating-point value may be rounded. Invalid values should be rejected
* with a {@link DataTypeEncodeException}.
*
*
* @param value the desired value.
* @param buf a buffer representing the eventual destination of the bytes.
* @param settings the settings to use.
@ -338,9 +338,9 @@ public interface DataType {
throws DataTypeEncodeException;
/**
* Get the Class of the value Object to be returned by this datatype
* Get the Class of the value Object to be returned by this datatype
* (see {@link #getValue(MemBuffer, Settings, int)}).
*
*
* @param settings the relevant settings to use or null for default.
* @return Class of the value to be returned by this datatype or null if it can vary or is
* unspecified. Types which correspond to a string or char array will return the String
@ -350,7 +350,7 @@ public interface DataType {
/**
* Returns the appropriate string to use as the default label prefix in the absence of any data.
*
*
* @return the default label prefix or null if none specified.
*/
public String getDefaultLabelPrefix();
@ -368,7 +368,7 @@ public interface DataType {
/**
* Returns the appropriate string to use as the default label prefix.
*
*
* @param buf memory buffer containing the bytes.
* @param settings the Settings object
* @param len the length of the data.
@ -383,7 +383,7 @@ public interface DataType {
* <p>
* This takes into account the fact that there exists a reference to the data that references
* <code>offcutLength</code> bytes into this type
*
*
* @param buf memory buffer containing the bytes.
* @param settings the Settings object
* @param len the length of the data.
@ -411,7 +411,7 @@ public interface DataType {
* should seek the nearest encoding to the specified value, since the representation is likely
* coming from user input. For example, a floating-point value may be rounded. Invalid
* representations should be rejected with a {@link DataTypeEncodeException}.
*
*
* @param repr the representation of the desired value, as in
* {@link #getRepresentation(MemBuffer, Settings, int)}. The supported formats depend
* on the specific datatype and its settings.
@ -430,7 +430,7 @@ public interface DataType {
/**
* Returns true if this datatype has been deleted and is no longer valid
*
*
* @return true if this datatype has been deleted and is no longer valid.
*/
public boolean isDeleted();
@ -441,7 +441,7 @@ public interface DataType {
* The precise meaning of "equivalent" is datatype dependent. <br>
* NOTE: if invoked by a DB object or manager it should be invoked on the DataTypeDB object
* passing the other datatype as the argument.
*
*
* @param dt the datatype being tested for equivalence.
* @return true if the if the given datatype is equivalent to this datatype.
*/
@ -452,7 +452,7 @@ public interface DataType {
* <p>
* DataTypes may need to make internal changes in response. <br>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param dt the datatype that has changed.
*/
public void dataTypeSizeChanged(DataType dt);
@ -462,7 +462,7 @@ public interface DataType {
* <p>
* DataTypes may need to make internal changes in response. <br>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param dt the datatype that has changed.
*/
public void dataTypeAlignmentChanged(DataType dt);
@ -471,7 +471,7 @@ public interface DataType {
* Informs this datatype that the given datatype has been deleted.
* <p>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param dt the datatype that has been deleted.
*/
public void dataTypeDeleted(DataType dt);
@ -480,7 +480,7 @@ public interface DataType {
* Informs this datatype that the given oldDT has been replaced with newDT
* <p>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param oldDt old datatype
* @param newDt new datatype
*/
@ -490,7 +490,7 @@ public interface DataType {
* Inform this data type that it has the given parent
* <br>
* TODO: This method is reserved for internal DB use.
*
*
* @param dt parent data type
*/
public void addParent(DataType dt);
@ -499,7 +499,7 @@ public interface DataType {
* Remove a parent datatype
* <p>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param dt parent datatype
*/
public void removeParent(DataType dt);
@ -508,7 +508,7 @@ public interface DataType {
* Informs this datatype that its name has changed from the indicated old name.
* <p>
* TODO: This method is reserved for internal DB use. <br>
*
*
* @param dt the datatype whose name changed
* @param oldName the datatype's old name
*/
@ -518,14 +518,14 @@ public interface DataType {
* Get the parents of this datatype.
*
* NOTE: This method is intended to be used on a DB-managed datatype only and is not
* fully supported for use with non-DB datatype instances.
* fully supported for use with non-DB datatype instances.
* @return parents of this datatype
*/
public Collection<DataType> getParents();
/**
* Gets the alignment to be used when aligning this datatype within another datatype.
*
*
* @return this datatype's alignment.
*/
public int getAlignment();
@ -534,7 +534,7 @@ public interface DataType {
* Check if this datatype depends on the existence of the given datatype.
* <p>
* For example byte[] depends on byte. If byte were deleted, then byte[] would also be deleted.
*
*
* @param dt the datatype to test that this datatype depends on.
* @return true if the existence of this datatype relies on the existence of the specified
* datatype dt.
@ -543,14 +543,14 @@ public interface DataType {
/**
* Get the source archive where this type originated
*
*
* @return source archive object
*/
public SourceArchive getSourceArchive();
/**
* Set the source archive where this type originated
*
*
* @param archive source archive object
*/
public void setSourceArchive(SourceArchive archive);
@ -558,7 +558,7 @@ public interface DataType {
/**
* Get the timestamp corresponding to the last time this type was changed within its datatype
* manager
*
*
* @return timestamp of last change within datatype manager
*/
public long getLastChangeTime();
@ -566,7 +566,7 @@ public interface DataType {
/**
* Get the timestamp corresponding to the last time this type was sync'd within its source
* archive
*
*
* @return timestamp of last sync with source archive
*/
public long getLastChangeTimeInSourceArchive();
@ -577,7 +577,7 @@ public interface DataType {
* This value is intended to be a unique identifier across all programs and archives. The same
* ID indicates that two datatypes were originally the same one. Keep in mind names, categories,
* and component makeup may differ and have changed since there origin.
*
*
* @return datatype UniversalID
*/
public UniversalID getUniversalID();
@ -588,7 +588,7 @@ public interface DataType {
* <p>
* The datatypes must be of the same "type" (i.e. structure can only be replacedWith another
* structure.
*
*
* @param dataType the datatype that contains the internals to upgrade to.
* @throws UnsupportedOperationException if the datatype does not support change.
* @throws IllegalArgumentException if the given datatype is not the same type as this datatype.
@ -601,7 +601,7 @@ public interface DataType {
* Normally, this is updated automatically when a datatype is changed, but when committing or
* updating while synchronizing an archive, the lastChangeTime may need to be updated
* externally.
*
*
* @param lastChangeTime the time to use as the lastChangeTime for this datatype
*/
public void setLastChangeTime(long lastChangeTime);
@ -610,7 +610,7 @@ public interface DataType {
* Sets the lastChangeTimeInSourceArchive for this datatype.
* <p>
* This is used by when a datatype change is committed back to its source archive.
*
*
* @param lastChangeTimeInSourceArchive the time to use as the lastChangeTimeInSourceArchive for
* this datatype
*/
@ -618,7 +618,7 @@ public interface DataType {
/**
* Returns the DataOrganization associated with this data-type
*
*
* @return associated data organization
*/
public DataOrganization getDataOrganization();

View file

@ -59,9 +59,9 @@ public interface DataTypeComponent {
/**
* Get the byte offset of where this component begins relative to the start of the parent
* data type.
* data type.
* @return offset of start of component relative to the start of the parent
* data type.
* data type.
*/
public int getOffset();
@ -75,8 +75,8 @@ public interface DataTypeComponent {
/**
* Get the length of this component. Zero-length components will report a length of 0
* and may overlap other components at the same offset. Similarly, multiple adjacent
* bit-field components may appear to overlap at the byte-level.
* and may overlap other components at the same offset. Similarly, multiple adjacent
* bit-field components may appear to overlap at the byte-level.
* @return the length of this component
*/
public int getLength();
@ -101,7 +101,7 @@ public interface DataTypeComponent {
/**
* Get this component's field name within its parent.
* If this method returns null {@link #getDefaultFieldName()} can be used to obtain a default
* If this method returns null {@link #getDefaultFieldName()} can be used to obtain a default
* generated field name.
* @return this component's field name within its parent or null if one has not been set.
*/
@ -121,7 +121,7 @@ public interface DataTypeComponent {
/**
* Returns a default field name for this component. Used only if a field name is not set.
* @return default field name (may be null for nameless fields such as a zero-length bitfield).
* @return default field name (may be null for nameless fields such as a zero-length bitfield).
*/
public default String getDefaultFieldName() {
if (isZeroBitFieldComponent()) {
@ -139,7 +139,7 @@ public interface DataTypeComponent {
* A dataTypeComponent is "equivalent" if the other component has a data type
* that is equivalent to this component's data type. The dataTypeComponents must
* also have the same offset, field name, and comment. The length is only checked
* for components which are dyanmic and whose size must be specified when creating
* for components which are dynamic and whose size must be specified when creating
* a component.
* @param dtc the dataTypeComponent being tested for equivalence.
* @return true if the given dataTypeComponent is equivalent to this dataTypeComponent.
@ -150,10 +150,10 @@ public interface DataTypeComponent {
* Determine if the specified dataType will be treated as a zero-length component
* allowing it to possibly overlap the next component. If the specified dataType
* returns true for {@link DataType#isZeroLength()} and true for {@link DataType#isNotYetDefined()}
* this method will return false causing the associated component to use the reported dataType length
* this method will return false causing the associated component to use the reported dataType length
* of 1.
* @param dataType datatype to be evaluated
* @return true if zero-length component
* @return true if zero-length component
*/
public static boolean usesZeroLengthComponent(DataType dataType) {
if (dataType.isZeroLength()) {

View file

@ -31,6 +31,8 @@ public class EquateSymbol extends HighSymbol {
public static final int FORMAT_OCT = 3;
public static final int FORMAT_BIN = 4;
public static final int FORMAT_CHAR = 5;
public static final int FORMAT_FLOAT = 6;
public static final int FORMAT_DOUBLE = 7;
private long value; // Value of the equate
private int convert; // Non-zero if this is a conversion equate
@ -100,6 +102,12 @@ public class EquateSymbol extends HighSymbol {
else if (formString.equals("bin")) {
convert = FORMAT_BIN;
}
else if (formString.equals("float")) {
convert = FORMAT_FLOAT;
}
else if (formString.equals("double")) {
convert = FORMAT_DOUBLE;
}
}
int valel = decoder.openElement(ELEM_VALUE);
value = decoder.readUnsignedInteger(ATTRIB_CONTENT);
@ -128,6 +136,13 @@ public class EquateSymbol extends HighSymbol {
else if (convert == FORMAT_CHAR) {
formString = "char";
}
else if (convert == FORMAT_FLOAT) {
formString = "float";
}
else if (convert == FORMAT_DOUBLE) {
formString = "double";
}
encoder.writeString(ATTRIB_FORMAT, formString);
}
encoder.openElement(ELEM_VALUE);