org.problets.domain.model.language
Class Language

java.lang.Object
  extended by org.problets.domain.model.language.Language
Direct Known Subclasses:
CLanguage, CSLanguage, JavaLanguage, PascalLanguage, VBLanguage

public abstract class Language
extends java.lang.Object

Serves as the base class for all the classes that provide language-specific details such as the available data types

Author:
Amruth Kumar

Constructor Summary
Language(java.lang.String[] inDataTypes)
           
 
Method Summary
 java.lang.String[] getAllDataTypes()
          Returns all the possible data types for the various languages
 java.lang.String getCaseHeader(java.lang.String value)
          Returns a case statement for the switch
 java.lang.String getDefaultDataType()
          The data type used for random number generation is an invalid data type has been specified
 java.lang.String getDefaultHeader()
          Returns the default case of switch
 Equals getEqualsOperator()
          Returns the Equals operator for this language
 ForLoopModel getForLoop(ActivationRecord parent, HeapModel heap, java.lang.String template, int scopeType)
          Returns the for loop model for the current language
 java.lang.String getIfHeader(java.lang.String condition)
          Returns the header of an if statement
 void getIntegerTypes(java.util.Vector optionVector)
          Returns the possible integer types for the various languages
abstract  int getMetaDataType(java.lang.String dataType)
          Returns the language-neutral meta data type (integer) corresponding to the language-specific string
abstract  BaseModulus getModulusOperator()
          Returns the Modulus operator for this language
 NotEquals getNotEqualsOperator()
          Returns the Equals operator for this language
 int getNumDataTypes()
          Returns the number of data types in this language
 java.lang.String getPrintString(java.lang.String printedValue, java.lang.String dataType)
          Returns the syntax for printing printedValue in the current language
 Program getProgram(ActivationRecord parentActivationRecord, HeapModel heap, java.lang.String template)
          Returns a program object for the given language
 void getRealTypes(java.util.Vector optionVector)
          Returns the possible real types for the various languages
 void getSignedTypes(java.util.Vector optionVector)
          Returns the possible signed types for the various languages
 java.lang.String getStatementDelimiter()
          Returns the delimiter for statements in the language
 java.lang.String getSwitchHeader(java.lang.String condition)
          Returns the switch statement header
 void getUnsignedTypes(java.util.Vector optionVector)
          Returns the possible unsigned types for the various languages
 java.lang.String getWhileHeader(java.lang.String condition)
          Returns the header of a while statement
 boolean hasUnsignedType()
          Returns whether unsigned data type exists in the language
abstract  boolean isIntegerType(java.lang.String dataType)
          Returns whether dataType is of integer type in the language
abstract  boolean isRealType(java.lang.String dataType)
          Returns whether dataType is of real type in the language
 boolean isValidDataType(java.lang.String currentDataType)
          Returns whether currentDataType is a valid data type for this language
static void main(java.lang.String[] args)
           
 boolean shouldExplainCoercionInAssignment(int variableMetaDataType, int valueMetaDataType)
          We want to avoid explaining coercion in expressions such as unsigned short x; x = 5; where 5 is automatically treated as CDouble.
 Value typeCompatibleAssign(Assignable left, Value right, boolean isCompoundOperator)
          Returns true if right value can be assigned to the left variable, and false otherwise
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Language

public Language(java.lang.String[] inDataTypes)
Method Detail

getAllDataTypes

public final java.lang.String[] getAllDataTypes()
Returns all the possible data types for the various languages


getNumDataTypes

public int getNumDataTypes()
Returns the number of data types in this language


getIntegerTypes

public void getIntegerTypes(java.util.Vector optionVector)
Returns the possible integer types for the various languages


getSignedTypes

public void getSignedTypes(java.util.Vector optionVector)
Returns the possible signed types for the various languages


hasUnsignedType

public boolean hasUnsignedType()
Returns whether unsigned data type exists in the language


getUnsignedTypes

public void getUnsignedTypes(java.util.Vector optionVector)
Returns the possible unsigned types for the various languages


getRealTypes

public void getRealTypes(java.util.Vector optionVector)
Returns the possible real types for the various languages


isValidDataType

public boolean isValidDataType(java.lang.String currentDataType)
Returns whether currentDataType is a valid data type for this language


isIntegerType

public abstract boolean isIntegerType(java.lang.String dataType)
Returns whether dataType is of integer type in the language

Parameters:
dataType - String which will be checked against integer types for the language

isRealType

public abstract boolean isRealType(java.lang.String dataType)
Returns whether dataType is of real type in the language

Parameters:
dataType - String which will be checked against real types for the language

getDefaultDataType

public java.lang.String getDefaultDataType()
The data type used for random number generation is an invalid data type has been specified


getMetaDataType

public abstract int getMetaDataType(java.lang.String dataType)
Returns the language-neutral meta data type (integer) corresponding to the language-specific string


shouldExplainCoercionInAssignment

public boolean shouldExplainCoercionInAssignment(int variableMetaDataType,
                                                 int valueMetaDataType)
We want to avoid explaining coercion in expressions such as unsigned short x; x = 5; where 5 is automatically treated as CDouble. Instead, we want to explain coercion only when integer values are assigned to real variables and vice versa. This function is called by inherited classes to determine whether they should explain coercion


typeCompatibleAssign

public Value typeCompatibleAssign(Assignable left,
                                  Value right,
                                  boolean isCompoundOperator)
Returns true if right value can be assigned to the left variable, and false otherwise

Parameters:
left - Assignable variable/expression
right - Value assigned to left variable/expression
Returns:
True if right value can be assigned to the left variable/expression, and false otherwise

getEqualsOperator

public Equals getEqualsOperator()
Returns the Equals operator for this language


getNotEqualsOperator

public NotEquals getNotEqualsOperator()
Returns the Equals operator for this language


getModulusOperator

public abstract BaseModulus getModulusOperator()
Returns the Modulus operator for this language


getStatementDelimiter

public java.lang.String getStatementDelimiter()
Returns the delimiter for statements in the language


getPrintString

public java.lang.String getPrintString(java.lang.String printedValue,
                                       java.lang.String dataType)
Returns the syntax for printing printedValue in the current language


getSwitchHeader

public java.lang.String getSwitchHeader(java.lang.String condition)
Returns the switch statement header


getCaseHeader

public java.lang.String getCaseHeader(java.lang.String value)
Returns a case statement for the switch


getDefaultHeader

public java.lang.String getDefaultHeader()
Returns the default case of switch


getWhileHeader

public java.lang.String getWhileHeader(java.lang.String condition)
Returns the header of a while statement


getIfHeader

public java.lang.String getIfHeader(java.lang.String condition)
Returns the header of an if statement


getForLoop

public ForLoopModel getForLoop(ActivationRecord parent,
                               HeapModel heap,
                               java.lang.String template,
                               int scopeType)
Returns the for loop model for the current language


getProgram

public Program getProgram(ActivationRecord parentActivationRecord,
                          HeapModel heap,
                          java.lang.String template)
Returns a program object for the given language


main

public static void main(java.lang.String[] args)