Better document ast::Variable parameters

In particular, "is_const=true" is required for formal parameters.

Change-Id: I05105da901a02d9bb51c88cab7430dd211c7b0ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49302
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
David Neto 2021-04-27 15:16:06 +00:00 committed by Commit Bot service account
parent 2c953eca48
commit f63a2948c6

View File

@ -32,7 +32,7 @@ class LocationDecoration;
/// A Variable statement. /// A Variable statement.
/// ///
/// An instance of this class represents one of three constructs in WGSL: "var" /// An instance of this class represents one of three constructs in WGSL: "var"
/// declaration, "const" declaration, or formal parameter to a function. /// declaration, "let" declaration, or formal parameter to a function.
/// ///
/// 1. A "var" declaration is a name for typed storage. Examples: /// 1. A "var" declaration is a name for typed storage. Examples:
/// ///
@ -68,14 +68,20 @@ class LocationDecoration;
/// and storage class S, then its reference type is pointer-to-T-in-S. /// and storage class S, then its reference type is pointer-to-T-in-S.
/// ///
/// This class uses the term "type" to refer to: /// This class uses the term "type" to refer to:
/// the value type of a "const", /// the value type of a "let",
/// the value type of the formal parameter, /// the value type of the formal parameter,
/// or the store type of the "var". /// or the store type of the "var".
//
/// Setting is_const:
/// - "var" gets false
/// - "let" gets true
/// - formal parameter gets true
/// ///
/// The storage class for a "var" is StorageClass::kNone when using the /// Setting storage class:
/// defaulting syntax for a "var" declared inside a function. /// - "var" is StorageClass::kNone when using the
/// The storage class for a "const" is always StorageClass::kNone. /// defaulting syntax for a "var" declared inside a function.
/// The storage class for a formal parameter is always StorageClass::kNone. /// - "let" is always StorageClass::kNone.
/// - formal parameter is always StorageClass::kNone.
class Variable : public Castable<Variable, Node> { class Variable : public Castable<Variable, Node> {
public: public:
/// BindingPoint holds a group and binding decoration. /// BindingPoint holds a group and binding decoration.