public override void OutAThisLvalue(AThisLvalue node)
        {
            AStructDecl currentStruct = Util.GetAncestor<AStructDecl>(node);
            AConstructorDecl constructor = Util.GetAncestor<AConstructorDecl>(node);
            ADeconstructorDecl deconstructor = Util.GetAncestor<ADeconstructorDecl>(node);
            AEnrichmentDecl enrichment = Util.GetAncestor<AEnrichmentDecl>(node);
            if (enrichment == null && (currentStruct == null || (currentStruct.GetClassToken() == null && constructor == null && deconstructor == null)))
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile, LocRM.GetString("ErrorText136")));
                throw new ParserException(node.GetToken(), "TypeChecking.OutAThisLvalue");
            }
            AMethodDecl method = Util.GetAncestor<AMethodDecl>(node);
            APropertyDecl property = Util.GetAncestor<APropertyDecl>(node);
            AALocalDecl field = Util.GetAncestor<AALocalDecl>(node);
            if (method != null && method.GetStatic() != null ||
                property != null && property.GetStatic() != null ||
                field != null && field.GetStatic() != null)
            {
                errors.Add(new ErrorCollection.Error(node.GetToken(), currentSourceFile, LocRM.GetString("ErrorText137")));
                throw new ParserException(node.GetToken(), "TypeChecking.OutAThisLvalue");
            }

            if (enrichment != null)
            {
                if (constructor == null && deconstructor == null)
                    data.LvalueTypes[node] = enrichment.GetType();
                else
                    data.LvalueTypes[node] = new APointerType(new TStar("*"), Util.MakeClone(enrichment.GetType(), data));
            }
            else
            {
                ANamedType namedType = new ANamedType(new TIdentifier(currentStruct.GetName().Text), null);
                data.StructTypeLinks[namedType] = currentStruct;
                data.LvalueTypes[node] = new APointerType(new TStar("*"), namedType);
            }
            base.OutAThisLvalue(node);
        }
 public override void CaseAThisLvalue(AThisLvalue node)
 {
     IsConst = false;
 }
Пример #3
0
 ArrayList New588()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TThis tthisNode4 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode3 = new AThisLvalue (
       tthisNode4
     );
     ALvalueExp pexpNode2 = new ALvalueExp (
       plvalueNode3
     );
     TArrow tarrowNode6 = (TArrow)nodeArrayList2[0];
     AArrowDotType pdottypeNode5 = new AArrowDotType (
       tarrowNode6
     );
     TIdentifier tidentifierNode7 = (TIdentifier)nodeArrayList3[0];
     AStructLvalue plvalueNode1 = new AStructLvalue (
       pexpNode2,
       pdottypeNode5,
       tidentifierNode7
     );
     nodeList.Add(plvalueNode1);
     return nodeList;
 }
        public static PLvalue Link(AAName name, Node refNode, List<Node> list, SharedData data)
        {
            List<TIdentifier> identifierList = new List<TIdentifier>();
            {
                int count = name.GetIdentifier().Count;
                if (count < list.Count)
                {
                    for (int i = 0; i < list.Count - count; i++)
                    {
                        if (list[i] is AStructDecl)
                            identifierList.Add(((AStructDecl)list[i]).GetName());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        TIdentifier iden = (TIdentifier)name.GetIdentifier()[i];
                        identifierList.Add(iden);
                    }
                }
                else
                    for (int i = count - list.Count; i < count; i++)
                    {
                        TIdentifier iden = (TIdentifier)name.GetIdentifier()[i];
                        identifierList.Add(iden);
                    }
            }
            PLvalue baseLvalue = null;
            Node node = list[0];
            list.RemoveAt(0);
            TIdentifier identifier = identifierList[0];
            identifierList.RemoveAt(0);
            if (node is AALocalDecl)
            {
                AALocalDecl aNode = (AALocalDecl)node;
                if (node.Parent() is AStructDecl)
                {//Struct local
                    //Make it this->var or this.var
                    AStructDecl pStruct = Util.GetAncestor<AStructDecl>(node);
                    if (pStruct.GetClassToken() != null || Util.HasAncestor<AConstructorDecl>(refNode) || Util.HasAncestor<ADeconstructorDecl>(refNode))
                    {//(*this).
                        baseLvalue = new AThisLvalue(new TThis("this"));
                        baseLvalue = new APointerLvalue(new TStar("*"), new ALvalueExp(baseLvalue));
                        baseLvalue = new AStructLvalue(new ALvalueExp(baseLvalue), new ADotDotType(new TDot(".")),
                                                       identifier);
                        data.StructFieldLinks[(AStructLvalue)baseLvalue] = aNode;
                    }
                    else
                    {//struct.
                        baseLvalue = new AStructFieldLvalue(identifier);
                        data.StructMethodFieldLinks[(AStructFieldLvalue)baseLvalue] = aNode;
                    }
                }
                else
                {//Method/constructor/deconstructor local
                    ALocalLvalue replaceNode = new ALocalLvalue(identifier);
                    data.LocalLinks[replaceNode] = aNode;
                    baseLvalue = replaceNode;
                }
            }
            else if (node is APropertyDecl)
            {
                APropertyDecl aNode = (APropertyDecl)node;
                if (Util.HasAncestor<AStructDecl>(node))
                {//Property in current struct
                    AStructDecl pStruct = Util.GetAncestor<AStructDecl>(node);
                    if (pStruct.GetClassToken() != null || Util.HasAncestor<AConstructorDecl>(refNode) || Util.HasAncestor<ADeconstructorDecl>(refNode))
                    {//(*this).
                        baseLvalue = new AThisLvalue(new TThis("this"));
                        baseLvalue = new APointerLvalue(new TStar("*"), new ALvalueExp(baseLvalue));
                        baseLvalue = new AStructLvalue(new ALvalueExp(baseLvalue), new ADotDotType(new TDot(".")),
                                                       identifier);
                        data.StructPropertyLinks[(AStructLvalue)baseLvalue] = aNode;
                    }
                    else
                    {//struct.
                        baseLvalue = new AStructFieldLvalue(identifier);
                        data.StructMethodPropertyLinks[(AStructFieldLvalue)baseLvalue] = aNode;
                    }
                }
                else
                {//Global property
                    baseLvalue = new APropertyLvalue(identifier);
                    data.PropertyLinks[(APropertyLvalue)baseLvalue] = aNode;
                }
            }
            else if (node is AFieldDecl)
            {
                baseLvalue = new AFieldLvalue(identifier);
                data.FieldLinks[(AFieldLvalue)baseLvalue] = (AFieldDecl)node;
            }
            else if (node is AStructDecl)
            {
                AStructDecl targetStruct = (AStructDecl)node;
                node = list[0];
                list.RemoveAt(0);
                identifier = identifierList[0];
                identifierList.RemoveAt(0);

                AStructFieldLvalue lvalue = new AStructFieldLvalue(identifier);
                if (node is AALocalDecl)
                    data.StructMethodFieldLinks[lvalue] = (AALocalDecl)node;
                else
                    data.StructMethodPropertyLinks[lvalue] = (APropertyDecl)node;

                baseLvalue = lvalue;
            }
            while (list.Count > 0)
            {
                node = list[0];
                list.RemoveAt(0);
                identifier = identifierList[0];
                identifierList.RemoveAt(0);

                baseLvalue = new AStructLvalue(new ALvalueExp(baseLvalue), new ADotDotType(new TDot(".")),
                                                identifier);
                if (node is AALocalDecl)
                {//Struct local
                    data.StructFieldLinks[(AStructLvalue) baseLvalue] = (AALocalDecl) node;
                }
                else if (node is APropertyDecl)
                {//Struct property
                    data.StructPropertyLinks[(AStructLvalue) baseLvalue] = (APropertyDecl) node;
                }
                //Don't link array length stuff
            }
            return baseLvalue;
        }
        public override void CaseAConstructorDecl(AConstructorDecl node)
        {
            AStructDecl str = Util.GetAncestor<AStructDecl>(node);
            AEnrichmentDecl enrichment = Util.GetAncestor<AEnrichmentDecl>(node);
            AMethodDecl replacer = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null, new AVoidType(new TVoid("void")),
                                                   node.GetName(), new ArrayList(), node.GetBlock());
            replacer.GetName().Text += "_Constructor";
            while (node.GetFormals().Count > 0)
            {
                replacer.GetFormals().Add(node.GetFormals()[0]);
            }

            //Move the method outside the struct
            AASourceFile file = Util.GetAncestor<AASourceFile>(node);
            if (str != null)
                str.RemoveChild(node.Parent());
            else
                enrichment.RemoveChild(node);
            int i = file.GetDecl().IndexOf(str ?? (PDecl)enrichment);
            file.GetDecl().Insert(i/* + 1*/, replacer);
            //Add the struct as a parameter
            PType type;
            if (str != null)
            {
                ANamedType structType = new ANamedType(new TIdentifier(str.GetName().Text), null);
                finalTrans.data.StructTypeLinks[structType] = str;
                type = structType;
            }
            else
            {
                type = Util.MakeClone(enrichment.GetType(), finalTrans.data);
            }
            finalTrans.data.ConstructorMap[node] = replacer;
            structFormal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new APointerType(new TStar("*"), type), new TIdentifier("currentStruct", replacer.GetName().Line, replacer.GetName().Pos), null);
            replacer.GetFormals().Add(structFormal);
            finalTrans.data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(file, replacer));

            //Add return stm
            replacer.SetReturnType(new APointerType(new TStar("*"), Util.MakeClone(type, data)));
            replacer.Apply(new TransformConstructorReturns(structFormal, data));

            //Insert call to base constructor););
            if (finalTrans.data.ConstructorBaseLinks.ContainsKey(node))
            {
                AMethodDecl baseConstructor = finalTrans.data.ConstructorMap[finalTrans.data.ConstructorBaseLinks[node]];
                ASimpleInvokeExp invoke = new ASimpleInvokeExp(new TIdentifier(baseConstructor.GetName().Text), new ArrayList());
                while (node.GetBaseArgs().Count > 0)
                {
                    invoke.GetArgs().Add(node.GetBaseArgs()[0]);
                }
                AThisLvalue thisLvalue1 = new AThisLvalue(new TThis("this"));
                ALvalueExp thisExp1 = new ALvalueExp(thisLvalue1);
                invoke.GetArgs().Add(thisExp1);

                AThisLvalue thisLvalue2 = new AThisLvalue(new TThis("this"));

                AAssignmentExp assignExp = new AAssignmentExp(new TAssign("="), thisLvalue2, invoke);

                ANamedType structType = new ANamedType(new TIdentifier(str.GetName().Text), null);
                finalTrans.data.StructTypeLinks[structType] = str;

                finalTrans.data.LvalueTypes[thisLvalue1] =
                    finalTrans.data.LvalueTypes[thisLvalue2] =
                    finalTrans.data.ExpTypes[thisExp1] =
                    finalTrans.data.ExpTypes[assignExp] =
                    finalTrans.data.ExpTypes[invoke] = new APointerType(new TStar("*"), structType);

                //finalTrans.data.ExpTypes[invoke] = new AVoidType(new TVoid("void"));
                finalTrans.data.SimpleMethodLinks[invoke] = baseConstructor;

                ((AABlock)replacer.GetBlock()).GetStatements().Insert(0, new AExpStm(new TSemicolon(";"), assignExp));

                //Inline if base and current are two different kinds of pointer types (int/string)
                AStructDecl baseStruct = null;
                AConstructorDecl baseC = finalTrans.data.ConstructorBaseLinks[node];
                foreach (KeyValuePair<AStructDecl, List<AConstructorDecl>> pair in finalTrans.data.StructConstructors)
                {
                    bool found = false;
                    foreach (AConstructorDecl decl in pair.Value)
                    {
                        if (baseC == decl)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        baseStruct = pair.Key;
                        break;
                    }
                }
                if ((str.GetIntDim() == null) != (baseStruct.GetIntDim() == null))
                {
                    //For the inilining, change the type to the type of the caller
                    AALocalDecl lastFormal = baseConstructor.GetFormals().OfType<AALocalDecl>().Last();
                    lastFormal.SetRef(new TRef("ref"));
                    APointerType oldType = (APointerType) lastFormal.GetType();

                    structType = new ANamedType(new TIdentifier(str.GetName().Text), null);
                    finalTrans.data.StructTypeLinks[structType] = str;

                    APointerType newType = new APointerType(new TStar("*"), structType);
                    lastFormal.SetType(newType);

                    foreach (
                        ALocalLvalue lvalue in
                            data.LocalLinks.Where(pair => pair.Value == lastFormal).Select(pair => pair.Key))
                    {
                        data.LvalueTypes[lvalue] = newType;
                        if (lvalue.Parent() is ALvalueExp)
                        {
                            data.ExpTypes[(PExp) lvalue.Parent()] = newType;
                            if (lvalue.Parent().Parent() is APointerLvalue)
                                data.LvalueTypes[(PLvalue) lvalue.Parent().Parent()] = newType.GetType();
                        }
                    }

                    FixInlineMethods.Inline(invoke, finalTrans);
                    lastFormal.SetRef(null);
                    foreach (
                        ALocalLvalue lvalue in
                            data.LocalLinks.Where(pair => pair.Value == lastFormal).Select(pair => pair.Key))
                    {
                        data.LvalueTypes[lvalue] = oldType;
                        if (lvalue.Parent() is ALvalueExp)
                        {
                            data.ExpTypes[(PExp) lvalue.Parent()] = oldType;
                            if (lvalue.Parent().Parent() is APointerLvalue)
                                data.LvalueTypes[(PLvalue) lvalue.Parent().Parent()] = oldType.GetType();
                        }
                    }

                    lastFormal.SetType(oldType);
                }

                //Inline it instead, Since the pointer implementations might not be the same (int vs string)

                /*AMethodDecl baseConstructor = finalTrans.data.ConstructorMap[finalTrans.data.ConstructorBaseLinks[node]];

                AABlock localsBlock = new AABlock(new ArrayList(), new TRBrace("}"));
                ABlockStm cloneBlock = new ABlockStm(new TLBrace("{"), (PBlock) baseConstructor.GetBlock().Clone());
                Dictionary<AALocalDecl, PLvalue> localMap = new Dictionary<AALocalDecl, PLvalue>();
                for (int argNr = 0; argNr < baseConstructor.GetFormals().Count; argNr++)
                {
                    AALocalDecl formal = (AALocalDecl) baseConstructor.GetFormals()[i];
                    PExp arg;
                    if (i < baseConstructor.GetFormals().Count - 1)
                        arg = (PExp)node.GetBaseArgs()[i];
                    else
                    {
                        AThisLvalue thisLvalue = new AThisLvalue(new TThis("this"));
                        ALvalueExp thisExp = new ALvalueExp(thisLvalue);

                        ANamedType structType = new ANamedType(new TIdentifier(str.GetName().Text), null);
                        finalTrans.data.StructTypeLinks[structType] = str;

                        finalTrans.data.LvalueTypes[thisLvalue] =
                            finalTrans.data.ExpTypes[thisExp] = new APointerType(new TStar("*"), structType);

                        arg = thisExp;
                    }

                    if (formal.GetRef() != null || formal.GetOut() != null)
                    {
                        //Use same variable
                        localMap[formal] = ((ALvalueExp) arg).GetLvalue();
                    }
                    else
                    {
                        //Make a new variable
                        AALocalDecl newLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                               Util.MakeClone(formal.GetType(), finalTrans.data),
                                                               new TIdentifier(formal.GetName().Text),
                                                               Util.MakeClone(arg, data));

                        ALocalLvalue newLocalRef = new ALocalLvalue(new TIdentifier(newLocal.GetName().Text));

                        localMap[formal] = newLocalRef;
                        data.LvalueTypes[newLocalRef] = newLocal.GetType();
                        data.LocalLinks[newLocalRef] = newLocal;

                        localsBlock.GetStatements().Add(new ALocalDeclStm(new TSemicolon(";"), newLocal));
                    }

                }

                CloneMethod cloner = new CloneMethod(finalTrans.data, localMap, cloneBlock);
                baseConstructor.GetBlock().Apply(cloner);

                ((AABlock)cloneBlock.GetBlock()).GetStatements().Insert(0, new ABlockStm(new TLBrace("{"), localsBlock));
                ((AABlock)node.GetBlock()).GetStatements().Insert(0, cloneBlock);*/
            }

            //Fix refferences to other struct stuff);
            base.CaseAMethodDecl(replacer);

            //Add functionality to refference the current struct in a constructor
            //Want to do it as a pointer type, since the constructer can only be called for pointer types
        }
Пример #6
0
 ArrayList New542()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList7 = (ArrayList) Pop();
     ArrayList nodeArrayList6 = (ArrayList) Pop();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode3 = new TypedList();
     TypedList listNode8 = new TypedList();
     TypedList listNode10 = new TypedList();
     TypedList listNode12 = new TypedList();
     TConst tconstNode2 = (TConst)nodeArrayList1[0];
     TThis tthisNode5 = (TThis)nodeArrayList2[0];
     AThisLvalue plvalueNode4 = new AThisLvalue (
       tthisNode5
     );
     TLt tltNode6 = (TLt)nodeArrayList3[0];
     TypedList listNode7 = (TypedList)nodeArrayList4[0];
     if ( listNode7 != null )
     {
     listNode8.AddAll(listNode7);
     }
     TypedList listNode9 = (TypedList)nodeArrayList6[0];
     if ( listNode9 != null )
     {
     listNode10.AddAll(listNode9);
     }
     TypedList listNode11 = (TypedList)nodeArrayList7[0];
     if ( listNode11 != null )
     {
     listNode12.AddAll(listNode11);
     }
     AShadySAssignmentExp pexpNode1 = new AShadySAssignmentExp (
       tconstNode2,
       listNode3,
       plvalueNode4,
       tltNode6,
       listNode8,
       listNode10,
       listNode12
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #7
0
 ArrayList New476()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TThis tthisNode3 = (TThis)nodeArrayList2[0];
     AThisLvalue plvalueNode2 = new AThisLvalue (
       tthisNode3
     );
     TMinusMinus tminusminusNode5 = (TMinusMinus)nodeArrayList1[0];
     APreDecIncDecOp pincdecopNode4 = new APreDecIncDecOp (
       tminusminusNode5
     );
     AIncDecExp pexpNode1 = new AIncDecExp (
       plvalueNode2,
       pincdecopNode4
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #8
0
 public virtual void InAThisLvalue(AThisLvalue node)
 {
     DefaultIn(node);
 }
Пример #9
0
 ArrayList New427()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TThis tthisNode3 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode2 = new AThisLvalue (
       tthisNode3
     );
     ALvalueExp pexpNode1 = new ALvalueExp (
       plvalueNode2
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #10
0
 ArrayList New439()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TThis tthisNode3 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode2 = new AThisLvalue (
       tthisNode3
     );
     TPlusPlus tplusplusNode5 = (TPlusPlus)nodeArrayList2[0];
     APostIncIncDecOp pincdecopNode4 = new APostIncIncDecOp (
       tplusplusNode5
     );
     AIncDecExp pexpNode1 = new AIncDecExp (
       plvalueNode2,
       pincdecopNode4
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #11
0
 ArrayList New391()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList6 = (ArrayList) Pop();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode9 = new TypedList();
     TThis tthisNode4 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode3 = new AThisLvalue (
       tthisNode4
     );
     ALvalueExp pexpNode2 = new ALvalueExp (
       plvalueNode3
     );
     TArrow tarrowNode6 = (TArrow)nodeArrayList2[0];
     AArrowDotType pdottypeNode5 = new AArrowDotType (
       tarrowNode6
     );
     TIdentifier tidentifierNode7 = (TIdentifier)nodeArrayList3[0];
     TypedList listNode8 = (TypedList)nodeArrayList5[0];
     if ( listNode8 != null )
     {
     listNode9.AddAll(listNode8);
     }
     ANonstaticInvokeExp pexpNode1 = new ANonstaticInvokeExp (
       pexpNode2,
       pdottypeNode5,
       tidentifierNode7,
       listNode9
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #12
0
 ArrayList New341()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TLBracket tlbracketNode2 = (TLBracket)nodeArrayList2[0];
     TThis tthisNode5 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode4 = new AThisLvalue (
       tthisNode5
     );
     ALvalueExp pexpNode3 = new ALvalueExp (
       plvalueNode4
     );
     PExp pexpNode6 = (PExp)nodeArrayList3[0];
     AArrayLvalue plvalueNode1 = new AArrayLvalue (
       tlbracketNode2,
       pexpNode3,
       pexpNode6
     );
     nodeList.Add(plvalueNode1);
     return nodeList;
 }
 public override void CaseAThisLvalue(AThisLvalue node)
 {
     //Replace with <structFormal>
     ALocalLvalue parameterRefference = new ALocalLvalue(new TIdentifier("tempName"));
     finalTrans.data.LocalLinks[parameterRefference] = structFormal;
     finalTrans.data.LvalueTypes[parameterRefference] = structFormal.GetType();
     node.ReplaceBy(parameterRefference);
     base.CaseAThisLvalue(node);
 }
Пример #14
0
 public virtual void CaseAThisLvalue(AThisLvalue node)
 {
     DefaultCase(node);
 }
Пример #15
0
 ArrayList New515()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TAssign tassignNode2 = (TAssign)nodeArrayList2[0];
     TThis tthisNode4 = (TThis)nodeArrayList1[0];
     AThisLvalue plvalueNode3 = new AThisLvalue (
       tthisNode4
     );
     PExp pexpNode5 = (PExp)nodeArrayList3[0];
     AAssignmentExp pexpNode1 = new AAssignmentExp (
       tassignNode2,
       plvalueNode3,
       pexpNode5
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #16
0
 public override void CaseAThisLvalue(AThisLvalue node)
 {
     InAThisLvalue(node);
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutAThisLvalue(node);
 }
Пример #17
0
 ArrayList New541()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode3 = new TypedList();
     TypedList listNode7 = new TypedList();
     TypedList listNode9 = new TypedList();
     TypedList listNode11 = new TypedList();
     TConst tconstNode2 = (TConst)nodeArrayList1[0];
     TThis tthisNode5 = (TThis)nodeArrayList2[0];
     AThisLvalue plvalueNode4 = new AThisLvalue (
       tthisNode5
     );
     TypedList listNode8 = (TypedList)nodeArrayList3[0];
     if ( listNode8 != null )
     {
     listNode9.AddAll(listNode8);
     }
     TypedList listNode10 = (TypedList)nodeArrayList4[0];
     if ( listNode10 != null )
     {
     listNode11.AddAll(listNode10);
     }
     AShadySAssignmentExp pexpNode1 = new AShadySAssignmentExp (
       tconstNode2,
       listNode3,
       plvalueNode4,
       null,
       listNode7,
       listNode9,
       listNode11
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #18
0
 public virtual void OutAThisLvalue(AThisLvalue node)
 {
     DefaultOut(node);
 }
        public override void OutAStructDecl(AStructDecl node)
        {
            //Insert init in each constructor
            AThisLvalue thisLvalue = new AThisLvalue(new TThis("this"));
            ALvalueExp thisExp = new ALvalueExp(thisLvalue);
            APointerLvalue pointerLvalue = new APointerLvalue(new TStar("*"), thisExp);

            ANamedType namedType = new ANamedType(new TIdentifier(node.GetName().Text), null);
            data.StructTypeLinks[namedType] = node;
            data.LvalueTypes[thisLvalue] =
                data.ExpTypes[thisExp] = new APointerType(new TStar("*"), namedType);
            data.LvalueTypes[pointerLvalue] = namedType;

            foreach (AConstructorDecl constructor in node.GetLocals().OfType<ADeclLocalDecl>().Select(decl => decl.GetDecl()).OfType<AConstructorDecl>())
            {
                AABlock block = new AABlock(new ArrayList(), new TRBrace("}"));
                MakeAssignments(block, namedType, pointerLvalue, false);

                ((AABlock)constructor.GetBlock()).GetStatements().Insert(0, new ABlockStm(new TLBrace("{"), block));
            }

            base.OutAStructDecl(node);
        }