private static RuleCodeDomStatement GetStatement(CodeStatement statement)
 {
     Type type = statement.GetType();
     if (type == typeof(CodeExpressionStatement))
     {
         return ExpressionStatement.Create(statement);
     }
     if (type == typeof(CodeAssignStatement))
     {
         return AssignmentStatement.Create(statement);
     }
     NotSupportedException exception = new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Messages.CodeStatementNotHandled, new object[] { statement.GetType().FullName }));
     exception.Data["ErrorObject"] = statement;
     throw exception;
 }
 internal static bool Match(CodeStatement firstStatement, CodeStatement secondStatement)
 {
     if ((firstStatement == null) && (secondStatement == null))
     {
         return true;
     }
     if ((firstStatement == null) || (secondStatement == null))
     {
         return false;
     }
     if (firstStatement.GetType() != secondStatement.GetType())
     {
         return false;
     }
     return GetStatement(firstStatement).Match(secondStatement);
 }
Exemplo n.º 3
0
        void EmitStatement(CodeStatement Statement, bool ForceTypes)
        {
            if(Statement == null) return;

            Depth++;
            Debug("Emitting statement");
            if(Statement is CodeAssignStatement)
            {
                EmitAssignStatement(Statement as CodeAssignStatement, ForceTypes);
            }
            else if(Statement is CodeExpressionStatement)
            {
                EmitExpressionStatement(Statement as CodeExpressionStatement, ForceTypes);
            }
            else if(Statement is CodeIterationStatement)
            {
                EmitIterationStatement(Statement as CodeIterationStatement);
            }
            else if(Statement is CodeConditionStatement)
            {
                EmitConditionStatement(Statement as CodeConditionStatement);
            }
            else if(Statement is CodeGotoStatement)
            {
                EmitGotoStatement(Statement as CodeGotoStatement);
            }
            else if(Statement is CodeLabeledStatement)
            {
                EmitLabeledStatement(Statement as CodeLabeledStatement);
            }
            else if(Statement is CodeMethodReturnStatement)
            {
                EmitReturnStatement(Statement as CodeMethodReturnStatement);
            }
            else if(Statement is CodeVariableDeclarationStatement)
            {
                EmitVariableDeclarationStatement(Statement as CodeVariableDeclarationStatement);
            }
            else
            {
                Depth++;
                Debug("Unhandled statement: "+Statement.GetType());
                Depth--;
            }
            Depth--;
        }
Exemplo n.º 4
0
 private void EmitStatement(CodeStatement statement)
 {
     if (statement is CodeAssignStatement)
         EmitAssignment((CodeAssignStatement) statement);
     else if (statement is CodeExpressionStatement)
         EmitExpressionStatement(((CodeExpressionStatement) statement).Expression);
     else if (statement is CodeIterationStatement)
         EmitIteration((CodeIterationStatement) statement);
     else if (statement is CodeConditionStatement)
         EmitConditionStatement((CodeConditionStatement) statement);
     else if (statement is CodeGotoStatement)
         EmitGoto((CodeGotoStatement) statement);
     else if (statement is CodeLabeledStatement)
         EmitLabel((CodeLabeledStatement) statement);
     else if (statement is CodeMethodReturnStatement)
         EmitReturn((CodeMethodReturnStatement) statement);
     else if (statement is CodeVariableDeclarationStatement)
         EmitVariableDeclaration((CodeVariableDeclarationStatement) statement);
     else if (statement is CodeCommentStatement)
         EmitComment((CodeCommentStatement) statement);
     else
         throw new ArgumentException("Unrecognised statement: " + statement.GetType());
 }
        /// <devdoc>
        ///    <para>
        ///       Generates code for
        ///       the specified CodeDom based statement representation.
        ///    </para>
        /// </devdoc>
        private void GenerateStatement(CodeStatement e) {        
            if (e.StartDirectives.Count > 0) {
                GenerateDirectives(e.StartDirectives);
            }
        
            if (e.LinePragma != null) {
                GenerateLinePragmaStart(e.LinePragma);
            }

            if (e is CodeCommentStatement) {
                GenerateCommentStatement((CodeCommentStatement)e);
            }
            else if (e is CodeMethodReturnStatement) {
                GenerateMethodReturnStatement((CodeMethodReturnStatement)e);
            }
            else if (e is CodeConditionStatement) {
                GenerateConditionStatement((CodeConditionStatement)e);
            }
            else if (e is CodeTryCatchFinallyStatement) {
                GenerateTryCatchFinallyStatement((CodeTryCatchFinallyStatement)e);
            }
            else if (e is CodeAssignStatement) {
                GenerateAssignStatement((CodeAssignStatement)e);
            }
            else if (e is CodeExpressionStatement) {
                GenerateExpressionStatement((CodeExpressionStatement)e);
            }
            else if (e is CodeIterationStatement) {
                GenerateIterationStatement((CodeIterationStatement)e);
            }
            else if (e is CodeThrowExceptionStatement) {
                GenerateThrowExceptionStatement((CodeThrowExceptionStatement)e);
            }
            else if (e is CodeSnippetStatement) {
                // Don't indent snippet statements, in order to preserve the column
                // information from the original code.  This improves the debugging
                // experience.
                int savedIndent = Indent;
                Indent=0;

                GenerateSnippetStatement((CodeSnippetStatement)e);

                // Restore the indent
                Indent=savedIndent;
            }
            else if (e is CodeVariableDeclarationStatement) {
                GenerateVariableDeclarationStatement((CodeVariableDeclarationStatement)e);
            }
            else if (e is CodeAttachEventStatement) {
                GenerateAttachEventStatement((CodeAttachEventStatement)e);
            }
            else if (e is CodeRemoveEventStatement) {
                GenerateRemoveEventStatement((CodeRemoveEventStatement)e);
            }
            else if (e is CodeGotoStatement) {
                GenerateGotoStatement((CodeGotoStatement)e);
            }
            else if (e is CodeLabeledStatement) {
                GenerateLabeledStatement((CodeLabeledStatement)e);
            }
            else {
                throw new ArgumentException(SR.GetString(SR.InvalidElementType, e.GetType().FullName), "e");
            }

            if (e.LinePragma != null) {
                GenerateLinePragmaEnd(e.LinePragma);
            }
            if (e.EndDirectives.Count > 0) {
                GenerateDirectives(e.EndDirectives);
            }            
        }
Exemplo n.º 6
0
        private void ValidateStatement(CodeStatement e) {
            ValidateCodeDirectives(e.StartDirectives);
            ValidateCodeDirectives(e.EndDirectives);

            if (e is CodeCommentStatement) {
                ValidateCommentStatement((CodeCommentStatement)e);
            }
            else if (e is CodeMethodReturnStatement) {
                ValidateMethodReturnStatement((CodeMethodReturnStatement)e);
            }
            else if (e is CodeConditionStatement) {
                ValidateConditionStatement((CodeConditionStatement)e);
            }
            else if (e is CodeTryCatchFinallyStatement) {
                ValidateTryCatchFinallyStatement((CodeTryCatchFinallyStatement)e);
            }
            else if (e is CodeAssignStatement) {
                ValidateAssignStatement((CodeAssignStatement)e);
            }
            else if (e is CodeExpressionStatement) {
                ValidateExpressionStatement((CodeExpressionStatement)e);
            }
            else if (e is CodeIterationStatement) {
                ValidateIterationStatement((CodeIterationStatement)e);
            }
            else if (e is CodeThrowExceptionStatement) {
                ValidateThrowExceptionStatement((CodeThrowExceptionStatement)e);
            }
            else if (e is CodeSnippetStatement) {
                ValidateSnippetStatement((CodeSnippetStatement)e);
            }
            else if (e is CodeVariableDeclarationStatement) {
                ValidateVariableDeclarationStatement((CodeVariableDeclarationStatement)e);
            }
            else if (e is CodeAttachEventStatement) {
                ValidateAttachEventStatement((CodeAttachEventStatement)e);
            }
            else if (e is CodeRemoveEventStatement) {
                ValidateRemoveEventStatement((CodeRemoveEventStatement)e);
            }
            else if (e is CodeGotoStatement) {
                ValidateGotoStatement((CodeGotoStatement)e);
            }
            else if (e is CodeLabeledStatement) {
                ValidateLabeledStatement((CodeLabeledStatement)e);
            }
            else {
                throw new ArgumentException(SR.GetString(SR.InvalidElementType, e.GetType().FullName), "e");
            }
        }
		void AppendStatement(CodeStatement statement)
		{
			if (statement is CodeExpressionStatement) {
			 	AppendExpressionStatement((CodeExpressionStatement)statement);
			} else if (statement is CodeCommentStatement) {
				AppendCommentStatement((CodeCommentStatement)statement);
			} else if (statement is CodeAssignStatement) {
				AppendAssignStatement((CodeAssignStatement)statement);
			} else if (statement is CodeVariableDeclarationStatement) {
				AppendVariableDeclarationStatement((CodeVariableDeclarationStatement)statement);
			} else if (statement is CodeAttachEventStatement) {
				AppendAttachEventStatement((CodeAttachEventStatement)statement);
			} else {
				Console.WriteLine("AppendStatement: " + statement.GetType().Name);
			}
		}
Exemplo n.º 8
0
        internal static bool Match(CodeStatement firstStatement, CodeStatement secondStatement)
        {
            // If they're both null, they match.
            if (firstStatement == null && secondStatement == null)
                return true;

            // If only one of them is null, there's no match.
            if (firstStatement == null || secondStatement == null)
                return false;

            if (firstStatement.GetType() != secondStatement.GetType())
                return false;

            RuleCodeDomStatement ruleStmt = GetStatement(firstStatement);
            return ruleStmt.Match(secondStatement);
        }
Exemplo n.º 9
0
 private void RefactorMethodNamesInStatement(CodeStatement statement, string newName)
 {
     if (typeof(CodeVariableDeclarationStatement) == statement.GetType())
     {
         CodeVariableDeclarationStatement vdeclStatement = (CodeVariableDeclarationStatement)statement;
         if (vdeclStatement.InitExpression != null)
         {
             if (typeof(CodeCastExpression) == vdeclStatement.InitExpression.GetType())
             {
                 CodeCastExpression castExp = (CodeCastExpression)vdeclStatement.InitExpression;
                 if (typeof(CodeMethodInvokeExpression) == castExp.Expression.GetType())
                 {
                     CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)castExp.Expression;
                     miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
                 }
             }
             else if (typeof(CodeMethodInvokeExpression) == vdeclStatement.InitExpression.GetType())
             {
                 CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)vdeclStatement.InitExpression;
                 miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
             }
         }
     }
     else if (typeof(CodeExpressionStatement) == statement.GetType())
     {
         CodeExpressionStatement ceStatement = (CodeExpressionStatement)statement;
         if (typeof(CodeMethodInvokeExpression) == ceStatement.Expression.GetType())
         {
             CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)ceStatement.Expression;
             miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
         }
     }
     else if (typeof(CodeAssignStatement) == statement.GetType())
     {
         CodeAssignStatement asnStatement = (CodeAssignStatement)statement;
         if (typeof(CodeCastExpression) == asnStatement.Right.GetType())
         {
             CodeCastExpression castExp = (CodeCastExpression)asnStatement.Right;
             if (typeof(CodeMethodInvokeExpression) == castExp.Expression.GetType())
             {
                 CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)castExp.Expression;
                 miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
             }
         }
         else if (typeof(CodeMethodInvokeExpression) == asnStatement.Right.GetType())
         {
             CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)asnStatement.Right;
             miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
         }
     }
     else if (typeof(CodeMethodReturnStatement) == statement.GetType())
     {
         CodeMethodReturnStatement retStatement = (CodeMethodReturnStatement)statement;
         if (typeof(CodeMethodInvokeExpression) == retStatement.Expression.GetType())
         {
             CodeMethodInvokeExpression miExp = (CodeMethodInvokeExpression)retStatement.Expression;
             miExp.Method.MethodName = PascalCaseConverterHelper.GetPascalCaseMethodName(miExp.Method.MethodName);
         }
     }
 }
Exemplo n.º 10
0
		void VisitCodeStatement(CodeStatement statement)
		{
			WriteLine("VisitCodeStatement: " + statement.GetType().Name);
			CodeVariableDeclarationStatement codeVariableDeclarationStatement = statement as CodeVariableDeclarationStatement;
			CodeAssignStatement codeAssignStatement = statement as CodeAssignStatement;
			CodeConditionStatement codeConditionStatement = statement as CodeConditionStatement;
			CodeIterationStatement codeIterationStatement = statement as CodeIterationStatement;
			CodeExpressionStatement codeExpressionStatement = statement as CodeExpressionStatement;
			CodeTryCatchFinallyStatement codeTryCatchFinallyStatement = statement as CodeTryCatchFinallyStatement;
			if (codeVariableDeclarationStatement != null) {
				VisitCodeVariableDeclarationStatement(codeVariableDeclarationStatement);
			} else if (codeAssignStatement != null) {
				VisitCodeAssignStatement(codeAssignStatement);
			} else if (codeConditionStatement != null) {
				VisitCodeConditionStatement(codeConditionStatement);
			} else if (codeIterationStatement != null) {
				VisitCodeIterationStatement(codeIterationStatement);
			} else if (codeExpressionStatement != null) {
				VisitCodeExpressionStatement(codeExpressionStatement);
			} else if (codeTryCatchFinallyStatement != null) {
				VisitCodeTryCatchFinallyStatement(codeTryCatchFinallyStatement);
			} else {
				WriteLine("Unhandled statement: " + statement.GetType().Name);
			}
		}
Exemplo n.º 11
0
 private void GenerateStatement(CodeStatement e)
 {
     if (e.StartDirectives.Count > 0)
     {
         this.GenerateDirectives(e.StartDirectives);
     }
     if (e.LinePragma != null)
     {
         this.GenerateLinePragmaStart(e.LinePragma);
     }
     if (e is CodeCommentStatement)
     {
         this.GenerateCommentStatement((CodeCommentStatement) e);
     }
     else if (e is CodeMethodReturnStatement)
     {
         this.GenerateMethodReturnStatement((CodeMethodReturnStatement) e);
     }
     else if (e is CodeConditionStatement)
     {
         this.GenerateConditionStatement((CodeConditionStatement) e);
     }
     else if (e is CodeTryCatchFinallyStatement)
     {
         this.GenerateTryCatchFinallyStatement((CodeTryCatchFinallyStatement) e);
     }
     else if (e is CodeAssignStatement)
     {
         this.GenerateAssignStatement((CodeAssignStatement) e);
     }
     else if (e is CodeExpressionStatement)
     {
         this.GenerateExpressionStatement((CodeExpressionStatement) e);
     }
     else if (e is CodeIterationStatement)
     {
         this.GenerateIterationStatement((CodeIterationStatement) e);
     }
     else if (e is CodeThrowExceptionStatement)
     {
         this.GenerateThrowExceptionStatement((CodeThrowExceptionStatement) e);
     }
     else if (e is CodeSnippetStatement)
     {
         int num1 = this.Indent;
         this.Indent = 0;
         this.GenerateSnippetStatement((CodeSnippetStatement) e);
         this.Indent = num1;
     }
     else if (e is CodeVariableDeclarationStatement)
     {
         this.GenerateVariableDeclarationStatement((CodeVariableDeclarationStatement) e);
     }
     else if (e is CodeAttachEventStatement)
     {
         this.GenerateAttachEventStatement((CodeAttachEventStatement) e);
     }
     else if (e is CodeRemoveEventStatement)
     {
         this.GenerateRemoveEventStatement((CodeRemoveEventStatement) e);
     }
     else if (e is CodeGotoStatement)
     {
         this.GenerateGotoStatement((CodeGotoStatement) e);
     }
     else
     {
         if (!(e is CodeLabeledStatement))
         {
             throw new ArgumentException("InvalidElementType" + e, e.GetType().FullName );
         }
         this.GenerateLabeledStatement((CodeLabeledStatement) e);
     }
     if (e.LinePragma != null)
     {
         this.GenerateLinePragmaEnd(e.LinePragma);
     }
     if (e.EndDirectives.Count > 0)
     {
         this.GenerateDirectives(e.EndDirectives);
     }
 }
Exemplo n.º 12
0
        /// <include file='doc\CodeGenerator.uex' path='docs/doc[@for="CodeGenerator.GenerateStatement"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Generates code for
        ///       the specified CodeDom based statement representation.
        ///    </para>
        /// </devdoc>
        protected void GenerateStatement(CodeStatement e) {
            if (e.LinePragma != null) {
                GenerateLinePragmaStart(e.LinePragma);
            }

            if (e is CodeCommentStatement) {
                GenerateCommentStatement((CodeCommentStatement)e);
            }
            else if (e is CodeMethodReturnStatement) {
                GenerateMethodReturnStatement((CodeMethodReturnStatement)e);
            }
            else if (e is CodeConditionStatement) {
                GenerateConditionStatement((CodeConditionStatement)e);
            }
            else if (e is CodeTryCatchFinallyStatement) {
                GenerateTryCatchFinallyStatement((CodeTryCatchFinallyStatement)e);
            }
            else if (e is CodeAssignStatement) {
                GenerateAssignStatement((CodeAssignStatement)e);
            }
            else if (e is CodeExpressionStatement) {
                GenerateExpressionStatement((CodeExpressionStatement)e);
            }
            else if (e is CodeIterationStatement) {
                GenerateIterationStatement((CodeIterationStatement)e);
            }
            else if (e is CodeThrowExceptionStatement) {
                GenerateThrowExceptionStatement((CodeThrowExceptionStatement)e);
            }
            else if (e is CodeSnippetStatement) {
                GenerateSnippetStatement((CodeSnippetStatement)e);
            }
            else if (e is CodeVariableDeclarationStatement) {
                GenerateVariableDeclarationStatement((CodeVariableDeclarationStatement)e);
            }
            else if (e is CodeAttachEventStatement) {
                GenerateAttachEventStatement((CodeAttachEventStatement)e);
            }
            else if (e is CodeRemoveEventStatement) {
                GenerateRemoveEventStatement((CodeRemoveEventStatement)e);
            }
            else if (e is CodeGotoStatement) {
                GenerateGotoStatement((CodeGotoStatement)e);
            }
            else if (e is CodeLabeledStatement) {
                GenerateLabeledStatement((CodeLabeledStatement)e);
            }
            else {
                throw new ArgumentException(SR.GetString(SR.InvalidElementType, e.GetType().FullName), "e");
            }

            if (e.LinePragma != null) {
                GenerateLinePragmaEnd(e.LinePragma);
            }
        }
Exemplo n.º 13
0
 private Statement Translate(CodeStatement statement){
   if (statement == null) return null;
   if (statement is CodeAssignStatement) return this.Translate((CodeAssignStatement)statement);
   if (statement is CodeAttachEventStatement) return this.Translate((CodeAttachEventStatement)statement);
   if (statement is CodeCommentStatement) return this.Translate((CodeCommentStatement)statement);
   if (statement is CodeConditionStatement) return this.Translate((CodeConditionStatement)statement);
   if (statement is CodeExpressionStatement) return this.Translate((CodeExpressionStatement)statement);
   if (statement is CodeGotoStatement) return this.Translate((CodeGotoStatement)statement);
   if (statement is CodeIterationStatement) return this.Translate((CodeIterationStatement)statement);
   if (statement is CodeLabeledStatement) return this.Translate((CodeLabeledStatement)statement);
   if (statement is CodeMethodReturnStatement) return this.Translate((CodeMethodReturnStatement)statement);
   if (statement is CodeRemoveEventStatement) return this.Translate((CodeRemoveEventStatement)statement);
   if (statement is CodeSnippetStatement) return this.Translate((CodeSnippetStatement)statement);
   if (statement is CodeThrowExceptionStatement) return this.Translate((CodeThrowExceptionStatement)statement);
   if (statement is CodeTryCatchFinallyStatement) return this.Translate((CodeTryCatchFinallyStatement)statement);
   if (statement is CodeVariableDeclarationStatement) return this.Translate((CodeVariableDeclarationStatement)statement);
   throw new ArgumentException("unknown statement", statement.GetType().FullName);
 }
Exemplo n.º 14
0
        private CodeTypeReferenceCollection GetCodeTypeReferenceInCodeStatement(CodeStatement statement)
        {
            CodeTypeReferenceCollection references = new CodeTypeReferenceCollection();

            // Is this a variable declaration statement?
            if (typeof(CodeVariableDeclarationStatement) == statement.GetType())
            {
                // Add CodeTypeReference used to define the type of the variable to output.
                CodeVariableDeclarationStatement vdeclStatement = (CodeVariableDeclarationStatement)statement;
                references.Add(vdeclStatement.Type);

                // Do we have an initialization expression?
                if (vdeclStatement.InitExpression != null)
                {
                    // Add CodeTypeReference in the initialization statement if available.
                    CodeTypeReference r = GetCodeTypeReferenceInCodeExpression(vdeclStatement.InitExpression);
                    Debug.Assert(r != null, "Could not obtain a proper CodeTypeReference from the variable initialization expression.");
                    if (r == null)
                    {
                        Debugger.Break();
                    }
                    references.Add(r);
                }
            }
            //// Is this a return statement?
            //else if (typeof(CodeMethodReturnStatement) == statement.GetType())
            //{
            //    CodeMethodReturnStatement retStatement = (CodeMethodReturnStatement)statement;
            //    // Add CodeTypeReference in the return statement if available.
            //    CodeTypeReference r = GetCodeTypeReferenceInCodeExpression(retStatement.Expression);
            //    Debug.Assert(r != null, "Could not obtain a proper CodeTypeReference from the variable initialization expression.");
            //    references.Add(r);
            //}

            // Finally return the references.
            return references;
        }
Exemplo n.º 15
0
 private static void PrintStatement(TextWriter output, CodeStatement statement)
 {
     if (statement is CodeVariableDeclarationStatement)
     {
         PrintVariableDeclarationStatement(output, (CodeVariableDeclarationStatement)statement);
         return;
     }
     if (statement is CodeExpressionStatement)
     {
         PrintExpressionStatement(output, (CodeExpressionStatement)statement);
         return;
     }
     if (statement is CodeMethodReturnStatement)
     {
         PrintMethodReturnStatement(output, (CodeMethodReturnStatement)statement);
         return;
     }
     if (statement is CodeAssignStatement)
     {
         PrintAssignStatement(output, (CodeAssignStatement)statement);
         return;
     }
     if (statement is CodeThrowExceptionStatement)
     {
         PrintThrowExceptionStatement(output, (CodeThrowExceptionStatement)statement);
         return;
     }
     if (statement is CodeConditionStatement)
     {
         PrintConditionStatement(output, (CodeConditionStatement)statement);
         return;
     }
     if (statement is CodeCommentStatement)
     {
         PrintCommentStatement(output, (CodeCommentStatement)statement);
         return;
     }
     output.WriteLine("*** UNKNOWN STATEMENT: " + statement.GetType() + " ***");
 }
Exemplo n.º 16
0
        private static RuleCodeDomStatement GetStatement(CodeStatement statement)
        {
            Type statementType = statement.GetType();

            RuleCodeDomStatement wrapper = null;
            if (statementType == typeof(CodeExpressionStatement))
            {
                wrapper = ExpressionStatement.Create(statement);
            }
            else if (statementType == typeof(CodeAssignStatement))
            {
                wrapper = AssignmentStatement.Create(statement);
            }
            else
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.CodeStatementNotHandled, statement.GetType().FullName);
                NotSupportedException exception = new NotSupportedException(message);
                exception.Data[RuleUserDataKeys.ErrorObject] = statement;
                throw exception;
            }

            return wrapper;
        }
Exemplo n.º 17
0
		protected void GenerateStatement (CodeStatement s)
		{
			if (s.StartDirectives.Count > 0)
				GenerateDirectives (s.StartDirectives);
			if (s.LinePragma != null)
				GenerateLinePragmaStart (s.LinePragma);

			CodeSnippetStatement snippet = s as CodeSnippetStatement;
			if (snippet != null) {
				int indent = Indent;
				try {
					Indent = 0;
					GenerateSnippetStatement (snippet);
				} finally {
					Indent = indent;
				}
			} else {
				try {
					s.Accept (visitor);
				} catch (NotImplementedException) {
					throw new ArgumentException ("Element type " + s.GetType () + " is not supported.", "s");
				}
			}

			if (s.LinePragma != null)
				GenerateLinePragmaEnd (s.LinePragma);

			if (s.EndDirectives.Count > 0)
				GenerateDirectives (s.EndDirectives);
		}
Exemplo n.º 18
0
 public IStatement GetStatement(CodeStatement codeStatement, CodeGeneratorOptions codeGeneratorOptions)
 {
     return _statementMap[codeStatement.GetType()](codeStatement, codeGeneratorOptions);
 }