public override void CaseASAssignmentExp(ASAssignmentExp node) { InASAssignmentExp(node); if (node.GetExp() != null) { node.GetExp().Apply(this); } if (node.GetLvalue() != null) { node.GetLvalue().Apply(this); } if (node.GetAssignop() != null) { node.GetAssignop().Apply(this); } OutASAssignmentExp(node); }
public override void OutASAssignmentExp(ASAssignmentExp node) { AAssignmentExp replacer = null; PAssignop assignop = node.GetAssignop(); Token token = null; PBinop binop = null; if (assignop is AAddAssignop) { token = ((AAddAssignop)assignop).GetToken(); binop = new APlusBinop(new TPlus("+", token.Line, token.Pos)); } else if (assignop is ASubAssignop) { token = ((ASubAssignop)assignop).GetToken(); binop = new AMinusBinop(new TMinus("-", token.Line, token.Pos)); } else if (assignop is AMulAssignop) { token = ((AMulAssignop)assignop).GetToken(); binop = new ATimesBinop(new TStar("*", token.Line, token.Pos)); } else if (assignop is ADivAssignop) { token = ((ADivAssignop)assignop).GetToken(); binop = new ADivideBinop(new TDiv("/", token.Line, token.Pos)); } else if (assignop is AModAssignop) { token = ((AModAssignop)assignop).GetToken(); binop = new AModuloBinop(new TMod("%", token.Line, token.Pos)); } else// if (assignop is AAssignAssignop) { token = ((AAssignAssignop)assignop).GetToken(); } PExp rightSide; if (binop != null) rightSide = new ABinopExp(new ALvalueExp((PLvalue)node.GetLvalue().Clone()), binop, (PExp)node.GetExp().Clone()); else rightSide = (PExp)node.GetExp().Clone(); replacer = new AAssignmentExp(new TAssign("=", token.Line, token.Pos), (PLvalue)node.GetLvalue().Clone(), rightSide); node.ReplaceBy(replacer); replacer.Apply(this); }