tip.cfg.cfa
Class Normalization

java.lang.Object
  extended by tip.analysis.AnalysisAdapter
      extended by tip.analysis.DepthFirstAdapter
          extended by tip.cfg.cfa.Normalization
All Implemented Interfaces:
Analysis

public class Normalization
extends DepthFirstAdapter

Author:
Johnni

Constructor Summary
Normalization()
           
 
Method Summary
 void caseABlock(ABlock node)
          Handles blocks of statements.
 void caseAIfThenElseStm(AIfThenElseStm node)
          Handles if-then-else statements.
 void caseAIfThenStm(AIfThenStm node)
          Handles if-then statements.
 void caseAWhileStm(AWhileStm node)
          Handles while statements.
 void inABody(ABody node)
          Clears the list of new identifiers for this body.
 void inAReturnStm(AReturnStm node)
          Normalizes return statements: S -> return E : E !
 void inAAssignPtrStm(AAssignPtrStm node)
          Normalizes pointer assignments: S -> *E1 = E2 : E1 !
 void outABody(ABody node)
          Add all new identifiers to a ADeclStm in the start of the body.
 void outADerefExp(ADerefExp node)
          Normalizes deref expressions: E -> *E1 : E \notin S -> id = E => S -> x = *E1 E -> x
 void outAFunctionCallExp(AFunctionCallExp node)
          Normalizes function call expressions: E -> f(E1,...
 void outAMallocExp(AMallocExp node)
          Normalizes malloc expressions: E -> malloc : E \notin S -> id = E => S -> x = malloc E -> x
 void outAPointerExp(APointerExp node)
          Normalizes pointer expressions: E -> &id : E \notin S -> id1 = &id2 => S -> x = &id2 E -> x
 
Methods inherited from class tip.analysis.DepthFirstAdapter
caseABinopExp, caseABlockStm, caseABody, caseADeclStm, caseADerefExp, caseADivideBinop, caseAEqBinop, caseAFuncDecl, caseAFunctionCallExp, caseAFunctionPtrCallExp, caseAGtBinop, caseAInputExp, caseAIntConstExp, caseALocalDecl, caseAMallocExp, caseAMinusBinop, caseANullExp, caseAOutputStm, caseAPlusBinop, caseAPointerExp, caseAProgram, caseAReturnStm, caseATimesBinop, caseAVarExp, caseStart, caseAAssignPtrStm, caseAAssignVarStm, defaultIn, defaultInPBinop, defaultInPBlock, defaultInPBody, defaultInPDecl, defaultInPExp, defaultInPProgram, defaultInPStm, defaultOut, defaultOutPBinop, defaultOutPBlock, defaultOutPBody, defaultOutPDecl, defaultOutPExp, defaultOutPProgram, defaultOutPStm, defaultPBinop, defaultPBlock, defaultPBody, defaultPDecl, defaultPExp, defaultPProgram, defaultPStm, inABinopExp, inABlock, inABlockStm, inADeclStm, inADerefExp, inADivideBinop, inAEqBinop, inAFuncDecl, inAFunctionCallExp, inAFunctionPtrCallExp, inAGtBinop, inAIfThenElseStm, inAIfThenStm, inAInputExp, inAIntConstExp, inALocalDecl, inAMallocExp, inAMinusBinop, inANullExp, inAOutputStm, inAPlusBinop, inAPointerExp, inAProgram, inATimesBinop, inAVarExp, inAWhileStm, inStart, inAAssignVarStm, outABinopExp, outABlock, outABlockStm, outADeclStm, outADivideBinop, outAEqBinop, outAFuncDecl, outAFunctionPtrCallExp, outAGtBinop, outAIfThenElseStm, outAIfThenStm, outAInputExp, outAIntConstExp, outALocalDecl, outAMinusBinop, outANullExp, outAOutputStm, outAPlusBinop, outAProgram, outAReturnStm, outATimesBinop, outAVarExp, outAWhileStm, outStart, outAAssignPtrStm, outAAssignVarStm
 
Methods inherited from class tip.analysis.AnalysisAdapter
caseEOF, caseTAnd, caseTAssign, caseTComma, caseTCommentBlock, caseTCommentSingle, caseTDiv, caseTElse, caseTEq, caseTGt, caseTIdentifier, caseTIf, caseTInput, caseTIntegerConst, caseTLBrace, caseTLPar, caseTMalloc, caseTMinus, caseTNull, caseTOutput, caseTPlus, caseTRBrace, caseTReturn, caseTRPar, caseTSemicolon, caseTStar, caseTVar, caseTWhile, caseTWhiteSpace, defaultNode, defaultToken, getIn, getOut, setIn, setOut
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Normalization

public Normalization()
Method Detail

caseABlock

public void caseABlock(ABlock node)
Handles blocks of statements.

Specified by:
caseABlock in interface Analysis
Overrides:
caseABlock in class DepthFirstAdapter
Parameters:
node - the current block

inABody

public void inABody(ABody node)
Clears the list of new identifiers for this body.

Overrides:
inABody in class DepthFirstAdapter
Parameters:
node - the body node

outABody

public void outABody(ABody node)
Add all new identifiers to a ADeclStm in the start of the body.

Overrides:
outABody in class DepthFirstAdapter
Parameters:
node - the current body node

outAFunctionCallExp

public void outAFunctionCallExp(AFunctionCallExp node)
Normalizes function call expressions:
 E -> f(E1,...,En) =>
                x1 = E1;
                ...
                xn = En
                xf = f;
                r = (xf)(x1,...,xn)
                E -> r
 

Overrides:
outAFunctionCallExp in class DepthFirstAdapter
Parameters:
node - the current function call expression

outAPointerExp

public void outAPointerExp(APointerExp node)
Normalizes pointer expressions:
 E -> &id : E \notin S -> id1 = &id2 =>
 
                S -> x = &id2
                E -> x
 

Overrides:
outAPointerExp in class DepthFirstAdapter
Parameters:
node - the current pointer expression

outADerefExp

public void outADerefExp(ADerefExp node)
Normalizes deref expressions:
        E -> *E1 : E \notin S -> id = E =>
 
                S -> x = *E1
                E -> x
 

Overrides:
outADerefExp in class DepthFirstAdapter
Parameters:
node - the current deref expression

outAMallocExp

public void outAMallocExp(AMallocExp node)
Normalizes malloc expressions:
 E -> malloc : E \notin S -> id = E =>
                
                S -> x = malloc
                E -> x
 

Overrides:
outAMallocExp in class DepthFirstAdapter
Parameters:
node - the current malloc expression

inAAssignPtrStm

public void inAAssignPtrStm(AAssignPtrStm node)
Normalizes pointer assignments:
        S -> *E1 = E2 : E1 != id =>
 
                S1 -> x = E2
                S2 -> y = E1
                S -> *y = x
 
        S -> *E1 = E2 : E1 = id, E2 != id =>
 
                S1 -> x = E2
                S -> *E1 = x
 

Overrides:
inAAssignPtrStm in class DepthFirstAdapter
Parameters:
node - the current pointer assignment

inAReturnStm

public void inAReturnStm(AReturnStm node)
Normalizes return statements:
 S -> return E : E != id =>
        
                S1 -> x = E
                S -> return x
 

Overrides:
inAReturnStm in class DepthFirstAdapter
Parameters:
node - the current return statement

caseAIfThenStm

public void caseAIfThenStm(AIfThenStm node)
Handles if-then statements. Need to manual set current statement for the body statement - it might not be a ABlockStm.

Specified by:
caseAIfThenStm in interface Analysis
Overrides:
caseAIfThenStm in class DepthFirstAdapter
Parameters:
node - the current if-then statement

caseAIfThenElseStm

public void caseAIfThenElseStm(AIfThenElseStm node)
Handles if-then-else statements. Need to manually set current statement for the body statements - it might not be a ABlockStm.

Specified by:
caseAIfThenElseStm in interface Analysis
Overrides:
caseAIfThenElseStm in class DepthFirstAdapter
Parameters:
node - the current if-then-else statement

caseAWhileStm

public void caseAWhileStm(AWhileStm node)
Handles while statements. Need to manually set current statement for the body statement - it might not be a ABlockStm.

Specified by:
caseAWhileStm in interface Analysis
Overrides:
caseAWhileStm in class DepthFirstAdapter
Parameters:
node - the current while statement