/// <summary> /// Reads the next throw-statement from the file and returns it. /// </summary> /// <param name="parentReference"> /// The parent code unit. /// </param> /// <param name="unsafeCode"> /// Indicates whether the code being parsed resides in an unsafe code block. /// </param> /// <returns> /// Returns the statement. /// </returns> private ThrowStatement ParseThrowStatement(Reference<ICodePart> parentReference, bool unsafeCode) { Param.AssertNotNull(parentReference, "parentReference"); Param.Ignore(unsafeCode); Reference<ICodePart> statementReference = new Reference<ICodePart>(); // Move past the throw keyword. CsToken firstToken = this.GetToken(CsTokenType.Throw, SymbolType.Throw, parentReference, statementReference); Node<CsToken> firstTokenNode = this.tokens.InsertLast(firstToken); // Check the type of the next symbol. Symbol symbol = this.GetNextSymbol(statementReference); Expression thrownExpression = null; if (symbol.SymbolType != SymbolType.Semicolon) { // Get the expression to throw. thrownExpression = this.GetNextExpression(ExpressionPrecedence.None, statementReference, unsafeCode); if (thrownExpression == null) { throw this.CreateSyntaxException(); } } this.tokens.Add(this.GetToken(CsTokenType.Semicolon, SymbolType.Semicolon, statementReference)); // Create the token list for the statement. CsTokenList partialTokens = new CsTokenList(this.tokens, firstTokenNode, firstTokenNode); // Create and return the statement. ThrowStatement statement = new ThrowStatement(partialTokens, thrownExpression); statementReference.Target = statement; return statement; }
/// <summary> /// The save. /// </summary> /// <param name="throwStatement"> /// The throw statement. /// </param> private void Save(ThrowStatement throwStatement) { this.cppWriter.Write("throw "); @switch(throwStatement.ThrownExpression); }