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); }
public void SetAssignop(PAssignop node) { if (_assignop_ != null) { _assignop_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _assignop_ = node; }
public AALocalDeclRight( TIdentifier _name_, PAssignop _assignop_, PExp _init_ ) { SetName(_name_); SetAssignop(_assignop_); SetInit(_init_); }
internal override void RemoveChild(Node child) { if (_assignop_ == child) { _assignop_ = null; return; } if (_lvalue_ == child) { _lvalue_ = null; return; } if (_exp_ == child) { _exp_ = null; return; } }
public ASAssignmentExp( PAssignop _assignop_, PLvalue _lvalue_, PExp _exp_ ) { SetAssignop(_assignop_); SetLvalue(_lvalue_); SetExp(_exp_); }
internal override void RemoveChild(Node child) { if (_name_ == child) { _name_ = null; return; } if (_assignop_ == child) { _assignop_ = null; return; } if (_init_ == child) { _init_ = null; return; } }