Commit Graph

10 Commits

Author SHA1 Message Date
Ben Clayton 90da745fbd Program: Fix IsValid() state on TypeDeterminer error
The error was added to diagnostics_, and then this list was replaced with diagnostics from the builder.
This resulted in the error silently being dropped.

Change-Id: Ifdda99bfb1582fa5d0fa691f7d39cfe3f17e60e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39901
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-02 15:06:05 +00:00
Ben Clayton 42d1e097e6 Have ProgramBuilder::Func() register the function
With the ast::Module::Functions().

Also remove pointless calls to td.Determine() that will automatically be
done when the program is built.

Change-Id: Ia7506e430b04d91d4f6b02fb6b678d0ea9912bcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39900
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-02 14:29:15 +00:00
Ben Clayton 844217fa34 Add Diagnostics to Program, reader::[wgsl,spirv]::Parse()
By putting diagnostics into the program, we can hold all the diagnostic messages for parsing and type determination in one place.
This also means that we can simplify the public WGSL and SPIR-V Parser interfaces to a single function.

Change-Id: Ib6ab5fa180addd45c4aaf0c6b192d47182ffb50a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-01-27 18:49:05 +00:00
Ben Clayton a6b9a8eb2f Split Program into Program and ProgramBuilder
Program is now immutable*, and remains part of the public Tint
interface.

ProgramBuilder is the mutable builder for Programs, and is not part of
the public Tint interface. ast::Builder has been folded into
ProgramBuilder.

Immutable Programs can be cloned into a mutable ProgramBuilder with
Program::CloneAsBuilder().

Mutable ProgramBuilders can be moved into immutable Programs.

* - mostly immutable. It still has a move constructor and move
  assignment operator - required for practical usage - and the
  semantic information on AST nodes is still mutable.

Bug: tint:390
Change-Id: Ia856c50b1880c2f95c91467a9eef5024cbc380c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38240
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 1f7e18bbc0 ast::Builder: Add shortcuts to the Program methods
This builder will be merged into ProgramBuilder, where these will become methods.
To breakup this change, perform the refactoring as a separate change.

Bug: tint:390
Change-Id: I2c9151cd9f198e99d88eaf296dd994293df6c425
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 8d391f7a10 ast::TypesBuilder: Change const fields to getters
This is required in order to support move operators for TypesBuilder.

Bug: tint:390
Change-Id: I9667bda5f5be267df092f5cd94dc40db053ae6e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38555
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 83158f214f Program: Remove deprecated function methods
Fixup all usages

Bug: tint:390
Change-Id: I949235908e50702d6c8b2e7e2299594879653e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38547
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton 1b3d6e460c Program: Remove deprecated constructed-type methods
Fixup all usages

Bug: tint:390
Change-Id: I739a7625cd385cb889369ab7c766462fbcd7cf12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38546
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton a86f4effe4 Program: Remove deprecated global variable methods
Fixup all usages

Bug: tint:390
Change-Id: I2e239dfc77872acb9f0b2ee5494350605dd780a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38545
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00
Ben Clayton c40f627bea Migrate from using ast::Module to Program
Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`.

As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object.

As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module.
These const_casts are temporary, and will be fixed in the next set of changes.

Depends on https://dawn-review.googlesource.com/c/dawn/+/38522

Bug: tint:390
Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-26 16:57:10 +00:00