Esempio n. 1
0
        public override Statement CloneStatementOnly()
        {
            EmptyStatement result = new EmptyStatement();

            CopyParentAndLabel(result);
            return(result);
        }
        private ForStatement CreateForStatement(Statement initializer, WhileStatement theWhile)
        {
            int forStatementsCount = theWhile.Body.Statements.Count - 1;
            string incrementLabel = theWhile.Body.Statements[forStatementsCount].Label;
            ForStatement result = new ForStatement(
                (initializer as ExpressionStatement).Expression,
                theWhile.Condition,
                (theWhile.Body.Statements[forStatementsCount] as ExpressionStatement).Expression,
                new BlockStatement());

            for (int i = 0; i < forStatementsCount; i++)
            {
                result.Body.AddStatement(theWhile.Body.Statements[i]);
            }

            if (!string.IsNullOrEmpty(incrementLabel))
            {
                EmptyStatement emptyStatement = new EmptyStatement() { Label = incrementLabel };
                result.Body.AddStatement(emptyStatement);
            }

            return result;
        }
 public override Statement CloneStatementOnly()
 {
     V_0 = new EmptyStatement();
     this.CopyParentAndLabel(V_0);
     return(V_0);
 }
		private void TransferLabel(ExpressionStatement expressionStatement)
		{
			if (expressionStatement.Label == string.Empty)
			{
				return;
			}

			string theLabel = expressionStatement.Label;
			Statement currentStatement = expressionStatement;
			while (currentStatement.Parent != null)
			{
				BlockStatement parent = currentStatement.Parent as BlockStatement;
				int statementIndex = parent.Statements.IndexOf(currentStatement);
				if (statementIndex != parent.Statements.Count - 1)
				{
					Statement nextStatement = parent.Statements[statementIndex + 1];
					MoveLabel(nextStatement, theLabel);
					return;
				}
				else if (IsLoopBody(parent))
				{
					Statement firstStatement = parent.Statements[0];
					MoveLabel(firstStatement, theLabel);
					return;
				}

				do
				{
					currentStatement = currentStatement.Parent;
				}
				while (currentStatement.Parent != null && currentStatement.Parent.CodeNodeType != CodeNodeType.BlockStatement);
			}

			EmptyStatement emptyStatement = new EmptyStatement();
			this.theBody.Statements.Add(emptyStatement);

			MoveLabel(emptyStatement, theLabel);
		}
 public virtual void VisitEmptyStatement(EmptyStatement node)
 {
 }
        public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
        {
            node.Expression = (Expression)Visit(node.Expression);
            if (node.Expression == null)
            {
                if (node.Label != null && node.Label != string.Empty)
                {
                    Statement nextStatement = node.GetNextStatement();
                    if (nextStatement == null || nextStatement.Label != null && nextStatement.Label != string.Empty)
                    {
                        var result = new EmptyStatement() { Label = node.Label };
                        this.methodContext.GotoLabels[node.Label] = result;
                        return result;
                    }

                    nextStatement.Label = node.Label;
                    this.methodContext.GotoLabels[node.Label] = nextStatement;
                }
                return null;
            }

            return node;
        }
 public override Statement CloneStatementOnly()
 {
     EmptyStatement result = new EmptyStatement();
     CopyParentAndLabel(result);
     return result;
 }
        public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
        {
            Expression result = (Expression)Visit(node.Expression);
            if (result == null)
            {
                if (!string.IsNullOrEmpty(node.Label))
                {
                    Statement nextStatement = node.GetNextStatement();
                    if (nextStatement == null || !string.IsNullOrEmpty(nextStatement.Label))
                    {
                        Statement newStatement = new EmptyStatement();
                        newStatement.Label = node.Label;
                        return newStatement;
                    }

                    nextStatement.Label = node.Label;
                }
                return null;
            }

            node.Expression = result;
            return node;
        }