コード例 #1
0
 public override void CaseAMultiLocalDecl(AMultiLocalDecl node)
 {
     PStm pStm = Util.GetAncestor<PStm>(node);
     if (!(pStm.Parent() is AABlock))
     {
         return;
     }
     AABlock pBlock = (AABlock) pStm.Parent();
     List<AALocalDecl> newDecls = new List<AALocalDecl>();
     foreach (AALocalDeclRight right in node.GetLocalDeclRight())
     {
         if (right.GetName() == null)
         {
             continue;
         }
         if ((right.GetAssignop() == null) != (right.GetInit() == null))
         {
             continue;
         }
         AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null,
                                                 node.GetConst() != null
                                                     ? (TConst) node.GetConst().Clone()
                                                     : null,
                                                 (PType) node.GetType().Clone(),
                                                 right.GetName(),
                                                 right.GetInit());
         newDecls.Add(localDecl);
         pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), new ALocalDeclStm(new TSemicolon(";"), localDecl));
     }
     pBlock.RemoveChild(pStm);
     foreach (AALocalDecl localDecl in newDecls)
     {
         localDecl.Apply(this);
     }
 }
コード例 #2
0
 internal LocalDeclRight_Cast(AMultiLocalDecl obj)
 {
     this.obj = obj;
 }
コード例 #3
0
 public virtual void CaseAMultiLocalDecl(AMultiLocalDecl node)
 {
     DefaultCase(node);
 }
コード例 #4
0
 public virtual void OutAMultiLocalDecl(AMultiLocalDecl node)
 {
     DefaultOut(node);
 }
コード例 #5
0
 public virtual void InAMultiLocalDecl(AMultiLocalDecl node)
 {
     DefaultIn(node);
 }
コード例 #6
0
 public override void CaseAMultiLocalDecl(AMultiLocalDecl node)
 {
     InAMultiLocalDecl(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);
         }
     }
     if (node.GetType() != null)
     {
         node.GetType().Apply(this);
     }
     if (node.GetConst() != null)
     {
         node.GetConst().Apply(this);
     }
     OutAMultiLocalDecl(node);
 }
コード例 #7
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);
            }
        }
コード例 #8
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);
            }
        }