コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public override void CaseAShadySAssignmentExp(AShadySAssignmentExp node)
 {
     InAShadySAssignmentExp(node);
     {
         Object[] temp = new Object[node.GetLocalDeclRight().Count];
         node.GetLocalDeclRight().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PLocalDeclRight)temp[i]).Apply(this);
         }
     }
     {
         Object[] temp = new Object[node.GetPostPointers().Count];
         node.GetPostPointers().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PShadyDynamicOps)temp[i]).Apply(this);
         }
     }
     {
         Object[] temp = new Object[node.GetGenericTypes().Count];
         node.GetGenericTypes().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PType)temp[i]).Apply(this);
         }
     }
     if (node.GetGenericToken() != null)
     {
         node.GetGenericToken().Apply(this);
     }
     if (node.GetLvalue() != null)
     {
         node.GetLvalue().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetPrePointers().Count];
         node.GetPrePointers().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((TStar)temp[i]).Apply(this);
         }
     }
     if (node.GetConst() != null)
     {
         node.GetConst().Apply(this);
     }
     OutAShadySAssignmentExp(node);
 }
コード例 #3
0
        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);
            }
        }