dspl.intermediate.variable
Class DSPLFloat

java.lang.Object
  extended by dspl.intermediate.variable.Variable
      extended by dspl.intermediate.variable.DSPLFloat
All Implemented Interfaces:
ParserTokensTokenTypes

public class DSPLFloat
extends Variable

DSPLFloat is the Variable class for the float primitive

Author:
David

Field Summary
 
Fields inherited from class dspl.intermediate.variable.Variable
arraySize, byteSize, DATA_TYPE_BYTE, DATA_TYPE_COMPLEX, DATA_TYPE_FLOAT, DATA_TYPE_INT, DATA_TYPE_STRING, DATA_TYPE_UBYTE, DATA_TYPE_UINT, dataType, elementIndex, elementsParentVar, identifier, isConstant, isElement, lineNumDecl, SIZE_TYPE_ARRAY, SIZE_TYPE_ATOM, sizeType, value
 
Fields inherited from interface dspl.frontend.ParserTokensTokenTypes
ASSIGN, COMMA, COMMENT, DECLS, DIGITS, DIV, DOT, EOF, EQ, GE, GT, ID, LBRACE, LBRACK, LE, LITERAL_byte, LITERAL_byte_array, LITERAL_ccall, LITERAL_complex, LITERAL_complex_array, LITERAL_else, LITERAL_float, LITERAL_float_array, LITERAL_for, LITERAL_if, LITERAL_int, LITERAL_int_array, LITERAL_string, LITERAL_ubyte, LITERAL_ubyte_array, LITERAL_uint, LITERAL_uint_array, LITERAL_while, LPAREN, LT, MINUS, MUL, NE, NEGATE, NEWLINE, NULL_TREE_LOOKAHEAD, NUM, PLUS, PROGRAM, RBRACE, RBRACK, REAL, RPAREN, SEMI, STRING, TILDE, WS
 
Constructor Summary
DSPLFloat(int numElements)
           
 
Method Summary
 java.lang.Object convertToObject(java.lang.String strValue)
          Method responsible for taking a string from the source code and converting it into the appriopriate Java Object for the primitive.
For all DSPL primitives except complex, the native java objects are used (String for string, Integer for int/uint, Float for float, etc).
 java.lang.Object convertToObject(java.lang.String strValue1, java.lang.String strValue2)
          Method responsible for taking two strings from the source code and converting it into the appriopriate Java Object for the primitive.
At time of writing, this is only required for Complex, which takes two strings (real and imag).
For complex, the dspl.intermediate.variable.primitive.Complex object is used
Note invoking the double string convertToObject on any type besides complex throws an error.
 int getDataType()
           
 int getDataTypeByteSize()
          Returns the size of the Variable type's byte size (for a single element)
 boolean isNaturalNum()
          Natural numbers are ints, uints, chars, and uchars.
 boolean isNumeric()
          Numeric types are defiend in the context of the allowable operations performable on them.
 
Methods inherited from class dspl.intermediate.variable.Variable
getAntlrTypeFromVarType, getAntlrTypeFromVarTypeArray, getArraySize, getByteSize, getIdentifier, getIndexVariable, getNewArray, getNewAtomic, getNewAtomicElement, getParentVariable, getSizeType, getValue, getVariableSizeType, initVariable, isArray, isAtomic, isConstant, isElement, isSameDataType, isValueSet, setIdentifier, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSPLFloat

public DSPLFloat(int numElements)
Method Detail

isNumeric

public boolean isNumeric()
Description copied from class: Variable
Numeric types are defiend in the context of the allowable operations performable on them. It is assumed that numeric types can undergo single and dual operand arithmatic operations, but non-numeric types cannot. For example, it is possible to add an integer constant to an array of integers, since both are numeric, but it is not possible to add a string to an integer, or add any numeric type to a string.

Specified by:
isNumeric in class Variable
Returns:
true if the Variable is a numeric type (int, float, array of numeric types, etc) and false if it is not (string)

getDataTypeByteSize

public int getDataTypeByteSize()
Description copied from class: Variable
Returns the size of the Variable type's byte size (for a single element)

Specified by:
getDataTypeByteSize in class Variable
Returns:
the size of bytes of the variable

getDataType

public int getDataType()
Specified by:
getDataType in class Variable
Returns:
the data tyep of the variable, must be one of the Variable.DATA_TYPE_xxx values

convertToObject

public java.lang.Object convertToObject(java.lang.String strValue)
Description copied from class: Variable
Method responsible for taking a string from the source code and converting it into the appriopriate Java Object for the primitive.
For all DSPL primitives except complex, the native java objects are used (String for string, Integer for int/uint, Float for float, etc).
Note: Invoking the single string convertToObject on a complex throws an Error since it is expecting two strings.

Specified by:
convertToObject in class Variable
Parameters:
strValue - the string expresion for the variable (i.e. "hello", "5", "3.4");
Returns:

convertToObject

public java.lang.Object convertToObject(java.lang.String strValue1,
                                        java.lang.String strValue2)
Description copied from class: Variable
Method responsible for taking two strings from the source code and converting it into the appriopriate Java Object for the primitive.
At time of writing, this is only required for Complex, which takes two strings (real and imag).
For complex, the dspl.intermediate.variable.primitive.Complex object is used
Note invoking the double string convertToObject on any type besides complex throws an error.

Specified by:
convertToObject in class Variable
Parameters:
strValue1 - the string expresion for the first variable
strValue2 - the string expression for the second variable
Returns:

isNaturalNum

public boolean isNaturalNum()
Description copied from class: Variable
Natural numbers are ints, uints, chars, and uchars.
This function is useful when there are different arithmatic machine instructions depending on whether the number is an integer or floating point type.

Specified by:
isNaturalNum in class Variable
Returns: