public override void OutAShadySAssignmentExp(AShadySAssignmentExp node) { if (node.GetLocalDeclRight().Count == 1 && ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetName() == null) { //Assignment expression //Cant have any [] or * after first lvalue if (node.GetPostPointers().Count > 0) { Token token; PShadyDynamicOps op = (PShadyDynamicOps)node.GetPostPointers()[0]; if (op is APointerShadyDynamicOps) token = ((APointerShadyDynamicOps) op).GetToken(); else token = ((AArrayShadyDynamicOps)op).GetToken(); errors.Add(new ErrorCollection.Error(token, currentSourceFile, "Didn't expect " + token.Text + " there. Im very confused.")); } if (node.GetGenericToken() != null) errors.Add(new ErrorCollection.Error(node.GetGenericToken(), "What the hell is this? I didn't see that coming. Or maybe I did.. But I don't like it!")); //an assignment can't be const); if (node.GetConst() != null) errors.Add(new ErrorCollection.Error(node.GetConst(), currentSourceFile, "Unexpected const", false)); //An assignment must have a right side if (((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetInit() == null || ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetAssignop() == null) { Token token = GetToken(node.GetLvalue()); errors.Add(new ErrorCollection.Error(token, currentSourceFile, "Expected assignment", false)); node.Parent().RemoveChild(node); return; } ASAssignmentExp exp = new ASAssignmentExp( ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetAssignop(), node.GetLvalue(), ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetInit()); node.ReplaceBy(exp); exp.Apply(this); } else { //Local decl AMultiLocalDecl localDecl = new AMultiLocalDecl(node.GetConst(), LvalueToType(node.GetLvalue(), node.GetPostPointers(), node.GetGenericToken(), node.GetGenericTypes()), new ArrayList()); while (node.GetLocalDeclRight().Count > 0) { localDecl.GetLocalDeclRight().Add(node.GetLocalDeclRight()[0]); } AExpStm expStm = Util.GetAncestor<AExpStm>(node); ALocalDeclStm localDeclStm = new ALocalDeclStm(expStm.GetToken(), localDecl); expStm.ReplaceBy(localDeclStm); localDeclStm.Apply(this); } }
public override void OutAShadySAssignmentExp(AShadySAssignmentExp node) { if (node.GetLocalDeclRight().Count == 1 && ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetName() == null) { //Assignment expression //an assignment can't be const); //An assignment must have a right side if (((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetInit() == null || ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetAssignop() == null) { node.Parent().RemoveChild(node); return; } ASAssignmentExp exp = new ASAssignmentExp( ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetAssignop(), node.GetLvalue(), ((AALocalDeclRight) node.GetLocalDeclRight()[0]).GetInit()); node.ReplaceBy(exp); exp.Apply(this); } else { //Local decl AMultiLocalDecl localDecl = new AMultiLocalDecl(node.GetConst(), LvalueToType(node.GetLvalue(), node.GetPostPointers(), node.GetGenericToken(), node.GetGenericTypes()), new ArrayList()); while (node.GetLocalDeclRight().Count > 0) { localDecl.GetLocalDeclRight().Add(node.GetLocalDeclRight()[0]); } AExpStm expStm = Util.GetAncestor<AExpStm>(node); ALocalDeclStm localDeclStm = new ALocalDeclStm(expStm.GetToken(), localDecl); expStm.ReplaceBy(localDeclStm); localDeclStm.Apply(this); } }