|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttudresden.ocl.parser.analysis.AnalysisAdapter
tudresden.ocl.parser.analysis.DepthFirstAdapter
tudresden.ocl.codegen.ProceduralCodeGenerator
Subclasses should overwrite only inXxx/outXxx/caseXxx methods of
nodes "below" AConstraintBody
(below means nodes such that their production can be derived from the
production constraint_body
). The methods
inAConstraintBody
and outAConstraintBody
may be
overwritten, but not caseAConstraintBody
. This is not
enforced by declaring methods final
to allow those who know
what they are doing to change behaviour in these methods.
After leaving
outAConstraintBody
subclasses must leave a
variable name for the AConstraintBody
's Expression object in
the map ncm
. This name is then taken as the translation
for the contraint body.
Field Summary | |
protected StringBuffer |
code
the Java code for the expression |
(package private) String |
constrainedOperation
|
(package private) String |
constrainedType
|
(package private) int |
constraintKind
one of CodeFragment.PRE, CodeFragment.POST, CodeFragement.INV |
protected ArrayList |
fragments
|
protected LinkedList |
fragmentStack
|
(package private) int |
indent
|
(package private) int |
initialIndent
|
(package private) boolean |
newLine
|
private NodeNameMap |
nnm
maps Nodes to variable names for nodes; can be accessed through getVariable(Node n) |
(package private) String[][] |
parameters
Formal parameters of the constrainted operation if a operation is constrainted; null otherwise.parameters[i][j] contains the i-th parameters name if i==0
and the i-th parameters type if i==1 |
protected StringBuffer |
preCode
Java code that is nessacary to evaluate @pre time expressions; will often be null (if the OCL expression contains no @pre) |
(package private) boolean |
preCodeIsValid
|
(package private) ArrayList |
preVariables
the list of variable determined in preCode and used in
code |
(package private) HashMap |
preVarTypes
maps pre variables to their types; the key set of this map must contain exactly those elements that are in preVariables |
protected ProceduralCodeFragment |
topOfStack
|
protected OclTree |
tree
|
(package private) boolean |
writeToPreCode
|
(package private) boolean |
writeToStandardCode
|
Fields inherited from class tudresden.ocl.parser.analysis.AnalysisAdapter |
|
Constructor Summary | |
ProceduralCodeGenerator()
|
Method Summary | |
private void |
addParameter(ArrayList parameterNames,
ArrayList parameterTypes,
AFormalParameter fp)
|
void |
addPreVariable(String var,
String type)
|
protected void |
appendCode(String s)
|
void |
assurePreCode()
make the preCode become an own fragment |
protected void |
beginNewFragment(String name,
String type,
String operation,
int kind)
|
void |
caseAConstraintBody(AConstraintBody cb)
|
protected void |
decreaseIndent(int i)
|
protected void |
endFragment(String resultVariable)
|
CodeFragment[] |
getCode(OclTree tree)
|
protected abstract String |
getTransferCode(String var,
String type)
|
protected String |
getVariable(Node n)
get a variable name for a AST node; this method either returns the name stored in the map nnm (if the map contains a mapping for node ) or
creates a new name, stores it in nnm and returns it |
void |
inAClassifierContext(AClassifierContext cc)
|
void |
inAInvStereotype(AInvStereotype is)
|
void |
inAOperationContext(AOperationContext oc)
|
void |
inAPostStereotype(APostStereotype is)
|
void |
inAPreStereotype(APreStereotype is)
|
protected void |
increaseIndent(int i)
|
protected void |
reachThrough(Node from,
Node to)
set the variable name representing node from to the variable
name of node to |
protected abstract void |
requireTreeInvariants()
gives subclasses the opportunity to check if the OclTree requires some invariants, using OclTree's requireInvariant() method |
void |
setInitialIndent(int initialIndent)
|
protected void |
setVariable(Node n,
String var)
set the variable for a node |
void |
writeToBothCodes()
|
void |
writeToPreCodeOnly()
|
void |
writeToStandardCodeOnly()
|
Methods inherited from class tudresden.ocl.parser.analysis.AnalysisAdapter |
caseEOF, caseTAnd, caseTApostroph, caseTArrow, caseTAt, caseTBar, caseTBlank, caseTBool, caseTChannel, caseTColon, caseTComma, caseTComment, caseTContext, caseTDcolon, caseTDdot, caseTDiv, caseTDot, caseTEndif, caseTEnum, caseTEqual, caseTGt, caseTGteq, caseTImplies, caseTInt, caseTLBrace, caseTLBracket, caseTLPar, caseTLt, caseTLteq, caseTMinus, caseTMult, caseTName, caseTNEqual, caseTNewLine, caseTNot, caseTOr, caseTPlus, caseTRBrace, caseTRBracket, caseTReal, caseTRPar, caseTSemicolon, caseTSimpleTypeName, caseTStringLit, caseTTab, caseTTBag, caseTTCollection, caseTTElse, caseTTIf, caseTTIn, caseTTInv, caseTTLet, caseTTPost, caseTTPre, caseTTSequence, caseTTSet, caseTTThen, caseTXor, defaultCase, getIn, getOut, setIn, setOut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ArrayList fragments
protected LinkedList fragmentStack
protected ProceduralCodeFragment topOfStack
private NodeNameMap nnm
getVariable(Node n)
protected OclTree tree
protected StringBuffer code
protected StringBuffer preCode
null
(if the OCL expression contains no @pre)
boolean writeToPreCode
boolean writeToStandardCode
boolean preCodeIsValid
ArrayList preVariables
preCode
and used in
code
HashMap preVarTypes
int indent
int initialIndent
boolean newLine
String constrainedType
String constrainedOperation
String[][] parameters
null
otherwise.parameters[i][j]
contains the i-th parameters name if i==0
and the i-th parameters type if i==1
int constraintKind
Constructor Detail |
public ProceduralCodeGenerator()
Method Detail |
protected void beginNewFragment(String name, String type, String operation, int kind)
operation
- is null
for invariantsprotected void endFragment(String resultVariable)
protected String getVariable(Node n)
nnm
(if the map contains a mapping for node
) or
creates a new name, stores it in nnm
and returns it
node
protected void setVariable(Node n, String var)
protected void reachThrough(Node from, Node to)
from
to the variable
name of node to
protected void appendCode(String s)
public void setInitialIndent(int initialIndent)
protected void increaseIndent(int i)
protected void decreaseIndent(int i)
public void inAClassifierContext(AClassifierContext cc)
inAClassifierContext
in class DepthFirstAdapter
public void inAOperationContext(AOperationContext oc)
inAOperationContext
in class DepthFirstAdapter
private void addParameter(ArrayList parameterNames, ArrayList parameterTypes, AFormalParameter fp)
public final void caseAConstraintBody(AConstraintBody cb)
caseAConstraintBody
in interface Analysis
caseAConstraintBody
in class DepthFirstAdapter
public void inAInvStereotype(AInvStereotype is)
inAInvStereotype
in class DepthFirstAdapter
public void inAPreStereotype(APreStereotype is)
inAPreStereotype
in class DepthFirstAdapter
public void inAPostStereotype(APostStereotype is)
inAPostStereotype
in class DepthFirstAdapter
protected abstract String getTransferCode(String var, String type)
protected abstract void requireTreeInvariants()
public void assurePreCode()
public void writeToPreCodeOnly()
public void writeToStandardCodeOnly()
public void writeToBothCodes()
public void addPreVariable(String var, String type)
public CodeFragment[] getCode(OclTree tree)
getCode
in interface CodeGenerator
|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |