ast: Remove TypeConstructorExpression

Add a new 'Target' to the ast::CallExpression, which can be either an
Identifier or Type. The Identifier may resolve to a Type, if the Type is
a structure or alias.

The Resolver now resolves the CallExpression target to one of the
following sem::CallTargets:
* sem::Function
* sem::Intrinsic
* sem::TypeConstructor
* sem::TypeCast

This change will allow us to remove the type tracking logic from the WGSL
parser, which is required for out-of-order module scope declarations.

Bug: tint:888
Bug: tint:1266
Change-Id: I696f117115a50981fd5c102a0d7764641bb755dd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68525
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2021-11-15 20:45:50 +00:00
parent d12f48828b
commit 735dca8393
48 changed files with 2275 additions and 1446 deletions

View File

@@ -12,17 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/sem/type_cast.h"
#include "src/sem/type_conversion.h"
TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeCast);
TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeConversion);
namespace tint {
namespace sem {
TypeCast::TypeCast(const sem::Type* type, const sem::Parameter* parameter)
TypeConversion::TypeConversion(const sem::Type* type,
const sem::Parameter* parameter)
: Base(type, ParameterList{parameter}) {}
TypeCast::~TypeCast() = default;
TypeConversion::~TypeConversion() = default;
} // namespace sem
} // namespace tint

View File

@@ -12,24 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_SEM_TYPE_CAST_H_
#define SRC_SEM_TYPE_CAST_H_
#ifndef SRC_SEM_TYPE_CONVERSION_H_
#define SRC_SEM_TYPE_CONVERSION_H_
#include "src/sem/call_target.h"
namespace tint {
namespace sem {
/// TypeCast is the CallTarget for a type cast.
class TypeCast : public Castable<TypeCast, CallTarget> {
/// TypeConversion is the CallTarget for a type conversion (cast).
class TypeConversion : public Castable<TypeConversion, CallTarget> {
public:
/// Constructor
/// @param type the target type of the cast
/// @param parameter the type cast parameter
TypeCast(const sem::Type* type, const sem::Parameter* parameter);
TypeConversion(const sem::Type* type, const sem::Parameter* parameter);
/// Destructor
~TypeCast() override;
~TypeConversion() override;
/// @returns the cast source type
const sem::Type* Source() const { return Parameters()[0]->Type(); }
@@ -41,4 +41,4 @@ class TypeCast : public Castable<TypeCast, CallTarget> {
} // namespace sem
} // namespace tint
#endif // SRC_SEM_TYPE_CAST_H_
#endif // SRC_SEM_TYPE_CONVERSION_H_