mChaRM.PremChaRM
Class PremChaRM

java.lang.Object
  |
  +--openjava.mop.OJClass
        |
        +--mChaRM.PremChaRM.PremChaRM
All Implemented Interfaces:
OJMember

public class PremChaRM
extends OJClass

This class represents the OpenJava Preprocessor for a class containing the mChaRM mechanism. Its role is to translate the OpenJava class who instantiates it (which is a class written in an extended syntax of java) into three pure-java classes. The whole class contains methods and objects representing the mChaRM objects Core Channel, Sender and Receiver. The classes created by PremChaRM represent these objects and they are obtained sharing out methods and fields according the use they did. A method or a field is put into a class only if it is really used by respective mChaRM object.

Author:
Valentina Cordì (1996s081@educ.disi.unige.it), Maurizio Mazza (1996s065@educ.disi.unige.it), Roberto Montagna (1996s063@educ.disi.unige.it)

Fields inherited from interface openjava.mop.OJMember
DECLARED, PUBLIC
 
Constructor Summary
PremChaRM(java.lang.Class oj_param0, MetaInfo oj_param1)
           
PremChaRM(Environment oj_param0, OJClass oj_param1, ClassDeclaration oj_param2)
           
 
Method Summary
 Expression expandAllocation(Environment env, AllocationExpression expr)
          This method is invoked on every AllocationExpression instance of start class.
 Expression expandMethodCall(Environment env, MethodCall call)
          This method is invoked on every MethodCall instance of start class not tested yet.
 TypeName expandTypeName(Environment env, TypeName type)
          This method is invoked on every TypeName instance of start class.
 Statement expandVariableDeclaration(Environment env, VariableDeclaration var)
          This method is invoked on every VariableDeclaration instance of start class.
static SyntaxRule getDeclSuffixRule(java.lang.String keyword)
          Function predefined in OJClass, is used to get a parse tree of added syntax.
 void HandleFirstTime(java.lang.String expr)
          This method takes the info in OJMI file of sterting class.
static boolean isRegisteredKeyword(java.lang.String keyword)
          Function predefined in OJClass, is used to check if the keyword present in added syntax regard current OJClass
 OJMethod methodCall2OJMethod(MethodCall mcMethod, Environment environment)
          This method perform the translation of MethodCall into OJMethod.
 void openClasses()
          This method create the output class.
 java.lang.String[] parseConstr(java.lang.String constr)
           
 java.lang.String parseConstr(java.util.StringTokenizer strToken, char stop)
           
 void translateDefinition()
          This is the starting point of pre-compiling.
 
Methods inherited from class openjava.mop.OJClass
addClass, addConstructor, addField, addInterface, addMethod, arrayForClasses, expandArrayAccess, expandArrayAllocation, expandAssignmentExpression, expandCastedExpression, expandCastExpression, expandExpression, expandFieldRead, expandFieldWrite, forClass, forName, forObject, forParseTree, getAcceptableConstructor, getAcceptableMethod, getAllClasses, getAllField, getAllFields, getAllMethod, getAllMethods, getAllMethods, getByteCode, getClasses, getClasses, getClassLoader, getCompatibleJavaClass, getComponentType, getConstructor, getConstructor, getConstructors, getConstructors, getDeclaredClasses, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredFields, getDeclaredMethod, getDeclaredMethods, getDeclaringClass, getEnvironment, getField, getField, getFields, getFields, getInheritableClasses, getInheritableClasses, getInheritableConstructors, getInheritableFields, getInheritableFields, getInheritableMethods, getInheritableMethods, getInheritedClasses, getInheritedFields, getInheritedMethods, getInterfaces, getMetaInfo, getMetaInfoElements, getMetaInfoKeys, getMethod, getMethod, getMethods, getMethods, getModifiers, getName, getPackage, getResource, getResourceAsStream, getSigners, getSimpleName, getSourceCode, getSuffix, getSuperclass, getTypeSuffixRule, isAlterable, isArray, isAssignableFrom, isExecutable, isInSamePackage, isInstance, isInterface, isPrimitive, isPrimitiveWrapper, isRegisteredModifier, makeCopy, makeExpression, makeExpression, makeStatement, makeStatement, makeStatementList, makeStatementList, newInstance, primitiveWrapper, putMetaInfo, removeClass, removeConstructor, removeField, removeMethod, resolveException, resolveException, setDeclaringClass, setInterfaces, setName, setSuperclass, signature, toClasses, toString, translateDefinition, unwrappedPrimitive, waitTranslation, writeMetaInfo
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PremChaRM

public PremChaRM(Environment oj_param0,
                 OJClass oj_param1,
                 ClassDeclaration oj_param2)

PremChaRM

public PremChaRM(java.lang.Class oj_param0,
                 MetaInfo oj_param1)
Method Detail

isRegisteredKeyword

public static boolean isRegisteredKeyword(java.lang.String keyword)
Function predefined in OJClass, is used to check if the keyword present in added syntax regard current OJClass
Parameters:
keyword - String that must be check
Returns:
true if the keyword is correct

getDeclSuffixRule

public static SyntaxRule getDeclSuffixRule(java.lang.String keyword)
Function predefined in OJClass, is used to get a parse tree of added syntax.
Parameters:
keyword - start String of added syntax
Returns:
the parse tree contains all added syntax

openClasses

public void openClasses()
This method create the output class. It starting after that the added syntax is parsing, it create and initialize the output class.
The new class is insert ipn instance of OJSubClass
See Also:
OJSubClass

parseConstr

public java.lang.String[] parseConstr(java.lang.String constr)

parseConstr

public java.lang.String parseConstr(java.util.StringTokenizer strToken,
                                    char stop)

methodCall2OJMethod

public OJMethod methodCall2OJMethod(MethodCall mcMethod,
                                    Environment environment)
This method perform the translation of MethodCall into OJMethod. This translation is done only if the MethodCall deals a method belong to start class, otherwise it return null. To do the translation it searchs a OJMethod with same name and same parameters type.
Parameters:
mcMethod - MethodCall to translate in OJMethod
environment - current Environment
Returns:
OJMethod invoked by specified MethodCall.

translateDefinition

public void translateDefinition()
This is the starting point of pre-compiling. Initially it checks th syntax, then creates and initializes the output classes, finally it prints\ all three classes and prepare main class. All this things are doing using several methods.
Overrides:
translateDefinition in class OJClass

expandVariableDeclaration

public Statement expandVariableDeclaration(Environment env,
                                           VariableDeclaration var)
This method is invoked on every VariableDeclaration instance of start class. It change type of Declaration into Core Type.
Overrides:
expandVariableDeclaration in class OJClass
Parameters:
env - current Environment
var - current VariableDeclaration

expandTypeName

public TypeName expandTypeName(Environment env,
                               TypeName type)
This method is invoked on every TypeName instance of start class. It change type name into Core Type.
Overrides:
expandTypeName in class OJClass
Parameters:
env - current Environment
type - current TypeName

expandAllocation

public Expression expandAllocation(Environment env,
                                   AllocationExpression expr)
This method is invoked on every AllocationExpression instance of start class. It earch the constructor and change it into a new constructor of Core class. To do that change name of current constructor and add it three parameters, KIND of Channel name of SENDER and RECEIVER.
Overrides:
expandAllocation in class OJClass
Parameters:
env - current Environment
expr - current AllocationExpression

expandMethodCall

public Expression expandMethodCall(Environment env,
                                   MethodCall call)
This method is invoked on every MethodCall instance of start class not tested yet. It check if a method is static, if so it translate it, otherwise don't make anything. To translate calling changeReferenceExpr
Overrides:
expandMethodCall in class OJClass
Parameters:
env - current Environment
call - current MethodCall

HandleFirstTime

public void HandleFirstTime(java.lang.String expr)
This method takes the info in OJMI file of sterting class. This method is performs only once.
Parameters:
expr - string representig the Core name