示例#1
0
        protected void VisitTryCatchStatement()
        {
            var visitor = new ReturnSearchVisitor();

            this.TryCatchStatement.AcceptVisitor(visitor);
            bool hasRet = visitor.Found;

            if (hasRet)
            {
                this.WriteReturn(true);
            }
            this.Write("System.try");
            this.WriteOpenParentheses();
            this.EmitTryBlock();

            var count = this.TryCatchStatement.CatchClauses.Count;

            if (count > 0)
            {
                this.EmitCatchBlock();
            }
            else
            {
                this.Write("nil, ");
            }

            this.EmitFinallyBlock();
        }
示例#2
0
        private void EmitUsing(AstNode expression, IEnumerable <AstNode> inner)
        {
            var visitor = new ReturnSearchVisitor();

            this.UsingStatement.EmbeddedStatement.AcceptVisitor(visitor);
            bool hasRet = visitor.Found;

            VariableInitializer variableInitializer = expression as VariableInitializer;

            if (variableInitializer != null)
            {
                if (hasRet)
                {
                    this.WriteReturn(true);
                }
                this.Write("System.using");
                this.WriteOpenParentheses();
                variableInitializer.Initializer.AcceptVisitor(this.Emitter);
                this.WriteComma();
                this.WriteFunction();
                this.WriteOpenParentheses();
                this.Write(variableInitializer.Name);
            }
            else
            {
                AssignmentExpression assignmentExpression = (AssignmentExpression)expression;
                assignmentExpression.AcceptVisitor(this.Emitter);
                this.WriteNewLine();
                if (hasRet)
                {
                    this.WriteReturn(true);
                }
                this.Write("System.using");
                this.WriteOpenParentheses();
                assignmentExpression.Left.AcceptVisitor(this.Emitter);
                this.WriteComma();
                this.WriteFunction();
                this.WriteOpenParentheses();
                assignmentExpression.Left.AcceptVisitor(this.Emitter);
            }

            this.WriteCloseParentheses();
            this.BeginFunctionBlock();
            this.UsingStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            this.EndFunctionBlock();
            this.WriteCloseParentheses();
            this.WriteNewLine();
        }