Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the UnsafeStatement class.
        /// </summary>
        /// <param name="proxy">Proxy object for the statement.</param>
        /// <param name="body">The body of the try-statement.</param>
        internal UnsafeStatement(CodeUnitProxy proxy, BlockStatement body)
            : base(proxy, StatementType.Unsafe)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.AssertNotNull(body, "body");

            this.body.Value = body;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the FinallyStatement class.
        /// </summary>
        /// <param name="proxy">Proxy object for the statement.</param>
        /// <param name="tryStatement">The try-statement that this finally-statement is embedded to.</param>
        /// <param name="body">The body of the finally-statement.</param>
        internal FinallyStatement(CodeUnitProxy proxy, TryStatement tryStatement, BlockStatement body)
            : base(proxy, StatementType.Finally)        
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.AssertNotNull(tryStatement, "tryStatement");
            Param.AssertNotNull(body, "body");

            this.tryStatement.Value = tryStatement;
            this.body.Value = body;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the CatchStatement class.
        /// </summary>
        /// <param name="proxy">Proxy object for the statement.</param>
        /// <param name="tryStatement">The try-statement that this catch-statement is attached to.</param>
        /// <param name="classExpression">The inner expression.</param>
        /// <param name="body">The body of the catch-statement.</param>
        internal CatchStatement(
            CodeUnitProxy proxy,
            TryStatement tryStatement,
            Expression classExpression,
            BlockStatement body)
            : base(proxy, StatementType.Catch)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.AssertNotNull(tryStatement, "tryStatement");
            Param.Ignore(classExpression);
            Param.AssertNotNull(body, "body");

            this.tryStatement.Value = tryStatement;
            this.catchExpression.Value = classExpression;
            this.body.Value = body;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the next block statement from the file and returns it.
        /// </summary>
        /// <param name="parentProxy">Represents the parent item.</param>
        /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param>
        /// <returns>Returns the statement.</returns>
        private BlockStatement GetBlockStatement(CodeUnitProxy parentProxy, bool unsafeCode)
        {
            Param.AssertNotNull(parentProxy, "parentProxy");
            Param.Ignore(unsafeCode);

            // Create the block statement.
            var statementProxy = new CodeUnitProxy(this.document);
            var block = new BlockStatement(statementProxy);

            // Get the opening bracket keyword.
            BracketToken openingBracket = (BracketToken)this.GetToken(statementProxy, TokenType.OpenCurlyBracket, SymbolType.OpenCurlyBracket);

            // Get the rest of the statement.
            BracketToken closingBracket = this.ParseStatementScope(statementProxy, unsafeCode);
            if (closingBracket == null)
            {
                // If we failed to get a closing bracket back, then there is a syntax
                // error in the document since there is an opening bracket with no matching
                // closing bracket.
                throw this.CreateSyntaxException();
            }

            openingBracket.MatchingBracket = closingBracket;
            closingBracket.MatchingBracket = openingBracket;

            parentProxy.Children.Add(block);

            return block;
        }