public override object Visit(IfStatement ifStatement, object data)
        {
            ProcessSpecials(ifStatement.Specials);

            CodeConditionStatement ifStmt = new CodeConditionStatement();

            ifStmt.Condition = (CodeExpression)ifStatement.Condition.AcceptVisitor(this, data);

            codeStack.Push(ifStmt.TrueStatements);
            ifStatement.EmbeddedStatement.AcceptChildren(this, data);
            codeStack.Pop();

            AddStmt(ifStmt);

            return ifStmt;
        }
        public override object Visit(IfStatement ifStatement, object data)
        {
            DebugOutput(ifStatement);
            AppendIndentation();
            InvocationExpression ie = GetEventHandlerRaise(ifStatement);

            if (ie == null) {
                sourceText.Append("If ");
                sourceText.Append(ifStatement.Condition.AcceptVisitor(this, data).ToString());
                sourceText.Append(" Then");
                AppendNewLine();

                ++indentLevel;
                ifStatement.EmbeddedStatement.AcceptVisitor(this, data);
                --indentLevel;

                AppendIndentation();sourceText.Append("End If");
                AppendNewLine();
            } else {
                sourceText.Append("RaiseEvent ");
                sourceText.Append(ie.AcceptVisitor(this, data));
                AppendNewLine();
            }
            return null;
        }
        InvocationExpression GetEventHandlerRaise(IfStatement ifStatement)
        {
            BinaryOperatorExpression op = ifStatement.Condition as BinaryOperatorExpression;
            if (op != null && op.Op == BinaryOperatorType.InEquality) {
                if (op.Left is IdentifierExpression && op.Right is PrimitiveExpression && ((PrimitiveExpression)op.Right).Value == null) {
                    string identifier = ((IdentifierExpression)op.Left).Identifier;
                    StatementExpression se = null;
                    if (ifStatement.EmbeddedStatement is StatementExpression) {
                        se = (StatementExpression)ifStatement.EmbeddedStatement;
                    } else if (ifStatement.EmbeddedStatement.Children.Count == 1) {
                        se = ifStatement.EmbeddedStatement.Children[0] as StatementExpression;
                    }
                    if (se != null) {
                        InvocationExpression ie = se.Expression as InvocationExpression;
                        if (ie != null) {
                            Expression ex = ie.TargetObject;
                            string methodName = null;
                            if (ex is IdentifierExpression) {
                                methodName = ((IdentifierExpression)ex).Identifier;
                            } else if (ex is FieldReferenceExpression) {
                                FieldReferenceExpression fre = (FieldReferenceExpression)ex;
                                if (fre.TargetObject is ThisReferenceExpression) {
                                    methodName = fre.FieldName;
                                }
                            }
                            if (methodName != null && methodName == identifier) {
                                foreach (object o in this.currentType.Children) {
                                    EventDeclaration ed = o as EventDeclaration;
                                    if (ed != null) {
                                        if (ed.Name == methodName) {
                                            return ie;
                                        }
                                        foreach (VariableDeclaration field in ed.VariableDeclarators) {
                                            if (field.Name == methodName) {
                                                return ie;
                                            }
                                        }

                                    }
                                }
                            }
                        }
                    }
                }
            }
            return null;
        }
 public override object Visit(IfStatement ifStatement, object data)
 {
     Console.WriteLine(ifStatement.ToString());
     return ifStatement.AcceptChildren(this, data);
 }
 public virtual object Visit(IfStatement ifStatement, object data)
 {
     object ret = data;
     if (ifStatement.Condition != null) {
         ret = ifStatement.Condition.AcceptVisitor(this, data);
     }
     if (ifStatement.EmbeddedStatement != null) {
         ret = ifStatement.EmbeddedStatement.AcceptVisitor(this, data);
     }
     return ret;
 }
 public override object Visit(IfStatement ifStatement, object data)
 {
     outputFormatter.Indent();
     outputFormatter.PrintToken(Tokens.If);
     outputFormatter.Space();
     outputFormatter.PrintToken(Tokens.OpenParenthesis);
     ifStatement.Condition.AcceptVisitor(this,data);
     outputFormatter.PrintToken(Tokens.CloseParenthesis);
     ifStatement.EmbeddedStatement.AcceptVisitor(this,data);
     return null;
 }