sem: Add new TypeConstructor and TypeCast CallTargets

Nothing yet creates or uses these.

Also add Constant to sem::Call.
These will be needed for TypeConstructors / TypeCasts.

Bug: tint:888
Change-Id: I5b8c64062f3262bdffd210bb012db980c5610b26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69107
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/BUILD.gn b/src/BUILD.gn
index db0f44d..bc38876 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -408,6 +408,8 @@
     "sem/storage_texture_type.h",
     "sem/switch_statement.h",
     "sem/texture_type.h",
+    "sem/type_cast.h",
+    "sem/type_constructor.h",
     "sem/type.h",
     "sem/type_manager.h",
     "sem/type_mappings.h",
@@ -574,6 +576,10 @@
     "sem/switch_statement.h",
     "sem/texture_type.cc",
     "sem/texture_type.h",
+    "sem/type_cast.cc",
+    "sem/type_cast.h",
+    "sem/type_constructor.cc",
+    "sem/type_constructor.h",
     "sem/type.cc",
     "sem/type.h",
     "sem/type_manager.cc",
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d7f8178..06758d8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -379,6 +379,10 @@
   sem/switch_statement.h
   sem/texture_type.cc
   sem/texture_type.h
+  sem/type_cast.cc
+  sem/type_cast.h
+  sem/type_constructor.cc
+  sem/type_constructor.h
   sem/type.cc
   sem/type.h
   sem/type_manager.cc
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 7a30a4d..51b6e4c 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -2500,7 +2500,7 @@
   }
 
   auto* call = builder_->create<sem::Call>(expr, intrinsic, std::move(args),
-                                           current_statement_);
+                                           current_statement_, sem::Constant{});
 
   current_function_->AddDirectlyCalledIntrinsic(intrinsic);
 
@@ -2544,7 +2544,7 @@
   }
 
   auto* call = builder_->create<sem::Call>(expr, target, std::move(args),
-                                           current_statement_);
+                                           current_statement_, sem::Constant{});
 
   if (current_function_) {
     target->AddCallSite(call);
diff --git a/src/sem/call.cc b/src/sem/call.cc
index ac95e78..9432fee 100644
--- a/src/sem/call.cc
+++ b/src/sem/call.cc
@@ -25,8 +25,9 @@
 Call::Call(const ast::CallExpression* declaration,
            const CallTarget* target,
            std::vector<const sem::Expression*> arguments,
-           Statement* statement)
-    : Base(declaration, target->ReturnType(), statement, Constant{}),
+           const Statement* statement,
+           Constant constant)
+    : Base(declaration, target->ReturnType(), statement, std::move(constant)),
       target_(target),
       arguments_(std::move(arguments)) {}
 
diff --git a/src/sem/call.h b/src/sem/call.h
index e7ce6bd..adae212 100644
--- a/src/sem/call.h
+++ b/src/sem/call.h
@@ -32,10 +32,12 @@
   /// @param target the call target
   /// @param arguments the call arguments
   /// @param statement the statement that owns this expression
+  /// @param constant the constant value of this expression
   Call(const ast::CallExpression* declaration,
        const CallTarget* target,
        std::vector<const sem::Expression*> arguments,
-       Statement* statement);
+       const Statement* statement,
+       Constant constant);
 
   /// Destructor
   ~Call() override;
diff --git a/src/sem/call_target.h b/src/sem/call_target.h
index 3ed05ab..0281d5a 100644
--- a/src/sem/call_target.h
+++ b/src/sem/call_target.h
@@ -56,7 +56,8 @@
   int IndexOf(ParameterUsage usage) const;
 };
 
-/// CallTarget is the base for callable functions
+/// CallTarget is the base for callable functions, intrinsics, type constructors
+/// and type casts.
 class CallTarget : public Castable<CallTarget, Node> {
  public:
   /// Constructor
diff --git a/src/sem/expression.h b/src/sem/expression.h
index e605ef8..4fc6e82 100644
--- a/src/sem/expression.h
+++ b/src/sem/expression.h
@@ -41,6 +41,9 @@
   /// Destructor
   ~Expression() override;
 
+  /// @returns the AST node
+  const ast::Expression* Declaration() const { return declaration_; }
+
   /// @return the resolved type of the expression
   const sem::Type* Type() const { return type_; }
 
@@ -50,9 +53,6 @@
   /// @return the constant value of this expression
   const Constant& ConstantValue() const { return constant_; }
 
-  /// @returns the AST node
-  const ast::Expression* Declaration() const { return declaration_; }
-
  protected:
   /// The AST expression node for this semantic expression
   const ast::Expression* const declaration_;
diff --git a/src/sem/type_cast.cc b/src/sem/type_cast.cc
new file mode 100644
index 0000000..aa39c36
--- /dev/null
+++ b/src/sem/type_cast.cc
@@ -0,0 +1,28 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/sem/type_cast.h"
+
+TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeCast);
+
+namespace tint {
+namespace sem {
+
+TypeCast::TypeCast(const sem::Type* type, const sem::Parameter* parameter)
+    : Base(type, ParameterList{parameter}) {}
+
+TypeCast::~TypeCast() = default;
+
+}  // namespace sem
+}  // namespace tint
diff --git a/src/sem/type_cast.h b/src/sem/type_cast.h
new file mode 100644
index 0000000..4acd888
--- /dev/null
+++ b/src/sem/type_cast.h
@@ -0,0 +1,44 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// 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_
+
+#include "src/sem/call_target.h"
+
+namespace tint {
+namespace sem {
+
+/// TypeCast is the CallTarget for a type cast.
+class TypeCast : public Castable<TypeCast, 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);
+
+  /// Destructor
+  ~TypeCast() override;
+
+  /// @returns the cast source type
+  const sem::Type* Source() const { return Parameters()[0]->Type(); }
+
+  /// @returns the cast target type
+  const sem::Type* Target() const { return ReturnType(); }
+};
+
+}  // namespace sem
+}  // namespace tint
+
+#endif  // SRC_SEM_TYPE_CAST_H_
diff --git a/src/sem/type_constructor.cc b/src/sem/type_constructor.cc
new file mode 100644
index 0000000..7ff12c4
--- /dev/null
+++ b/src/sem/type_constructor.cc
@@ -0,0 +1,29 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/sem/type_constructor.h"
+
+TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeConstructor);
+
+namespace tint {
+namespace sem {
+
+TypeConstructor::TypeConstructor(const sem::Type* type,
+                                 const ParameterList& parameters)
+    : Base(type, parameters) {}
+
+TypeConstructor::~TypeConstructor() = default;
+
+}  // namespace sem
+}  // namespace tint
diff --git a/src/sem/type_constructor.h b/src/sem/type_constructor.h
new file mode 100644
index 0000000..7acc22f
--- /dev/null
+++ b/src/sem/type_constructor.h
@@ -0,0 +1,38 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_SEM_TYPE_CONSTRUCTOR_H_
+#define SRC_SEM_TYPE_CONSTRUCTOR_H_
+
+#include "src/sem/call_target.h"
+
+namespace tint {
+namespace sem {
+
+/// TypeConstructor is the CallTarget for a type constructor.
+class TypeConstructor : public Castable<TypeConstructor, CallTarget> {
+ public:
+  /// Constructor
+  /// @param type the type that's being constructed
+  /// @param parameters the type constructor parameters
+  TypeConstructor(const sem::Type* type, const ParameterList& parameters);
+
+  /// Destructor
+  ~TypeConstructor() override;
+};
+
+}  // namespace sem
+}  // namespace tint
+
+#endif  // SRC_SEM_TYPE_CONSTRUCTOR_H_
diff --git a/src/sem/variable.h b/src/sem/variable.h
index ffc89eb..78e208a 100644
--- a/src/sem/variable.h
+++ b/src/sem/variable.h
@@ -188,7 +188,7 @@
  private:
   const uint32_t index_;
   const ParameterUsage usage_;
-  CallTarget const* owner_;
+  CallTarget const* owner_ = nullptr;
 };
 
 /// ParameterList is a list of Parameter