mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
intrinsics: Add new struct form of modf(), frexp()
Implement these for all the writers. SPIR-V reader not implemented (the old overloads weren't implemented either). Deprecate the old overloads. Fixed: tint:54 Change-Id: If66d26dbac3389ff604734f31b426abe47868b91 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59302 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -58,6 +58,8 @@ func (g *generator) generate(tmpl string, w io.Writer, writeFile WriteFile) erro
|
||||
"SplitDisplayName": splitDisplayName,
|
||||
"HasPrefix": strings.HasPrefix,
|
||||
"HasSuffix": strings.HasSuffix,
|
||||
"TrimPrefix": strings.TrimPrefix,
|
||||
"TrimSuffix": strings.TrimSuffix,
|
||||
"IsEnumEntry": is(sem.EnumEntry{}),
|
||||
"IsEnumMatcher": is(sem.EnumMatcher{}),
|
||||
"IsFQN": is(sem.FullyQualifiedName{}),
|
||||
@@ -66,6 +68,7 @@ func (g *generator) generate(tmpl string, w io.Writer, writeFile WriteFile) erro
|
||||
"IsTemplateNumberParam": is(sem.TemplateNumberParam{}),
|
||||
"IsTemplateTypeParam": is(sem.TemplateTypeParam{}),
|
||||
"IsType": is(sem.Type{}),
|
||||
"IsDeclarable": isDeclarable,
|
||||
"IsFirstIn": isFirstIn,
|
||||
"IsLastIn": isLastIn,
|
||||
"IntrinsicTable": g.intrinsicTable,
|
||||
@@ -200,6 +203,13 @@ func iterate(n int) []int {
|
||||
return out
|
||||
}
|
||||
|
||||
// isDeclarable returns false if the FullyQualifiedName starts with a
|
||||
// leading underscore. These are undeclarable as WGSL does not allow identifers
|
||||
// to have a leading underscore.
|
||||
func isDeclarable(fqn sem.FullyQualifiedName) bool {
|
||||
return !strings.HasPrefix(fqn.Target.GetName(), "_")
|
||||
}
|
||||
|
||||
// pascalCase returns the snake-case string s transformed into 'PascalCase',
|
||||
// Rules:
|
||||
// * The first letter of the string is capitalized
|
||||
|
||||
@@ -364,6 +364,10 @@ func validate(fqn sem.FullyQualifiedName, uses *sem.StageUses) bool {
|
||||
}
|
||||
}
|
||||
|
||||
if !isDeclarable(fqn) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, arg := range fqn.TemplateArguments {
|
||||
if argFQN, ok := arg.(sem.FullyQualifiedName); ok {
|
||||
if !validate(argFQN, uses) {
|
||||
|
||||
@@ -91,7 +91,7 @@ func (l *lexer) lex() error {
|
||||
case l.match("enum", tok.Enum):
|
||||
case l.match("type", tok.Type):
|
||||
case l.match("match", tok.Match):
|
||||
case unicode.IsLetter(l.peek(0)):
|
||||
case unicode.IsLetter(l.peek(0)) || l.peek(0) == '_':
|
||||
l.tok(l.count(alphaNumericOrUnderscore), tok.Identifier)
|
||||
case unicode.IsNumber(l.peek(0)):
|
||||
l.tok(l.count(unicode.IsNumber), tok.Integer)
|
||||
|
||||
@@ -40,6 +40,9 @@ func TestLexTokens(t *testing.T) {
|
||||
{"ident_123", tok.Token{Kind: tok.Identifier, Runes: []rune("ident_123"), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 10, 9),
|
||||
}}},
|
||||
{"_ident_", tok.Token{Kind: tok.Identifier, Runes: []rune("_ident_"), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 8, 7),
|
||||
}}},
|
||||
{"123456789", tok.Token{Kind: tok.Integer, Runes: []rune("123456789"), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 10, 9),
|
||||
}}},
|
||||
|
||||
Reference in New Issue
Block a user