/// <summary> /// Reads the next unchecked-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 UncheckedStatement ParseUncheckedStatement(Reference<ICodePart> parentReference, bool unsafeCode) { Param.AssertNotNull(parentReference, "parentReference"); Param.Ignore(unsafeCode); Reference<ICodePart> statementReference = new Reference<ICodePart>(); // Move past the unchecked keyword. CsToken firstToken = this.GetToken(CsTokenType.Unchecked, SymbolType.Unchecked, parentReference, statementReference); Node<CsToken> firstTokenNode = this.tokens.InsertLast(firstToken); // Get the embedded statement. It must be a block statement. BlockStatement childStatement = this.GetNextStatement(statementReference, unsafeCode) as BlockStatement; if (childStatement == null) { throw this.CreateSyntaxException(); } // Create the token list for the statement. CsTokenList partialTokens = new CsTokenList(this.tokens, firstTokenNode, this.tokens.Last); // Create and return the unchecked-statement. UncheckedStatement statement = new UncheckedStatement(partialTokens, childStatement); statementReference.Target = statement; return statement; }
/// <summary> /// The save. /// </summary> /// <param name="uncheckedStatement"> /// The unchecked statement. /// </param> private void Save(UncheckedStatement uncheckedStatement) { this.cppWriter.WriteLine("/* unchecked */"); this.Save(uncheckedStatement.EmbeddedStatement); }