ast: Add Source argument to literals

Bug: tint:396
Bug: tint:390
Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-12 01:35:43 +00:00
committed by Commit Bot service account
parent 604bc72dd9
commit 5ed161b2d9
78 changed files with 1038 additions and 1005 deletions

View File

@@ -105,13 +105,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
} else if (val >= int32_t(size)) {
val = int32_t(size) - 1;
}
lit = ctx->mod->create<ast::SintLiteral>(ctx->Clone(sint->type()), val);
lit = ctx->mod->create<ast::SintLiteral>(ctx->Clone(sint->source()),
ctx->Clone(sint->type()), val);
} else if (auto* uint = lit->As<ast::UintLiteral>()) {
uint32_t val = uint->value();
if (val >= size - 1) {
val = size - 1;
}
lit = ctx->mod->create<ast::UintLiteral>(ctx->Clone(uint->type()), val);
lit = ctx->mod->create<ast::UintLiteral>(ctx->Clone(uint->source()),
ctx->Clone(uint->type()), val);
} else {
diag::Diagnostic err;
err.severity = diag::Severity::Error;
@@ -132,7 +134,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
params.push_back(
ctx->mod->create<ast::TypeConstructorExpression>(u32, cast_expr));
params.push_back(ctx->mod->create<ast::ScalarConstructorExpression>(
ctx->mod->create<ast::UintLiteral>(u32, size - 1)));
ctx->mod->create<ast::UintLiteral>(Source{}, u32, size - 1)));
auto* call_expr = ctx->mod->create<ast::CallExpression>(
ctx->mod->create<ast::IdentifierExpression>(

View File

@@ -66,7 +66,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
// Build the AST expression & statement for assigning pointsize one.
auto* one = mod->create<ast::ScalarConstructorExpression>(
mod->create<ast::FloatLiteral>(f32, 1.0f));
mod->create<ast::FloatLiteral>(Source{}, f32, 1.0f));
auto* pointsize_ident = mod->create<ast::IdentifierExpression>(
Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar);
auto* pointsize_assign =

View File

@@ -353,7 +353,7 @@ void VertexPulling::State::AddVertexPullingPreamble(
ast::Expression* VertexPulling::State::GenUint(uint32_t value) {
return mod->create<ast::ScalarConstructorExpression>(
mod->create<ast::UintLiteral>(GetU32Type(), value));
mod->create<ast::UintLiteral>(Source{}, GetU32Type(), value));
}
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() {