[spirv-reader] Start emitting expression

Bug: tint:3
Change-Id: I2e2fe41c43abbcbbc941968c0115d703f6bff501
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18822
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-04-08 14:24:18 +00:00 committed by dan sinclair
parent ec322349e2
commit d877e8b084
2 changed files with 17 additions and 0 deletions

View File

@ -163,6 +163,18 @@ bool FunctionEmitter::EmitFunctionVariables() {
return success();
}
std::unique_ptr<ast::Expression> FunctionEmitter::MakeExpression(uint32_t id) {
if (failed()) {
return nullptr;
}
const auto* spirv_constant = constant_mgr_->FindDeclaredConstant(id);
if (spirv_constant) {
return parser_impl_.MakeConstantExpression(id);
}
Fail() << "unhandled expression for ID " << id;
return nullptr;
}
} // namespace spirv
} // namespace reader
} // namespace tint

View File

@ -66,6 +66,11 @@ class FunctionEmitter {
/// @returns false if emission failed.
bool EmitFunctionVariables();
/// Makes an expression
/// @param id the SPIR-V ID of the value
/// @returns true if emission has not yet failed.
std::unique_ptr<ast::Expression> MakeExpression(uint32_t id);
private:
/// @returns the store type for the OpVariable instruction, or
/// null on failure.