📄 ircleaner.java
字号:
/**
*This class is used for expressions using the AND operation.
*This class extends the Exp abstract class
**/
package CatDecaf.Optimizer;
import CatDecaf.IR.*;
import CatDecaf.Utilities.*;
public class IRCleaner implements Visitor{
public IRCleaner(){
}
public void visit(Ir n){ } //abstract class
public void visit(IrProg n){
if(n.fdDeclList_!=null)
n.fdDeclList_.accept(this);
if(n.mdDeclList_ == null) System.out.println("ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!");
n.mdDeclList_.accept(this); //this should never be empty
}
public void visit(FdDeclList n){ //not printing List classes
while(n!= null)
{
n.fdDecl_.accept(this);
n = n.fdDeclList_;
}
}
public void visit(FdDecl n){
if(n.glbVarList_==null) System.out.println("ERROR!!!!!!!!!!!!!!!");
n.typ_.accept(this);
n.glbVarList_.accept(this);
}
public void visit(GlbVar n){ } //abstract class
public void visit(GlbVarArray n){
n.identifier_.accept(this);
n.ltrInt_.accept(this);
}
public void visit(GlbVarId n){
n.identifier_.accept(this);
}
public void visit(GlbVarList n){ //not printing List classes
while(n!= null)
{
n.glbVar_.accept(this);
n = n.glbVarList_;
}
}
public void visit(Typ n){ } //abstract class
public void visit(TypInt n){
}
public void visit(TypBool n){
}
public void visit(TypVoid n){
}
public void visit(MdDeclList n){ //not printing List classes
while(n!= null)
{
n.mdDecl_.accept(this);
n = n.mdDeclList_;
}
}
public void visit(MdDecl n){
n.typ_.accept(this);
n.identifier_.accept(this);
if(n.mdParaList_ !=null){ //method parameter list could be NULL
n.mdParaList_.accept(this);
}
n.block_.accept(this);
}
public void visit(MdParaList n){ //not printing List classes
while(n!= null)
{
n.mdPara_.accept(this);
n = n.mdParaList_;
}
}
public void visit(MdPara n){
n.typ_.accept(this);
n.identifier_.accept(this);
}
public void visit(Block n){
if(n.varDeclList_!=null) //var declaration list could be empty
n.varDeclList_.accept(this);
if(n.stmtList_!=null)//list can be empty
n.stmtList_.accept(this);
}
public void visit(VarDecl n){
n.typ_.accept(this);
if(n.locVarList_==null) System.out.println("ERROR!!!!!!!!!!!!!!!");
n.locVarList_.accept(this);
}
public void visit(VarDeclList n){ //not printing List classes
while(n!= null)
{
n.varDecl_.accept(this);
n = n.varDeclList_;
}
}
public void visit(LocVar n){
n.identifier_.accept(this);
}
public void visit(LocVarList n){ //not printing List classes
while(n!= null)
{
n.locVar_.accept(this);
n = n.locVarList_;
}
}
public void visit(StmtList n){ //not printing List classes
while(n!= null)
{
n.stmt_.accept(this);
n = n.stmtList_;
}
}
public void visit(Stmt n){ } //abstract class
public void visit(StmtLocation n){
n.location_.accept(this);
n.exp_.accept(this);
}
public void visit(StmtBlock n){
n.block_.accept(this);
}
public void visit(StmtMdCall n){
n.mdCall_.accept(this);
}
public void visit(Location n){ } //abstract class
public void visit(LocationId n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.identifier_.accept(this);
}
public void visit(LocationArray n){
n.identifier_.accept(this);
n.exp_.accept(this);
}
public void visit(CallOutArgList n){ //not printing List classes
while(n!= null)
{
n.callOutArg_.accept(this);
n = n.callOutArgList_;
}
}
public void visit(CallOutArg n){ } //abstract class
public void visit(CallOutArgExp n){
n.exp_.accept(this);
}
public void visit(CallOutArgStr n){
n.ltrString_.accept(this);
}
public void visit(MdCall n){ } //abstract class
public void visit(MdCallOut n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.ltrString_.accept(this);
if(n.callOutArgList_!=null) //could be empty
n.callOutArgList_.accept(this);
}
public void visit(MdCallIn n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.identifier_.accept(this);
if(n.expList_!=null) //could be empty
n.expList_.accept(this);
}
public void visit(ExpList n){ //not printing List classes
while(n!= null)
{
n.exp_.accept(this);
n = n.expList_;
}
}
public void visit(StmtForLoop n){
n.identifier1_.accept(this);
n.exp1_.accept(this);
n.exp2_.accept(this);
n.identifier3_.accept(this);
n.exp3_.accept(this);
n.block_.accept(this);
}
public void visit(StmtIfElse n){
n.exp_.accept(this);
n.ifBlock_.accept(this);
if(n.elseBlock_!=null) { //else block could be empty
n.elseBlock_.accept(this);
}
}
public void visit(StmtReturn n){
if(n.exp_ != null) //could return nothing
n.exp_.accept(this);
}
public void visit(StmtWhileLoop n){
n.exp_.accept(this);
n.block_.accept(this);
}
public void visit(Literal n){}//abstract
public void visit(Exp n){}//abstract
public void visit(ExpPlus n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpMinus n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpTimes n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpDivide n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpMod n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpUMinus n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp_.accept(this);
}
public void visit(ExpShiftLeft n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpShiftRight n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpLessThan n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpGreaterThan n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpLessThEql n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpGreaterThEql n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpEqualTo n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpNotEqualTo n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpAndOp n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(ExpOrOp n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
n.exp1_.accept(this);
n.exp2_.accept(this);
}
public void visit(LtrBoolFalse n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
}
public void visit(LtrBoolTrue n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
}
public void visit(LtrChar n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
}
public void visit(LtrInt n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
}
public void visit(LtrString n){
n.compileResult=null;
n.constantResult=null;
n.algebraicResult=null;
n.copyResult=null;
}
public void visit(Identifier n){
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -