Cleanup SyntaxTree writer.
This Cl removes the boolean return values from most of the SyntaxTree writer methods. The diagnostics are used to determine if the generation was successful. The writer itself just continues until complete. Change-Id: I87d85e2cbe061306a4598a498ccad4510f62e8c9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124681 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
27c7722620
commit
541138b11b
|
@ -26,7 +26,8 @@ Result Generate(const Program* program, const Options&) {
|
||||||
|
|
||||||
// Generate the AST dump.
|
// Generate the AST dump.
|
||||||
auto impl = std::make_unique<GeneratorImpl>(program);
|
auto impl = std::make_unique<GeneratorImpl>(program);
|
||||||
result.success = impl->Generate();
|
impl->Generate();
|
||||||
|
result.success = impl->Diagnostics().empty();
|
||||||
result.error = impl->Diagnostics().str();
|
result.error = impl->Diagnostics().str();
|
||||||
result.ast = impl->result();
|
result.ast = impl->result();
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -49,165 +49,125 @@ class GeneratorImpl : public TextGenerator {
|
||||||
~GeneratorImpl();
|
~GeneratorImpl();
|
||||||
|
|
||||||
/// Generates the result data
|
/// Generates the result data
|
||||||
/// @returns true on successful generation; false otherwise
|
void Generate();
|
||||||
bool Generate();
|
|
||||||
|
|
||||||
/// Handles generating a diagnostic control
|
/// Handles generating a diagnostic control
|
||||||
/// @param diagnostic the diagnostic control node
|
/// @param diagnostic the diagnostic control node
|
||||||
/// @returns true if the diagnostic control was emitted
|
void EmitDiagnosticControl(const ast::DiagnosticControl& diagnostic);
|
||||||
bool EmitDiagnosticControl(const ast::DiagnosticControl& diagnostic);
|
|
||||||
/// Handles generating an enable directive
|
/// Handles generating an enable directive
|
||||||
/// @param enable the enable node
|
/// @param enable the enable node
|
||||||
/// @returns true if the enable directive was emitted
|
void EmitEnable(const ast::Enable* enable);
|
||||||
bool EmitEnable(const ast::Enable* enable);
|
|
||||||
/// Handles generating a declared type
|
/// Handles generating a declared type
|
||||||
/// @param ty the declared type to generate
|
/// @param ty the declared type to generate
|
||||||
/// @returns true if the declared type was emitted
|
void EmitTypeDecl(const ast::TypeDecl* ty);
|
||||||
bool EmitTypeDecl(const ast::TypeDecl* ty);
|
|
||||||
/// Handles an index accessor expression
|
/// Handles an index accessor expression
|
||||||
/// @param expr the expression to emit
|
/// @param expr the expression to emit
|
||||||
/// @returns true if the index accessor was emitted
|
void EmitIndexAccessor(const ast::IndexAccessorExpression* expr);
|
||||||
bool EmitIndexAccessor(const ast::IndexAccessorExpression* expr);
|
|
||||||
/// Handles an assignment statement
|
/// Handles an assignment statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitAssign(const ast::AssignmentStatement* stmt);
|
||||||
bool EmitAssign(const ast::AssignmentStatement* stmt);
|
|
||||||
/// Handles generating a binary expression
|
/// Handles generating a binary expression
|
||||||
/// @param expr the binary expression
|
/// @param expr the binary expression
|
||||||
/// @returns true if the expression was emitted, false otherwise
|
void EmitBinary(const ast::BinaryExpression* expr);
|
||||||
bool EmitBinary(const ast::BinaryExpression* expr);
|
|
||||||
/// Handles generating a binary operator
|
/// Handles generating a binary operator
|
||||||
/// @param op the binary operator
|
/// @param op the binary operator
|
||||||
/// @returns true if the operator was emitted, false otherwise
|
void EmitBinaryOp(const ast::BinaryOp op);
|
||||||
bool EmitBinaryOp(const ast::BinaryOp op);
|
|
||||||
/// Handles generating a bitcast expression
|
/// Handles generating a bitcast expression
|
||||||
/// @param expr the bitcast expression
|
/// @param expr the bitcast expression
|
||||||
/// @returns true if the bitcast was emitted
|
void EmitBitcast(const ast::BitcastExpression* expr);
|
||||||
bool EmitBitcast(const ast::BitcastExpression* expr);
|
|
||||||
/// Handles a block statement
|
/// Handles a block statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitBlock(const ast::BlockStatement* stmt);
|
||||||
bool EmitBlock(const ast::BlockStatement* stmt);
|
|
||||||
/// Handles emitting the start of a block statement (including attributes)
|
/// Handles emitting the start of a block statement (including attributes)
|
||||||
/// @param stmt the block statement to emit the header for
|
/// @param stmt the block statement to emit the header for
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitBlockHeader(const ast::BlockStatement* stmt);
|
||||||
bool EmitBlockHeader(const ast::BlockStatement* stmt);
|
|
||||||
/// Handles a break statement
|
/// Handles a break statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitBreak(const ast::BreakStatement* stmt);
|
||||||
bool EmitBreak(const ast::BreakStatement* stmt);
|
|
||||||
/// Handles a break-if statement
|
/// Handles a break-if statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitBreakIf(const ast::BreakIfStatement* stmt);
|
||||||
bool EmitBreakIf(const ast::BreakIfStatement* stmt);
|
|
||||||
/// Handles generating a call expression
|
/// Handles generating a call expression
|
||||||
/// @param expr the call expression
|
/// @param expr the call expression
|
||||||
/// @returns true if the call expression is emitted
|
void EmitCall(const ast::CallExpression* expr);
|
||||||
bool EmitCall(const ast::CallExpression* expr);
|
|
||||||
/// Handles a case statement
|
/// Handles a case statement
|
||||||
/// @param stmt the statement
|
/// @param stmt the statement
|
||||||
/// @returns true if the statment was emitted successfully
|
void EmitCase(const ast::CaseStatement* stmt);
|
||||||
bool EmitCase(const ast::CaseStatement* stmt);
|
|
||||||
/// Handles a compound assignment statement
|
/// Handles a compound assignment statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitCompoundAssign(const ast::CompoundAssignmentStatement* stmt);
|
||||||
bool EmitCompoundAssign(const ast::CompoundAssignmentStatement* stmt);
|
|
||||||
/// Handles generating a literal expression
|
/// Handles generating a literal expression
|
||||||
/// @param expr the literal expression expression
|
/// @param expr the literal expression expression
|
||||||
/// @returns true if the literal expression is emitted
|
void EmitLiteral(const ast::LiteralExpression* expr);
|
||||||
bool EmitLiteral(const ast::LiteralExpression* expr);
|
|
||||||
/// Handles a continue statement
|
/// Handles a continue statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted successfully
|
void EmitContinue(const ast::ContinueStatement* stmt);
|
||||||
bool EmitContinue(const ast::ContinueStatement* stmt);
|
|
||||||
/// Handles generate an Expression
|
/// Handles generate an Expression
|
||||||
/// @param expr the expression
|
/// @param expr the expression
|
||||||
/// @returns true if the expression was emitted
|
void EmitExpression(const ast::Expression* expr);
|
||||||
bool EmitExpression(const ast::Expression* expr);
|
|
||||||
/// Handles generating a function
|
/// Handles generating a function
|
||||||
/// @param func the function to generate
|
/// @param func the function to generate
|
||||||
/// @returns true if the function was emitted
|
void EmitFunction(const ast::Function* func);
|
||||||
bool EmitFunction(const ast::Function* func);
|
|
||||||
/// Handles generating an identifier expression
|
/// Handles generating an identifier expression
|
||||||
/// @param expr the identifier expression
|
/// @param expr the identifier expression
|
||||||
/// @returns true if the identifier was emitted
|
void EmitIdentifier(const ast::IdentifierExpression* expr);
|
||||||
bool EmitIdentifier(const ast::IdentifierExpression* expr);
|
|
||||||
/// Handles generating an identifier
|
/// Handles generating an identifier
|
||||||
/// @param ident the identifier
|
/// @param ident the identifier
|
||||||
/// @returns true if the identifier was emitted
|
void EmitIdentifier(const ast::Identifier* ident);
|
||||||
bool EmitIdentifier(const ast::Identifier* ident);
|
|
||||||
/// Handles an if statement
|
/// Handles an if statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was successfully emitted
|
void EmitIf(const ast::IfStatement* stmt);
|
||||||
bool EmitIf(const ast::IfStatement* stmt);
|
|
||||||
/// Handles an increment/decrement statement
|
/// Handles an increment/decrement statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was successfully emitted
|
void EmitIncrementDecrement(const ast::IncrementDecrementStatement* stmt);
|
||||||
bool EmitIncrementDecrement(const ast::IncrementDecrementStatement* stmt);
|
|
||||||
/// Handles generating a discard statement
|
/// Handles generating a discard statement
|
||||||
/// @param stmt the discard statement
|
/// @param stmt the discard statement
|
||||||
/// @returns true if the statement was successfully emitted
|
void EmitDiscard(const ast::DiscardStatement* stmt);
|
||||||
bool EmitDiscard(const ast::DiscardStatement* stmt);
|
|
||||||
/// Handles a loop statement
|
/// Handles a loop statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emtited
|
void EmitLoop(const ast::LoopStatement* stmt);
|
||||||
bool EmitLoop(const ast::LoopStatement* stmt);
|
|
||||||
/// Handles a for-loop statement
|
/// Handles a for-loop statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emtited
|
void EmitForLoop(const ast::ForLoopStatement* stmt);
|
||||||
bool EmitForLoop(const ast::ForLoopStatement* stmt);
|
|
||||||
/// Handles a while statement
|
/// Handles a while statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emtited
|
void EmitWhile(const ast::WhileStatement* stmt);
|
||||||
bool EmitWhile(const ast::WhileStatement* stmt);
|
|
||||||
/// Handles a member accessor expression
|
/// Handles a member accessor expression
|
||||||
/// @param expr the member accessor expression
|
/// @param expr the member accessor expression
|
||||||
/// @returns true if the member accessor was emitted
|
void EmitMemberAccessor(const ast::MemberAccessorExpression* expr);
|
||||||
bool EmitMemberAccessor(const ast::MemberAccessorExpression* expr);
|
|
||||||
/// Handles return statements
|
/// Handles return statements
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was successfully emitted
|
void EmitReturn(const ast::ReturnStatement* stmt);
|
||||||
bool EmitReturn(const ast::ReturnStatement* stmt);
|
|
||||||
/// Handles const assertion statements
|
/// Handles const assertion statements
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was successfully emitted
|
void EmitConstAssert(const ast::ConstAssert* stmt);
|
||||||
bool EmitConstAssert(const ast::ConstAssert* stmt);
|
|
||||||
/// Handles statement
|
/// Handles statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted
|
void EmitStatement(const ast::Statement* stmt);
|
||||||
bool EmitStatement(const ast::Statement* stmt);
|
|
||||||
/// Handles a statement list
|
/// Handles a statement list
|
||||||
/// @param stmts the statements to emit
|
/// @param stmts the statements to emit
|
||||||
/// @returns true if the statements were emitted
|
void EmitStatements(utils::VectorRef<const ast::Statement*> stmts);
|
||||||
bool EmitStatements(utils::VectorRef<const ast::Statement*> stmts);
|
|
||||||
/// Handles a statement list with an increased indentation
|
/// Handles a statement list with an increased indentation
|
||||||
/// @param stmts the statements to emit
|
/// @param stmts the statements to emit
|
||||||
/// @returns true if the statements were emitted
|
void EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts);
|
||||||
bool EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts);
|
|
||||||
/// Handles generating a switch statement
|
/// Handles generating a switch statement
|
||||||
/// @param stmt the statement to emit
|
/// @param stmt the statement to emit
|
||||||
/// @returns true if the statement was emitted
|
void EmitSwitch(const ast::SwitchStatement* stmt);
|
||||||
bool EmitSwitch(const ast::SwitchStatement* stmt);
|
|
||||||
/// Handles generating a struct declaration
|
/// Handles generating a struct declaration
|
||||||
/// @param str the struct
|
/// @param str the struct
|
||||||
/// @returns true if the struct is emitted
|
void EmitStructType(const ast::Struct* str);
|
||||||
bool EmitStructType(const ast::Struct* str);
|
|
||||||
/// Handles emitting an image format
|
/// Handles emitting an image format
|
||||||
/// @param fmt the format to generate
|
/// @param fmt the format to generate
|
||||||
/// @returns true if the format is emitted
|
void EmitImageFormat(const builtin::TexelFormat fmt);
|
||||||
bool EmitImageFormat(const builtin::TexelFormat fmt);
|
|
||||||
/// Handles a unary op expression
|
/// Handles a unary op expression
|
||||||
/// @param expr the expression to emit
|
/// @param expr the expression to emit
|
||||||
/// @returns true if the expression was emitted
|
void EmitUnaryOp(const ast::UnaryOpExpression* expr);
|
||||||
bool EmitUnaryOp(const ast::UnaryOpExpression* expr);
|
|
||||||
/// Handles generating a variable
|
/// Handles generating a variable
|
||||||
/// @param var the variable to generate
|
/// @param var the variable to generate
|
||||||
/// @returns true if the variable was emitted
|
void EmitVariable(const ast::Variable* var);
|
||||||
bool EmitVariable(const ast::Variable* var);
|
|
||||||
/// Handles generating a attribute list
|
/// Handles generating a attribute list
|
||||||
/// @param attrs the attribute list
|
/// @param attrs the attribute list
|
||||||
/// @returns true if the attributes were emitted
|
void EmitAttributes(utils::VectorRef<const ast::Attribute*> attrs);
|
||||||
bool EmitAttributes(utils::VectorRef<const ast::Attribute*> attrs);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::writer::syntax_tree
|
} // namespace tint::writer::syntax_tree
|
||||||
|
|
Loading…
Reference in New Issue