public VariableDescription(ATriggerDecl triggerDecl)
 {
     Name = triggerDecl.GetName().Text;
     Type = "trigger";
     PlacementPrefix = "Field";
     VariableType = VariableTypes.Field;
     Const = false;
     IsStatic = false;
     realType = new ANamedType(new TIdentifier("trigger"), null);
     Visibility = (PVisibilityModifier)triggerDecl.GetVisibilityModifier().Clone();
     Line = triggerDecl.GetName().Line;
     Position = TextPoint.FromCompilerCoords(triggerDecl.GetActionsToken());
 }
Пример #2
0
 public virtual void OutATriggerDecl(ATriggerDecl node)
 {
     DefaultOut(node);
 }
Пример #3
0
 public virtual void InATriggerDecl(ATriggerDecl node)
 {
     DefaultIn(node);
 }
Пример #4
0
 public override void CaseATriggerDecl(ATriggerDecl node)
 {
     InATriggerDecl(node);
     if (node.GetActions() != null)
     {
         node.GetActions().Apply(this);
     }
     if (node.GetActionsToken() != null)
     {
         node.GetActionsToken().Apply(this);
     }
     if (node.GetConditions() != null)
     {
         node.GetConditions().Apply(this);
     }
     if (node.GetConditionsToken() != null)
     {
         node.GetConditionsToken().Apply(this);
     }
     if (node.GetEvents() != null)
     {
         node.GetEvents().Apply(this);
     }
     if (node.GetEventToken() != null)
     {
         node.GetEventToken().Apply(this);
     }
     if (node.GetName() != null)
     {
         node.GetName().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutATriggerDecl(node);
 }
Пример #5
0
 public virtual void CaseATriggerDecl(ATriggerDecl node)
 {
     DefaultCase(node);
 }
Пример #6
0
        /* public override void CaseAArrayTempType(AArrayTempType node)
        {
            //Replace by an AArrayType
            //Have to wait untill after constant folding
            /*
            if (!(node.GetDimention() is AIntConstExp))
            {
                base.CaseAArrayTempType(node);
                return;
            }
            AIntConstExp dim = (AIntConstExp)node.GetDimention();
            AArrayType newType = new AArrayType(node.GetToken(), dim.GetIntegerLiteral(), node.GetType());
            node.ReplaceBy(newType);
            newType.Apply(this);
        }*/
        public override void OutATriggerDecl(ATriggerDecl node)
        {
            //If no actions, insert it
            if (node.GetActions() == null)
            {
                node.SetActions(new AABlock(new ArrayList(), new TRBrace("}")));
                node.SetActionsToken(new TActions("actions"));
            }

            //If return in events is missing, insert it.
            if (node.GetEvents() != null)
            {
                AABlock block = (AABlock)node.GetEvents();
                bool insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                        break;
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }
            //Also for actions
            {
                AABlock block = (AABlock)node.GetActions();
                bool insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                        break;
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }

            if (node.GetVisibilityModifier() is AProtectedVisibilityModifier)
                errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText192")));
        }
 public override void OutATriggerDecl(ATriggerDecl node)
 {
     data.Triggers.Add(node);
 }
Пример #8
0
 ArrayList New83()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList8 = (ArrayList) Pop();
     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();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TIdentifier tidentifierNode3 = (TIdentifier)nodeArrayList3[0];
     TEvents teventsNode4 = (TEvents)nodeArrayList5[0];
     PBlock pblockNode5 = (PBlock)nodeArrayList5[1];
     TConditions tconditionsNode6 = (TConditions)nodeArrayList6[0];
     PBlock pblockNode7 = (PBlock)nodeArrayList6[1];
     TActions tactionsNode8 = (TActions)nodeArrayList7[0];
     PBlock pblockNode9 = (PBlock)nodeArrayList7[1];
     ATriggerDecl pdeclNode1 = new ATriggerDecl (
       pvisibilitymodifierNode2,
       tidentifierNode3,
       teventsNode4,
       pblockNode5,
       tconditionsNode6,
       pblockNode7,
       tactionsNode8,
       pblockNode9
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
Пример #9
0
 ArrayList New80()
 {
     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();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TIdentifier tidentifierNode3 = (TIdentifier)nodeArrayList3[0];
     TActions tactionsNode8 = (TActions)nodeArrayList5[0];
     PBlock pblockNode9 = (PBlock)nodeArrayList5[1];
     ATriggerDecl pdeclNode1 = new ATriggerDecl (
       pvisibilitymodifierNode2,
       tidentifierNode3,
       null,
       null,
       null,
       null,
       tactionsNode8,
       pblockNode9
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
Пример #10
0
 ArrayList New77()
 {
     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();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TIdentifier tidentifierNode3 = (TIdentifier)nodeArrayList3[0];
     TEvents teventsNode4 = (TEvents)nodeArrayList5[0];
     PBlock pblockNode5 = (PBlock)nodeArrayList5[1];
     ATriggerDecl pdeclNode1 = new ATriggerDecl (
       pvisibilitymodifierNode2,
       tidentifierNode3,
       teventsNode4,
       pblockNode5,
       null,
       null,
       null,
       null
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
Пример #11
0
 ArrayList New76()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TIdentifier tidentifierNode3 = (TIdentifier)nodeArrayList3[0];
     ATriggerDecl pdeclNode1 = new ATriggerDecl (
       pvisibilitymodifierNode2,
       tidentifierNode3,
       null,
       null,
       null,
       null,
       null,
       null
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
        public override void OutATriggerDecl(ATriggerDecl node)
        {
            //If no actions, insert it
            if (node.GetActions() == null)
            {
                node.SetActions(new AABlock(new ArrayList(), new TRBrace("}", -1, -1)));
                node.SetActionsToken(new TActions("actions", -1, -1));
            }

            //If return in events is missing, insert it.
            if (node.GetEvents() != null)
            {
                AABlock block = (AABlock)node.GetEvents();
                bool insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                        break;
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }
            //Also for actions
            //if (node.GetActions() != null)
            {
                AABlock block = (AABlock)node.GetActions();
                bool insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                        break;
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }
        }
 /*public override void OutAIncludeDecl(AIncludeDecl node)
 {
     string name = Util.GetString(node.GetName());
     SourceFileContents sourceFile = compiler.LookupFile(name);
     if (sourceFile != null)
     {
         Includes.Add(sourceFile);
     }
 }*/
 public override void OutATriggerDecl(ATriggerDecl node)
 {
     //Add field
     Fields.Add(new VariableDescription(node));
     //Add event method
     //The methods don't start from node.GetName(), make the parser add the events, conditions and action tokens
     if (node.GetEvents() != null)
     {
         Methods.Add(
             new MethodDescription(TextPoint.FromCompilerCoords(node.GetEventToken().Line, node.GetEventToken().Pos),
                                   new AVoidType(new TVoid("void")), (AABlock) node.GetEvents(), null));
     }
     if (node.GetConditions() != null)
     {
         Methods.Add(
             new MethodDescription(TextPoint.FromCompilerCoords(node.GetConditionsToken().Line, node.GetConditionsToken().Pos),
                                   new AVoidType(new TVoid("void")), (AABlock)node.GetConditions(), null));
     }
     //Actions. this one can be called
     {
         AMethodDecl method = new AMethodDecl((PVisibilityModifier) node.GetVisibilityModifier().Clone(), null, null, null, null, null,
                                              new ANamedType(new TIdentifier("bool"), null),
                                              new TIdentifier(node.GetName().Text, node.GetActionsToken().Line, node.GetActionsToken().Pos),
                                              new ArrayList()
                                                  {
                                                      new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                                      new ANamedType(
                                                                          new TIdentifier("bool"), null),
                                                                      new TIdentifier("testConds"), null),
                                                      new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                                      new ANamedType(
                                                                          new TIdentifier("bool"), null),
                                                                      new TIdentifier("runActions"), null)
                                                  },
                                              node.GetActions());
         Methods.Add(new MethodDescription(method));
     }
 }