Diff
Modified: trunk/Tools/ChangeLog (221685 => 221686)
--- trunk/Tools/ChangeLog 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/ChangeLog 2017-09-06 18:25:55 UTC (rev 221686)
@@ -1,3 +1,65 @@
+2017-09-06 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ WSL should correctly handle the interaction between casting operators and complex types
+ https://bugs.webkit.org/show_bug.cgi?id=176316
+
+ Reviewed by Filip Pizlo.
+
+ This allows the standard library to include all identity cast operators for all exsting
+ and yet-to-exist types. The standard library now has a function with the signature:
+ operator T<><T>(T). This means "for all T, define a cast operator from T to T<>." The
+ duplicate <>s lets us say things like operator OutputVector<T><T>(InputVector<T> x).
+
+ For testing, this patch also adds the ability to cast an arbitrary Equatable type to bool,
+ by comparing the value to the default value for that type.
+
+ * WebGPUShadingLanguageRI/All.js:
+ * WebGPUShadingLanguageRI/CastExpression.js: Copied from Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js.
+ (CastExpression):
+ (CastExpression.prototype.get functionName):
+ (CastExpression.prototype.get returnType):
+ (CastExpression.prototype.toString):
+ * WebGPUShadingLanguageRI/Checker.js:
+ * WebGPUShadingLanguageRI/Func.js:
+ (Func.prototype.toDeclString):
+ * WebGPUShadingLanguageRI/FuncInstantiator.js:
+ (FuncInstantiator.prototype.getUnique.Instantiate.prototype.visitNativeFunc):
+ (FuncInstantiator.prototype.getUnique.Instantiate):
+ (FuncInstantiator.prototype.getUnique):
+ (FuncInstantiator):
+ * WebGPUShadingLanguageRI/Inliner.js:
+ (Inliner.prototype.visitCastExpression):
+ (Inliner):
+ * WebGPUShadingLanguageRI/Intrinsics.js:
+ (Intrinsics):
+ * WebGPUShadingLanguageRI/NativeFunc.js:
+ * WebGPUShadingLanguageRI/NativeFuncInstance.js:
+ (NativeFuncInstance):
+ * WebGPUShadingLanguageRI/Parse.js:
+ (parsePossiblePrefix):
+ (parseFuncDecl):
+ (parseOperatorFuncDefValues): Deleted.
+ (parseNonOperatorFuncDefValues): Deleted.
+ (parseGenericFuncDefValues): Deleted.
+ * WebGPUShadingLanguageRI/Prepare.js:
+ (prepare):
+ * WebGPUShadingLanguageRI/Program.js:
+ (Program.prototype.resolveFuncOverload):
+ * WebGPUShadingLanguageRI/ResolveOverloadImpl.js:
+ (resolveOverloadImpl):
+ * WebGPUShadingLanguageRI/Rewriter.js:
+ (Rewriter.prototype.processDerivedCallData):
+ (Rewriter.prototype.visitCastExpression):
+ (Rewriter.prototype.visitCallExpression):
+ * WebGPUShadingLanguageRI/StandardLibrary.js: Removed.
+ * WebGPUShadingLanguageRI/Test.html:
+ * WebGPUShadingLanguageRI/Test.js:
+ * WebGPUShadingLanguageRI/TypeDefResolver.js:
+ (TypeDefResolver):
+ (TypeDefResolver.prototype.visitFuncDef): Deleted.
+ * WebGPUShadingLanguageRI/Visitor.js:
+ (Visitor.prototype.visitCastExpression):
+
2017-09-06 Daniel Bates <daba...@apple.com>
Copy WebKit Permalink may generate wrong URL with SVN checkout
Modified: trunk/Tools/WebGPUShadingLanguageRI/All.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -41,6 +41,7 @@
load("CallAssignment.js");
load("CallExpression.js");
load("CallFunction.js");
+load("CastExpression.js");
load("Check.js");
load("CheckLiteralTypes.js");
load("CheckReturns.js");
@@ -96,7 +97,8 @@
load("Return.js");
load("ReturnChecker.js");
load("ReturnException.js");
-load("StandardLibrary.js");
+load("StandardLibraryEpilogue.js");
+load("StandardLibraryPrologue.js");
load("StructLayoutBuilder.js");
load("StructType.js");
load("Substitution.js");
Copied: trunk/Tools/WebGPUShadingLanguageRI/CastExpression.js (from rev 221684, trunk/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js) (0 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/CastExpression.js (rev 0)
+++ trunk/Tools/WebGPUShadingLanguageRI/CastExpression.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+"use strict";
+
+// This is a bit of a misnomer, as this represents casts as well as constructors.
+// Syntactically they are identical; a cast just takes one argument whereas a
+// constructor takes 0-n.
+class CastExpression extends CallExpression {
+ constructor(origin, returnType, typeArguments, argumentList)
+ {
+ super(origin, CastExpression.functionName, typeArguments, argumentList);
+ this._returnType = returnType;
+ }
+
+ static get functionName() { return "operator cast"; }
+
+ get returnType() { return this._returnType; }
+
+ toString()
+ {
+ return this.returnType + "<" + this.typeArguments + ">(" + this.argumentList + ")";
+ }
+}
+
Modified: trunk/Tools/WebGPUShadingLanguageRI/Checker.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -233,8 +233,8 @@
result = _expression_.visit(this);
return result;
}
-
- visitCallExpression(node)
+
+ checkCastOrCallExpression(node, returnType)
{
for (let typeArgument of node.typeArguments)
typeArgument.visit(this);
@@ -245,6 +245,8 @@
return TypeRef.wrap(newArgument);
});
node.argumentTypes = argumentTypes;
+ if (returnType)
+ returnType.visit(this);
let overload = null;
let failures = [];
@@ -257,7 +259,7 @@
typeParameter.protocol.protocolDecl.signaturesByNameWithTypeVariable(node.name, typeParameter);
if (!signatures)
continue;
- overload = resolveOverloadImpl(signatures, node.typeArguments, argumentTypes);
+ overload = resolveOverloadImpl(signatures, node.typeArguments, argumentTypes, returnType);
if (overload.func)
break;
failures.push(...overload.failures);
@@ -265,7 +267,7 @@
}
if (!overload) {
overload = this._program.resolveFuncOverload(
- node.name, node.typeArguments, argumentTypes);
+ node.name, node.typeArguments, argumentTypes, returnType);
if (!overload.func) {
failures.push(...overload.failures);
let message = "Did not find function for call";
@@ -284,5 +286,15 @@
}
return node.resolve(overload);
}
+
+ visitCastExpression(node)
+ {
+ return this.checkCastOrCallExpression(node, node.returnType);
+ }
+
+ visitCallExpression(node)
+ {
+ return this.checkCastOrCallExpression(node, undefined);
+ }
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Func.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Func.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Func.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -48,7 +48,7 @@
toDeclString()
{
- return (this.isCast ? "" : this.returnType + " ") + this.name + "<" + this.typeParameters + ">(" + this.parameters + ")";
+ return (this.isCast ? "operator " + this.returnType : this.returnType + " " + this.name) + "<" + this.typeParameters + ">(" + this.parameters + ")";
}
toString()
Modified: trunk/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -92,7 +92,8 @@
return new NativeFuncInstance(
func,
func.returnType.visit(substitution),
- func.parameters.map(parameter => parameter.visit(substitution)));
+ func.parameters.map(parameter => parameter.visit(substitution)),
+ func.isCast);
}
}
let resultingFunc = func.visit(new Instantiate());
Modified: trunk/Tools/WebGPUShadingLanguageRI/Inliner.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Inliner.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Inliner.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -58,5 +58,10 @@
func.parameters, func.body);
});
}
+
+ visitCastExpression(node)
+ {
+ return this.visitCallExpression(node);
+ }
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -34,9 +34,9 @@
this._map = new Map();
// NOTE: Intrinsic resolution happens before type name resolution, so the strings we use here
- // to catch the intrinsics must be based on the type names that StandardLibrary.js uses. For
- // example, if a native function is declared using "int" rather than "int32", then we must use
- // "int" here, since we don't yet know that they are the same type.
+ // to catch the intrinsics must be based on the type names that StandardLibraryPrologue.js uses.
+ // For example, if a native function is declared using "int" rather than "int32", then we must
+ // use "int" here, since we don't yet know that they are the same type.
this._map.set(
"native primitive type void<>",
@@ -178,27 +178,6 @@
EPtr.box(left.loadValue() == right.loadValue());
});
- this._map.set(
- "native operator int<>(int)",
- func => {
- func.implementation = ([value]) =>
- EPtr.box(value.loadValue());
- });
-
- this._map.set(
- "native operator uint<>(uint)",
- func => {
- func.implementation = ([value]) =>
- EPtr.box(value.loadValue());
- });
-
- this._map.set(
- "native operator bool<>(bool)",
- func => {
- func.implementation = ([value]) =>
- EPtr.box(value.loadValue());
- });
-
let arrayElementPtr = func => {
func.implementation = ([ref, index], node) => {
ref = ref.loadValue();
Modified: trunk/Tools/WebGPUShadingLanguageRI/NativeFunc.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/NativeFunc.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/NativeFunc.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -25,7 +25,7 @@
"use strict";
class NativeFunc extends Func {
- constructor(origin, name, returnType, typeParameters, parameters, isCast = false)
+ constructor(origin, name, returnType, typeParameters, parameters, isCast)
{
super(origin, name, returnType, typeParameters, parameters, isCast);
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -25,9 +25,9 @@
"use strict";
class NativeFuncInstance extends Func {
- constructor(func, returnType, parameters)
+ constructor(func, returnType, parameters, isCast)
{
- super(func.origin, func.name, returnType, [], parameters);
+ super(func.origin, func.name, returnType, [], parameters, isCast);
}
get func() { return this._func; }
Modified: trunk/Tools/WebGPUShadingLanguageRI/Parse.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -380,8 +380,10 @@
return new MakePtrExpression(token, parsePossiblePrefix());
if (token = tryConsume("@"))
return new MakeArrayRefExpression(token, parsePossiblePrefix());
- if (token = tryConsume("!"))
- return new LogicalNot(token, new CallExpression(token, "operator bool", [], [parsePossiblePrefix()]));
+ if (token = tryConsume("!")) {
+ let remainder = parsePossiblePrefix();
+ return new LogicalNot(token, new CastExpression(remainder.origin, new TypeRef(remainder.origin, "bool", []), [], [remainder]));
+ }
return parsePossibleSuffix();
}
@@ -620,44 +622,27 @@
return consumeKind("identifier").text;
}
- function parseOperatorFuncDefValues()
+ function parseFuncDecl()
{
- let result = {};
- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=176316 Correctly handle the interaction between casting operators and complex types
- let castType = consumeKind("identifier").text;
- result.returnType = new TypeRef(name, castType, []);
- result.name = "operator " + castType;
- result.isCast = true;
- return result;
- }
-
- function parseNonOperatorFuncDefValues()
- {
- let result = {};
- result.returnType = parseType();
- result.origin = result.returnType.origin;
- result.name = parseFuncName();
- result.isCast = false;
- return result;
- }
-
- function parseGenericFuncDefValues()
- {
+ let origin;
+ let returnType;
+ let name;
+ let isCast;
let operatorToken = tryConsume("operator");
if (operatorToken) {
- let result = parseOperatorFuncDefValues();
- result.origin = operatorToken.origin;
- return result;
+ origin = operatorToken;
+ returnType = parseType();
+ name = CastExpression.functionName;
+ isCast = true;
+ } else {
+ returnType = parseType();
+ origin = returnType.origin;
+ name = parseFuncName();
+ isCast = false;
}
- return parseNonOperatorFuncDefValues();
- }
-
- function parseFuncDecl()
- {
- let values = parseGenericFuncDefValues();
let typeParameters = parseTypeParameters();
let parameters = parseParameters();
- return new Func(values.origin, values.name, values.returnType, typeParameters, parameters, values.isCast);
+ return new Func(origin, name, returnType, typeParameters, parameters, isCast);
}
function parseProtocolFuncDecl()
Modified: trunk/Tools/WebGPUShadingLanguageRI/Prepare.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Prepare.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Prepare.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -27,8 +27,9 @@
function prepare(origin, lineNumberOffset, text)
{
let program = new Program();
- parse(program, "/internal/stdlib", 28, standardLibrary);
+ parse(program, "/internal/stdlib/prologue", 28, standardLibraryPrologue);
parse(program, origin, lineNumberOffset, text);
+ parse(program, "/internal/stdlib/epilogue", 28, standardLibraryEpilogue);
resolveNames(program);
resolveTypeDefs(program);
check(program);
Modified: trunk/Tools/WebGPUShadingLanguageRI/Program.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Program.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Program.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -58,13 +58,13 @@
this._topLevelStatements.push(statement);
}
- resolveFuncOverload(name, typeArguments, argumentTypes)
+ resolveFuncOverload(name, typeArguments, argumentTypes, returnType)
{
let functions = this.functions.get(name);
if (!functions)
return {failures: []};
- return resolveOverloadImpl(functions, typeArguments, argumentTypes);
+ return resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType);
}
get nameContext()
Modified: trunk/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -24,7 +24,7 @@
*/
"use strict";
-function resolveOverloadImpl(functions, typeArguments, argumentTypes)
+function resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType)
{
let failures = [];
for (let func of functions) {
@@ -42,7 +42,7 @@
let argument = typeArguments[i];
let parameter = func.typeParameters[i];
if (!argument.unify(unificationContext, parameter)) {
- failures.push(new OverloadResolutionFailure(func, "Type argument #" + (i + 1) + " for parameter " + func.typeParameters.name + " does not match (passed " + argument + ", require " + parameter + ")"));
+ failures.push(new OverloadResolutionFailure(func, "Type argument #" + (i + 1) + " for parameter " + parameter.name + " does not match (passed " + argument + ", require " + parameter + ")"));
ok = false;
break;
}
@@ -60,6 +60,12 @@
}
if (!ok)
continue;
+ if (returnType) {
+ if (!returnType.unify(unificationContext, func.returnType)) {
+ failures.push(new OverloadResolutionFailure(func, "Return type " + func.returnType + " does not match " + returnType));
+ continue;
+ }
+ }
if (!unificationContext.verify()) {
failures.push(new OverloadResolutionFailure(func, "Violates type variable constraints"));
continue;
Modified: trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -235,13 +235,9 @@
result.type = node.type ? node.type.visit(this) : null;
return result;
}
-
- visitCallExpression(node)
+
+ processDerivedCallData(node, result)
{
- let result = new CallExpression(
- node.origin, node.name,
- node.typeArguments.map(typeArgument => typeArgument.visit(this)),
- node.argumentList.map(argument => argument.visit(this)));
let actualTypeArguments = node.actualTypeArguments;
if (actualTypeArguments) {
result.actualTypeArguments =
@@ -254,7 +250,25 @@
result.nativeFuncInstance = node.nativeFuncInstance;
return result;
}
+
+ visitCastExpression(node)
+ {
+ let result = new CastExpression(
+ node.origin, node.returnType.visit(this),
+ node.typeArguments.map(typeArgument => typeArgument.visit(this)),
+ node.argumentList.map(argument => argument.visit(this)));
+ return this.processDerivedCallData(node, result);
+ }
+ visitCallExpression(node)
+ {
+ let result = new CallExpression(
+ node.origin, node.name,
+ node.typeArguments.map(typeArgument => typeArgument.visit(this)),
+ node.argumentList.map(argument => argument.visit(this)));
+ return this.processDerivedCallData(node, result);
+ }
+
visitFunctionLikeBlock(node)
{
return new FunctionLikeBlock(
Deleted: trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-"use strict";
-
-// NOTE: The next line is line 28, and we rely on this in Prepare.js.
-const standardLibrary = `
-// This is the WSL standard library. Implementations of all of these things are in
-// Intrinsics.js. The only thing that gets defined before we get here is the primitive
-// protocol.
-
-// Need to bootstrap void first.
-native primitive typedef void;
-
-native primitive typedef int32;
-native primitive typedef uint32;
-native primitive typedef bool;
-typedef int = int32;
-typedef uint = uint32;
-
-native primitive typedef double;
-
-native int operator+(int, int);
-native uint operator+(uint, uint);
-native int operator-(int, int);
-native uint operator-(uint, uint);
-native int operator*(int, int);
-native uint operator*(uint, uint);
-native int operator/(int, int);
-native uint operator/(uint, uint);
-native bool operator==(int, int);
-native bool operator==(uint, uint);
-native bool operator==(bool, bool);
-
-native operator int(int);
-native operator uint(uint);
-native operator bool(bool);
-
-native thread T^ operator&[]<T>(thread T[], uint);
-native threadgroup T^ operator&[]<T:primitive>(threadgroup T[], uint);
-native device T^ operator&[]<T:primitive>(device T[], uint);
-native constant T^ operator&[]<T:primitive>(constant T[], uint);
-`;
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.html (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-06 18:25:55 UTC (rev 221686)
@@ -17,6 +17,7 @@
<script src=""
<script src=""
<script src=""
+<script src=""
<script src=""
<script src=""
<script src=""
@@ -72,7 +73,8 @@
<script src=""
<script src=""
<script src=""
-<script src=""
+<script src=""
+<script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -201,6 +201,13 @@
(e) => e instanceof WTypeError && e.message.indexOf("/internal/test:1") != -1);
}
+function TEST_generalNegation()
+{
+ let program = doPrep("bool foo(int x) { return !x; }");
+ checkBool(program, callFunction(program, "foo", [], [makeInt(program, 7)]), false);
+ checkBool(program, callFunction(program, "foo", [], [makeInt(program, 0)]), true);
+}
+
function TEST_add1() {
let program = doPrep("int foo(int x) { return x + 1; }");
checkInt(program, callFunction(program, "foo", [], [makeInt(program, 42)]), 43);
Modified: trunk/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -30,15 +30,6 @@
super();
this._visiting = new VisitingSet();
}
-
- visitFuncDef(node)
- {
- if (node.isCast && node.returnType.type instanceof TypeDef) {
- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=176316 Correctly handle the interaction between casting operators and complex types
- throw new Error("Casting operators don't work with typedefs.");
- }
- super.visitFuncDef(node);
- }
visitTypeRef(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Visitor.js (221685 => 221686)
--- trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-06 18:16:56 UTC (rev 221685)
+++ trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-06 18:25:55 UTC (rev 221686)
@@ -255,6 +255,12 @@
argument.visit(this);
}
}
+
+ visitCastExpression(node)
+ {
+ this.visitCallExpression(node);
+ node.returnType.visit(this);
+ }
visitLogicalNot(node)
{