@@ -40,26 +40,31 @@ class RootSignatureParser {
40
40
private:
41
41
DiagnosticsEngine &getDiags () { return PP.getDiagnostics (); }
42
42
43
- // All private Parse .* methods follow a similar pattern:
43
+ // All private parse .* methods follow a similar pattern:
44
44
// - Each method will start with an assert to denote what the CurToken is
45
45
// expected to be and will parse from that token forward
46
46
//
47
47
// - Therefore, it is the callers responsibility to ensure that you are
48
48
// at the correct CurToken. This should be done with the pattern of:
49
49
//
50
- // if (TryConsumeExpectedToken(RootSignatureToken::Kind))
51
- // if (Parse.*())
52
- // return true;
50
+ // if (tryConsumeExpectedToken(RootSignatureToken::Kind)) {
51
+ // auto ParsedObject = parse.*();
52
+ // if (!ParsedObject.has_value())
53
+ // return std::nullopt;
54
+ // ...
55
+ // }
53
56
//
54
57
// or,
55
58
//
56
- // if (ConsumeExpectedToken(RootSignatureToken::Kind, ...))
57
- // return true;
58
- // if (Parse.*())
59
- // return true;
59
+ // if (consumeExpectedToken(RootSignatureToken::Kind, ...))
60
+ // return std::nullopt;
61
+ // auto ParsedObject = parse.*();
62
+ // if (!ParsedObject.has_value())
63
+ // return std::nullopt;
64
+ // ...
60
65
//
61
- // - All methods return true if a parsing error is encountered. It is the
62
- // callers responsibility to propogate this error up, or deal with it
66
+ // - All methods return std::nullopt if a parsing error is encountered. It
67
+ // is the callers responsibility to propogate this error up, or deal with it
63
68
// otherwise
64
69
//
65
70
// - An error will be raised if the proceeding tokens are not what is
@@ -70,16 +75,17 @@ class RootSignatureParser {
70
75
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>
71
76
parseDescriptorTableClause ();
72
77
73
- struct ParsedParams {
78
+ // / Parameter parse methods
79
+ // / Parameter arguments (eg. `bReg`, `space`, ...) can be specified in any
80
+ // / order and only exactly once. `ParsedClauseParams` denotes the current
81
+ // / state of parsed params
82
+ struct ParsedClauseParams {
74
83
std::optional<llvm::hlsl::rootsig::Register> Register;
75
84
std::optional<uint32_t > Space;
76
85
};
77
- // / Parses out a `ParsedParams` for the caller to use for construction
78
- // / of the in-memory representation of a Root Element.
79
- std::optional<ParsedParams>
86
+ std::optional<ParsedClauseParams>
80
87
parseDescriptorTableClauseParams (RootSignatureToken::Kind RegType);
81
88
82
- // / Parameter parse methods corresponding to a ParamType
83
89
std::optional<uint32_t > parseUIntParam ();
84
90
std::optional<llvm::hlsl::rootsig::Register> parseRegister ();
85
91
0 commit comments