Beispiel #1
0
        public virtual bool VisitLabelStmt(LabelStmt stmt)
        {
            if (!VisitStmt(stmt))
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Visit LabelStmt, stores the label in dictionary and creates new basic block.
        /// </summary>
        /// <param name="x">LabelStmt</param>
        public override void VisitLabelStmt(LabelStmt x)
        {
            BasicBlock labelBlock = new BasicBlock();

            labelDictionary.GetOrCreateLabelData(x.Name, x.Position)
            .AsociateLabel(labelBlock, x.Position);

            BasicBlockEdge.ConnectDirectEdge(currentBasicBlock, labelBlock);
            currentBasicBlock = labelBlock;

            //Next line could be used for label visualization, label statement shouldnt be in resulting cgf
            //labelBlock.AddElement(x);
        }
Beispiel #3
0
        public override void VisitLabelStmt(LabelStmt x)
        {
            var /*!*/ label = GetLabelBlock(x.Name.Name.Value);

            if ((label.Flags & ControlFlowGraph.LabelBlockFlags.Defined) != 0)
            {
                label.Flags |= ControlFlowGraph.LabelBlockFlags.Redefined; // label was defined already
                return;                                                    // ignore label redefinition
            }

            label.Flags    |= ControlFlowGraph.LabelBlockFlags.Defined;     // label is defined
            label.LabelSpan = x.Span;

            _current = WithNewOrdinal(Connect(_current, label.TargetBlock));
        }
Beispiel #4
0
            internal override Statement Analyze(GotoStmt node, Analyzer analyzer)
            {
                //
                // TODO: analyze reachability, restrict jumps inside blocks, ...
                //
                // goto x;
                // // unreachable
                // x:
                //

                if (analyzer.IsThisCodeUnreachable())
                {
                    analyzer.ReportUnreachableCode(node.Span);
                    return(EmptyStmt.Unreachable);
                }

                Dictionary <VariableName, Statement> labels = analyzer.CurrentLabels;

                Statement stmt;

                if (labels.TryGetValue(node.LabelName, out stmt))
                {
                    LabelStmt label = stmt as LabelStmt;
                    if (label != null)
                    {
                        label.IsReferred = true;
                    }
                }
                else
                {
                    // add a stub (this node):
                    labels.Add(node.LabelName, node);
                }

                return(node);
            }
Beispiel #5
0
 public override void VisitLabelStmt(LabelStmt x)
 {
     ConsumeToken(Tokens.T_STRING, x.Name.Name.Value, x.Name.Span.Start);
     ConsumeToken(Tokens.T_COLON, ":", x.Span.End - 1);
 }
Beispiel #6
0
 public bool VisitLabelStmt(LabelStmt stmt)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 virtual public void VisitLabelStmt(LabelStmt x)
 {
     // x.Name
 }
Beispiel #8
0
 override public void VisitLabelStmt(LabelStmt x)
 {
     _serializer.Serialize(typeof(LabelStmt).Name, SerializeSpan(x.Span), new NodeObj("Name", x.Name.Name.Value));
 }