public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     if (node.GetExp() is ALvalueExp && Util.ReturnsTheSame(node.GetLvalue(), ((ALvalueExp)node.GetExp()).GetLvalue(), data))
     {
         RemovedOne = true;
         node.Parent().Parent().RemoveChild(node.Parent());
     }
     else
         base.CaseAAssignmentExp(node);
 }
 public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     currentLocal = null;
     node.GetLvalue().Apply(this);
     if (currentLocal != null)
     {
         AALocalDecl decl = data.LocalLinks[currentLocal];
         NeededRefs[Util.GetAncestor<AMethodDecl>(node)].Add(decl);
     }
     node.GetExp().Apply(this);
 }
 public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     if (!processMethodsOnly && !processStructs)
     {
         if (!processFieldsOnly)
             if (node.GetLvalue() is ALocalLvalue)
             {
                 ALocalLvalue lvalue = (ALocalLvalue)node.GetLvalue();
                 assignedToLocals[finalTrans.data.LocalLinks[lvalue]].Add(node);
                 node.GetExp().Apply(this);
                 return;
             }
         if (node.GetLvalue() is AFieldLvalue)
         {
             AFieldLvalue lvalue = (AFieldLvalue)node.GetLvalue();
             AFieldDecl decl = finalTrans.data.FieldLinks[lvalue];
             if (!assignedToFields[decl].Contains(node))
                 assignedToFields[decl].Add(node);
             node.GetExp().Apply(this);
             return;
         }
     }
     base.CaseAAssignmentExp(node);
 }
예제 #4
0
            public override void CaseAAssignmentExp(AAssignmentExp node)
            {
                if (node.GetExp() is ANullExp)
                {
                    PType type = data.LvalueTypes[node.GetLvalue()];
                    if (type is APointerType)
                    {
                        bool add = true;
                        foreach (PType pType in TypesWithIdentifierArray)
                        {
                            if (Util.TypesEqual(((APointerType)type).GetType(), pType, data))
                            {
                                add = false;
                                break;
                            }
                        }
                        if (add)
                            TypesWithIdentifierArray.Add(((APointerType) type).GetType());
                    }
                }

                base.CaseAAssignmentExp(node);
            }
예제 #5
0
 public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     InAAssignmentExp(node);
     if (node.GetExp() != null)
     {
         node.GetExp().Apply(this);
     }
     if (node.GetLvalue() != null)
     {
         node.GetLvalue().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAAssignmentExp(node);
 }
예제 #6
0
 public override void OutAAssignmentExp(AAssignmentExp node)
 {
     if (Util.GetAncestor<PStm>(node) == null)
     {
         errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile, LocRM.GetString("ErrorText186")));
         node.ReplaceBy(node.GetExp());
         return;
     }
     base.OutAAssignmentExp(node);
 }
        public override void OutAAssignmentExp(AAssignmentExp node)
        {
            PType from = data.ExpTypes[node.GetExp()];
            PType to = data.LvalueTypes[node.GetLvalue()];
            if (!Assignable(from, to))
            {
                if (ImplicitAssignable(from, to))
                {
                    ANamedType namedTo = (ANamedType) to;
                    ACastExp cast = new ACastExp(new TLParen("("), new ANamedType(new TIdentifier(((AAName)namedTo.GetName()).AsString()), null), node.GetExp());
                    node.SetExp(cast);
                    OutACastExp(cast);
                    //to = from;
                }
                else
                    errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile,
                                                         LocRM.GetString("ErrorText151") + Util.TypeToString(from) +
                                                         LocRM.GetString("ErrorText152") + Util.TypeToString(to)));
            }
            data.ExpTypes[node] = to;

            if (node.GetLvalue() is ALocalLvalue)
            {
                assignedToOutParams.Add(data.LocalLinks[(ALocalLvalue) node.GetLvalue()]);
            }

            if (node.GetLvalue() is AStructLvalue && data.StructFieldLinks.ContainsKey((AStructLvalue) node.GetLvalue()))
            {
                AALocalDecl decl = data.StructFieldLinks[(AStructLvalue) node.GetLvalue()];
                if (decl.GetConst() != null)
                    errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText153")));
            }

            if (node.GetLvalue() is AStructFieldLvalue && data.StructMethodFieldLinks.ContainsKey((AStructFieldLvalue)node.GetLvalue()))
            {
                AALocalDecl decl = data.StructMethodFieldLinks[(AStructFieldLvalue)node.GetLvalue()];
                if (decl.GetConst() != null)
                    errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText153")));
            }

            base.OutAAssignmentExp(node);
        }
 public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     node.GetLvalue().Apply(this);
     //node.GetToken().Apply(this);
     Write(" = ");
     node.GetExp().Apply(this);
 }
 public override void CaseAAssignmentExp(AAssignmentExp node)
 {
     isLeftAssign = true;
     node.GetLvalue().Apply(this);
     isLeftAssign = false;
     node.GetExp().Apply(this);
 }
 public override void OutAAssignmentExp(AAssignmentExp node)
 {
     if (Util.GetAncestor<PStm>(node) == null)
     {
         node.ReplaceBy(node.GetExp());
         return;
     }
     base.OutAAssignmentExp(node);
 }
예제 #11
0
 public override void OutAAssignmentExp(AAssignmentExp node)
 {
     PType type = data.ExpTypes[node];
     if (Util.IsBulkCopy(type))
     {
         node.Apply(mover);
         List<PStm> replacementStatements = MakeAssignments(node.GetLvalue(), node.GetExp(),
                                                            new List<AALocalDecl>() {null});
         PStm pStm = Util.GetAncestor<PStm>(node);
         AABlock pBlock = (AABlock) pStm.Parent();
         foreach (PStm stm in replacementStatements)
         {
             pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), stm);
         }
         pBlock.RemoveChild(pStm);
     }
     base.OutAAssignmentExp(node);
 }
예제 #12
0
            public override void CaseAAssignmentExp(AAssignmentExp node)
            {
                if (node.GetExp() is ANewExp)
                {
                    node.GetExp().Apply(this);
                }

                bool rightIsDynamic = false;
                PExp rightString = null;
                bool rightWasSet = assignmentRightSideSet;
                assignmentRightSideSet = false;
                if (rightWasSet)
                {
                    rightIsDynamic = hadPointer;
                    rightString = nameExp;
                }

                hadPointer = false;
                nameExp = null;
                node.GetLvalue().Apply(this);
                bool leftIsDynamic = hadPointer;
                PExp leftString = nameExp;

                if (!rightWasSet)
                {
                    hadPointer = false;
                    nameExp = null;
                    node.GetExp().Apply(this);
                    rightIsDynamic = hadPointer;
                    rightString = nameExp;
                }

                PType type = data.ExpTypes[node];
                if (node.GetExp() is ANullExp &&
                            type is APointerType &&
                            Util.IsIntPointer(node, ((APointerType)type).GetType(), data))
                {
                    AIntConstExp replacer = new AIntConstExp(new TIntegerLiteral("0"));
                    data.ExpTypes[replacer] = new ANamedType(new TIdentifier("int"), null);
                    node.GetExp().ReplaceBy(replacer);
                }
                /* Cases to handle
                 *
                 * left dynamic, right dynamic, type simple / left dynamic, right normal, type simple
                 * left dynamic, right dynamic, type bulk
                 * left dynamic, right simple, type bulk
                 * left simple, right dynamic, type bulk
                 *
                 *
                 */
                /*if (!Util.IsBulkCopy(type))
                {//left dynamic, right dynamic, type simple / left dynamic, right normal, type simple
                    if (leftIsDynamic)
                    {
                        string typeString = "string";
                        if (type is ANamedType)
                        {
                            typeString = ((ANamedType) type).GetName().Text;
                        }
                        PExp exp = CreateDynaicSetStm(typeString, leftString, node.GetExp());

                        node.ReplaceBy(exp);
                    }
                }
                else*/
                {
                    //throw new ParserException(null, "Not implemented");
                    if (type is ANamedType)
                    {

                    }
                    else if (type is AArrayTempType || type is ADynamicArrayType)
                    {

                    }
                    PStm pStm = Util.GetAncestor<PStm>(node);
                    AABlock pBlock = (AABlock) pStm.Parent();
                    int index = pBlock.GetStatements().IndexOf(pStm) + 1;
                    if (leftIsDynamic)
                    {

                        if (rightIsDynamic)
                        {//left dynamic, right dynamic, type bulk
                            MakeAssignmentBothDynamic(leftString, rightString, type, pBlock, ref index);
                            pStm.Parent().RemoveChild(pStm);
                        }
                        else
                        {//left dynamic, right simple, type bulk
                            MakeAssignmentLeftDynamic(leftString, node.GetExp(), type, pBlock, ref index);
                            pStm.Parent().RemoveChild(pStm);
                        }
                    }
                    else if (rightIsDynamic)
                    {//left simple, right dynamic, type bulk
                        MakeAssignmentRightDynamic(node.GetLvalue(), rightString, type, pBlock, ref index);
                        pStm.Parent().RemoveChild(pStm);
                    }
                }
            }
예제 #13
0
            public override void CaseAAssignmentExp(AAssignmentExp node)
            {
                /*if (!(data.ExpTypes[node] is APointerType))
                {
                    base.CaseAAssignmentExp(node);
                    return;
                }*/

                {
                    currentPointer.Clear();
                    node.GetLvalue().Apply(this);
                    List<PointerType> leftSide = MakePointer(currentPointer);

                    currentPointer.Clear();
                    node.GetExp().Apply(this);
                    //List<PointerType> rightSide = MakePointer(currentPointer);
                    if (leftSide.Count > 0)
                        foreach (List<PointerType> prefix in GetPrefixes(leftSide))
                        {
                            bool isRoot = prefix == leftSide;

                            if (isSet != Contains(setPointers, prefix))
                            {
                                if (isSet)
                                {
                                    if (isRoot)
                                        setPointers.Add(prefix);
                                }
                                else
                                    setPointers.Remove(prefix);
                            }

                            if (isExposed != Contains(exposedPointers, prefix))
                            {
                                if (isSet)
                                    setPointers.Add(prefix);
                                else if (isRoot)
                                    setPointers.Remove(prefix);
                            }
                        }

                }
            }