WebKit Bugzilla
Attachment 347581 Details for
Bug 188770
: [WHLSL] Call expressions shouldn't have type arguments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Needs tests
bug-188770-20180820172820.patch (text/plain), 13.58 KB, created by
Myles C. Maxfield
on 2018-08-20 17:28:21 PDT
(
hide
)
Description:
Needs tests
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-08-20 17:28:21 PDT
Size:
13.58 KB
patch
obsolete
>Subversion Revision: 235099 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 16a144fa6d071bfcafff4a330f4c1e0e3260d238..3e4f2e24207c2f0c705944430a985f6fb6dd917a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,38 @@ >+2018-08-20 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Call expressions shouldn't have type arguments >+ https://bugs.webkit.org/show_bug.cgi?id=188770 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Call expressions only had type arguments for casts, becuase native types can have type arguments. >+ However, instead of putting those type arguments on the CallExpression, we should parse the casted >+ type as a real type and not as an identifier, which puts the type arguments in the TypeRef. >+ >+ * WebGPUShadingLanguageRI/CallExpression.js: >+ (CallExpression): >+ (CallExpression.prototype.get name): >+ (CallExpression.resolve): >+ (CallExpression.prototype.get typeArguments): Deleted. >+ (CallExpression.prototype.becomeCast): Deleted. >+ * WebGPUShadingLanguageRI/NameResolver.js: >+ (NameResolver.prototype.visitCallExpression): >+ * WebGPUShadingLanguageRI/Parse.js: >+ (parseConstexpr): >+ (parseTypeDef): >+ (parseLeftOperatorCall): >+ (parseCallExpression.let.parseArguments): >+ (parsePossiblePrefix): >+ (parsePossibleRelationalEquality): >+ (parseLeftLogicalExpression): >+ (parseIfStatement): >+ (parseWhile): >+ (parseFor): >+ (parseDo): >+ * WebGPUShadingLanguageRI/RemoveTypeArguments.js: >+ * WebGPUShadingLanguageRI/Rewriter.js: >+ (Rewriter.prototype.visitCallExpression): >+ > 2018-08-20 Jonathan Bedard <jbedard@apple.com> > > WebKitTestRunner: Add watchOS entitlements >diff --git a/Tools/WebGPUShadingLanguageRI/CallExpression.js b/Tools/WebGPUShadingLanguageRI/CallExpression.js >index 6dba1532946cda78d7955c564bacccb68230762c..b25398f0b1b6eade1b79ac90e6a762525f819bd7 100644 >--- a/Tools/WebGPUShadingLanguageRI/CallExpression.js >+++ b/Tools/WebGPUShadingLanguageRI/CallExpression.js >@@ -25,11 +25,10 @@ > "use strict"; > > class CallExpression extends Expression { >- constructor(origin, name, typeArguments, argumentList) >+ constructor(origin, name, argumentList) > { > super(origin); > this._name = name; >- this._typeArguments = typeArguments; > this._argumentList = argumentList; > this.func = null; > this._isCast = false; >@@ -37,14 +36,13 @@ class CallExpression extends Expression { > } > > get name() { return this._name; } >- get typeArguments() { return this._typeArguments; } > get argumentList() { return this._argumentList; } > get isCast() { return this._isCast; } > get returnType() { return this._returnType; } > > static resolve(origin, possibleOverloads, name, argumentList, argumentTypes, returnType, program) > { >- let call = new CallExpression(origin, name, [], argumentList); >+ let call = new CallExpression(origin, name, argumentList); > call.argumentTypes = argumentTypes.map(argument => argument.visit(new AutoWrapper())); > call.possibleOverloads = possibleOverloads; > if (returnType) >@@ -164,14 +162,6 @@ class CallExpression extends Expression { > return result; > } > >- becomeCast(returnType) >- { >- this._returnType = new TypeRef(this.origin, this.name); >- this._returnType.type = returnType; >- this._name = "operator cast"; >- this._isCast = true; >- } >- > setCastData(returnType) > { > this._returnType = returnType; >diff --git a/Tools/WebGPUShadingLanguageRI/NameResolver.js b/Tools/WebGPUShadingLanguageRI/NameResolver.js >index a2af1d933467251726c427fa064b6d74c9235575..f615a2fb4e87dc1deb7b01b572fb7af626abd095 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/NameResolver.js >@@ -198,15 +198,13 @@ class NameResolver extends Visitor { > let funcs = this._nameContext.get(Func, node.name); > if (funcs) > node.possibleOverloads = funcs; >- else { >- let type = this._nameContext.get(Type, node.name); >- if (!type) >- throw new WTypeError(node.origin.originString, "Cannot find any function or type named \"" + node.name + "\""); >- node.becomeCast(type); >+ else if (node.name != "operator cast"){ >+ node.setCastData(new TypeRef(node.origin, node.name)); > node.possibleOverloads = this._nameContext.get(Func, "operator cast"); >- if (!node.possibleOverloads) >- throw new WTypeError(node.origin.originString, "Cannot find any operator cast implementations in cast to " + type); > } >+ >+ if (!node.possibleOverloads) >+ throw new WTypeError(node.origin.originString, "Cannot find any possible overloads for " + node); > > super.visitCallExpression(node); > } >diff --git a/Tools/WebGPUShadingLanguageRI/Parse.js b/Tools/WebGPUShadingLanguageRI/Parse.js >index c4ae9de7fde8562969260c1469c22b586de76df9..be35a1ddfca9b551a5aecd39beee22d657f5434f 100644 >--- a/Tools/WebGPUShadingLanguageRI/Parse.js >+++ b/Tools/WebGPUShadingLanguageRI/Parse.js >@@ -188,7 +188,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > let token; > if (token = tryConsume("-")) >- return new CallExpression(token, "operator" + token.text, [], [parseTerm()]); >+ return new CallExpression(token, "operator" + token.text, [parseTerm()]); > let left = parseTerm(); > if (token = tryConsume(".")) > left = new DotExpression(token, left, consumeKind("identifier").text); >@@ -285,7 +285,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > let origin = consume("typedef"); > let name = consumeKind("identifier").text; > consume("="); >- let type = parseType(true); >+ let type = parseType(); > consume(";"); > return new TypeDef(origin, name, type); > } >@@ -304,24 +304,39 @@ function parse(program, origin, originKind, lineNumberOffset, text) > return genericParseLeft( > texts, nextParser, > (token, left, right) => >- new CallExpression(token, "operator" + token.text, [], [left, right])); >+ new CallExpression(token, "operator" + token.text, [left, right])); > } > > function parseCallExpression() > { >- let name = consumeKind("identifier"); >- let typeArguments = parseTypeArguments(); >- consume("("); >- let argumentList = []; >- while (!test(")")) { >- let argument = parsePossibleAssignment(); >- argumentList.push(argument); >- if (!tryConsume(",")) >- break; >+ let parseArguments = function(origin, callName) { >+ let argumentList = []; >+ while (!test(")")) { >+ let argument = parsePossibleAssignment(); >+ argumentList.push(argument); >+ if (!tryConsume(",")) >+ break; >+ } >+ consume(")"); >+ return new CallExpression(origin, callName, argumentList); >+ } >+ >+ let name = lexer.backtrackingScope(() => { >+ let name = consumeKind("identifier"); >+ consume("("); >+ return name; >+ }); >+ >+ if (name) { >+ let result = parseArguments(name, name.text); >+ return result; >+ } else { >+ let returnType = parseType(); >+ consume("("); >+ let result = parseArguments(returnType.origin, "operator cast"); >+ result.setCastData(returnType); >+ return result; > } >- consume(")"); >- let result = new CallExpression(name, name.text, typeArguments, argumentList); >- return result; > } > > function isCallExpression() >@@ -346,7 +361,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > if (name == "operator") > throw new Error("Invalid name: " + name); > >- return new CallExpression(token, name, [], args); >+ return new CallExpression(token, name, args); > } > > function finishParsingPostIncrement(token, left) >@@ -419,7 +434,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > if (test("++", "--")) > return parsePreIncrement(); > if (token = tryConsume("+", "-", "~")) >- return new CallExpression(token, "operator" + token.text, [], [parsePossiblePrefix()]); >+ return new CallExpression(token, "operator" + token.text, [parsePossiblePrefix()]); > if (token = tryConsume("*")) > return new DereferenceExpression(token, parsePossiblePrefix()); > if (token = tryConsume("&")) >@@ -428,7 +443,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > return new MakeArrayRefExpression(token, parsePossiblePrefix()); > if (token = tryConsume("!")) { > let remainder = parsePossiblePrefix(); >- return new LogicalNot(token, new CallExpression(remainder.origin, "bool", [], [remainder])); >+ return new LogicalNot(token, new CallExpression(remainder.origin, "bool", [remainder])); > } > return parsePossibleSuffix(); > } >@@ -458,7 +473,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > return genericParseLeft( > ["==", "!="], parsePossibleRelationalInequality, > (token, left, right) => { >- let result = new CallExpression(token, "operator==", [], [left, right]); >+ let result = new CallExpression(token, "operator==", [left, right]); > if (token.text == "!=") > result = new LogicalNot(token, result); > return result; >@@ -484,7 +499,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > return genericParseLeft( > texts, nextParser, >- (token, left, right) => new LogicalExpression(token, token.text, new CallExpression(left.origin, "bool", [], [left]), new CallExpression(right.origin, "bool", [], [right]))); >+ (token, left, right) => new LogicalExpression(token, token.text, new CallExpression(left.origin, "bool", [left]), new CallExpression(right.origin, "bool", [right]))); > } > > function parsePossibleLogicalAnd() >@@ -621,7 +636,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > let elseBody; > if (tryConsume("else")) > elseBody = parseStatement(); >- return new IfStatement(origin, new CallExpression(conditional.origin, "bool", [], [conditional]), body, elseBody); >+ return new IfStatement(origin, new CallExpression(conditional.origin, "bool", [conditional]), body, elseBody); > } > > function parseWhile() >@@ -631,7 +646,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > let conditional = parseExpression(); > consume(")"); > let body = parseStatement(); >- return new WhileLoop(origin, new CallExpression(conditional.origin, "bool", [], [conditional]), body); >+ return new WhileLoop(origin, new CallExpression(conditional.origin, "bool", [conditional]), body); > } > > function parseFor() >@@ -652,7 +667,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > else { > condition = parseExpression(); > consume(";"); >- condition = new CallExpression(condition.origin, "bool", [], [condition]); >+ condition = new CallExpression(condition.origin, "bool", [condition]); > } > let increment; > if (tryConsume(")")) >@@ -673,7 +688,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > consume("("); > let conditional = parseExpression(); > consume(")"); >- return new DoWhileLoop(origin, body, new CallExpression(conditional.origin, "bool", [], [conditional])); >+ return new DoWhileLoop(origin, body, new CallExpression(conditional.origin, "bool", [conditional])); > } > > function parseVariableDecls() >diff --git a/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js b/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js >index 7f9087032e850fe0df45fd7d7d8fbaf334fa00bc..93db9e647c921c954e8998ce1675de7cb61f142b 100644 >--- a/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js >+++ b/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js >@@ -59,15 +59,7 @@ function removeTypeArguments(program) > node._name = RemoveTypeArguments.resolveNameAndArguments(node); > node._typeArguments = null; > } >- >- visitCallExpression(node) >- { >- node._name = RemoveTypeArguments.resolveNameAndArguments(node); >- if (!node._name || !node._name.length) >- throw new Error("lazy"); >- node._typeArguments = null; >- } > } > > program.visit(new RemoveTypeArguments()); >-} >\ No newline at end of file >+} >diff --git a/Tools/WebGPUShadingLanguageRI/Rewriter.js b/Tools/WebGPUShadingLanguageRI/Rewriter.js >index b56cd60bf6fc2636ddd4341252a46aa324fb496d..d547d203f0dbf8cabee4377803bd5b084e9807bc 100644 >--- a/Tools/WebGPUShadingLanguageRI/Rewriter.js >+++ b/Tools/WebGPUShadingLanguageRI/Rewriter.js >@@ -298,7 +298,7 @@ class Rewriter { > visitCallExpression(node) > { > let result = new CallExpression( >- node.origin, node.name, null, >+ node.origin, node.name, > node.argumentList.map(argument => Node.visit(argument, this))); > return this.processDerivedCallData(node, result); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188770
:
347580
|
347581
|
347593
|
347595
|
347649