Skip to content
Snippets Groups Projects
Select Git revision
  • 6ffc322932ce212b6c8ca2069243c14d281ddd05
  • main default protected
2 results

check07exe

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Sa2c3a.java 5.24 KiB
    package c3a;
    import ts.*;
    import sa.*;
    
    
    public class Sa2c3a extends SaDepthFirstVisitor <C3aOperand> {
        private C3a c3a;
        int indentation;
        public C3a getC3a(){return this.c3a;}
        
        public Sa2c3a(SaNode root, Ts tableGlobale){
    	c3a = new C3a();
    	C3aTemp result = c3a.newTemp();
    	C3aFunction fct = new C3aFunction(tableGlobale.getFct("main"));
    	c3a.ajouteInst(new C3aInstCall(fct, result, ""));
    	c3a.ajouteInst(new C3aInstStop(result, ""));
    	indentation = 0;
        }
    
        public void defaultIn(SaNode node)
        {
    	for(int i = 0; i < indentation; i++){System.out.print(" ");}
    	indentation++;
    	System.out.println("<" + node.getClass().getSimpleName() + ">");
        }
    
        public void defaultOut(SaNode node)
        {
    	indentation--;
    		for(int i = 0; i < indentation; i++){System.out.print(" ");}
    		System.out.println("</" + node.getClass().getSimpleName() + ">");
        }
        
    
        // EXP -> op2 EXP EXP
        public C3aOperand visit(SaExpAdd node) throws Exception
        {
    	defaultIn(node);
    	C3aOperand op1 = node.getOp1().accept(this);
    	C3aOperand op2 = node.getOp2().accept(this);
    	C3aOperand result = c3a.newTemp();
    
    	c3a.ajouteInst(new C3aInstAdd(op1, op2, result, ""));
    	defaultOut(node);
    	return result;
        }
    
    	@Override
    	public C3aOperand visit(SaProg node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaDecTab node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExp node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpInt node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpVrai node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpFaux node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpVar node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstEcriture node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstTantQue node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaLInst node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaDecFonc node) throws Exception {
    		defaultIn(node);
    		C3aOperand result = c3a.newAutoLabel();
    		c3a.ajouteInst(new C3aInstFBegin(node.tsItem, "begin"));
    		node.getCorps().accept(this);
    		c3a.ajouteInst(new C3aInstFEnd("end"));
    		defaultOut(node);
    		return result;
    	}
    
    	@Override
    	public C3aOperand visit(SaDecVar node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstAffect node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaLDecVar node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaLDecFonc node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaVarSimple node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaAppel node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpAppel node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpSub node) throws Exception {
    		defaultIn(node);
    		C3aOperand op1 = node.getOp1().accept(this);
    		C3aOperand op2 = node.getOp2().accept(this);
    		C3aOperand result = c3a.newTemp();
    
    		c3a.ajouteInst(new C3aInstSub(op1, op2, result, ""));
    		defaultOut(node);
    		return result;
    	}
    
    	@Override
    	public C3aOperand visit(SaExpMult node) throws Exception {
    		defaultIn(node);
    		C3aOperand op1 = node.getOp1().accept(this);
    		C3aOperand op2 = node.getOp2().accept(this);
    		C3aOperand result = c3a.newTemp();
    
    		c3a.ajouteInst(new C3aInstMult(op1, op2, result, ""));
    		defaultOut(node);
    		return result;
    	}
    
    	@Override
    	public C3aOperand visit(SaExpDiv node) throws Exception {
    		defaultIn(node);
    		C3aOperand op1 = node.getOp1().accept(this);
    		C3aOperand op2 = node.getOp2().accept(this);
    		C3aOperand result = c3a.newTemp();
    
    		c3a.ajouteInst(new C3aInstDiv(op1, op2, result, ""));
    		defaultOut(node);
    		return result;
    	}
    
    	@Override
    	public C3aOperand visit(SaExpInf node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpEqual node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpAnd node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpOr node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpNot node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaExpLire node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstBloc node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstSi node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaInstRetour node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaLExp node) throws Exception {
    		return super.visit(node);
    	}
    
    	@Override
    	public C3aOperand visit(SaVarIndicee node) throws Exception {
    		return super.visit(node);
    	}
    }