WebKit Bugzilla
Attachment 346751 Details for
Bug 188400
: [WHLSL] Start making the compiler match the spec
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-188400-20180807193453.patch (text/plain), 283.57 KB, created by
Myles C. Maxfield
on 2018-08-07 19:34:54 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-08-07 19:34:54 PDT
Size:
283.57 KB
patch
obsolete
>Subversion Revision: 234435 >diff --git a/Tools/WebGPUShadingLanguageRI/All.js b/Tools/WebGPUShadingLanguageRI/All.js >index 15dd7ccab94692a32acd27b9dac96c8a8f55d658..a07ed6c51a7a850f6451334b97faa6a269033ee9 100644 >--- a/Tools/WebGPUShadingLanguageRI/All.js >+++ b/Tools/WebGPUShadingLanguageRI/All.js >@@ -58,7 +58,6 @@ load("Checker.js"); > load("CloneProgram.js"); > load("CommaExpression.js"); > load("ConstexprFolder.js"); >-load("ConstexprTypeParameter.js"); > load("Continue.js"); > load("ConvertPtrToArrayRefExpression.js"); > load("DereferenceExpression.js"); >@@ -77,7 +76,6 @@ load("ExpressionFinder.js"); > load("ExternalOrigin.js"); > load("Field.js"); > load("FindHighZombies.js"); >-load("FlattenProtocolExtends.js"); > load("FlattenedStructOffsetGatherer.js"); > load("FloatLiteral.js"); > load("FloatLiteralType.js"); >@@ -95,7 +93,6 @@ load("IndexExpression.js"); > load("InferTypesForCall.js"); > load("Inline.js"); > load("Inliner.js"); >-load("InstantiateImmediates.js"); > load("IntLiteral.js"); > load("IntLiteralType.js"); > load("Intrinsics.js"); >@@ -125,10 +122,6 @@ load("Prepare.js"); > load("Program.js"); > load("ProgramWithUnnecessaryThingsRemoved.js"); > load("PropertyResolver.js"); >-load("Protocol.js"); >-load("ProtocolDecl.js"); >-load("ProtocolFuncDecl.js"); >-load("ProtocolRef.js"); > load("PtrType.js"); > load("ReadModifyWriteExpression.js"); > load("RecursionChecker.js"); >@@ -153,10 +146,7 @@ load("TrapStatement.js"); > load("TypeDef.js"); > load("TypeDefResolver.js"); > load("TypeOrVariableRef.js"); >-load("TypeParameterRewriter.js"); > load("TypeRef.js"); >-load("TypeVariable.js"); >-load("TypeVariableTracker.js"); > load("TypedValue.js"); > load("UintLiteral.js"); > load("UintLiteralType.js"); >diff --git a/Tools/WebGPUShadingLanguageRI/AutoWrapper.js b/Tools/WebGPUShadingLanguageRI/AutoWrapper.js >index 80ae7d92a4fa62666db2a2ff5220d149a7f38e9c..216a7e2e33de991b06ab636db5cfcab405d8ee29 100644 >--- a/Tools/WebGPUShadingLanguageRI/AutoWrapper.js >+++ b/Tools/WebGPUShadingLanguageRI/AutoWrapper.js >@@ -35,11 +35,6 @@ class AutoWrapper extends Rewriter { > return node; > } > >- visitConstexprTypeParameter(node) >- { >- return VariableRef.wrap(node); >- } >- > visitFuncParameter(node) > { > return VariableRef.wrap(node); >@@ -60,11 +55,6 @@ class AutoWrapper extends Rewriter { > return TypeRef.wrap(node); > } > >- visitTypeVariable(node) >- { >- return TypeRef.wrap(node); >- } >- > visitGenericLiteralType(node) > { > return node; >diff --git a/Tools/WebGPUShadingLanguageRI/CallExpression.js b/Tools/WebGPUShadingLanguageRI/CallExpression.js >index b5ae0fe49fcedc8fa76a66793cfe0cb1f08b4571..c1eb3da5a2aaeef18c34dcc50a80678b993827c8 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,7 +36,6 @@ 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; } >@@ -57,46 +55,20 @@ class CallExpression extends Expression { > if (!possibleOverloads) > throw new WTypeError(this.origin.originString, "Did not find any functions named " + this.name); > >- let overload = null; > let failures = []; >- for (let typeParameter of typeParametersInScope) { >- if (!(typeParameter instanceof TypeVariable)) >- continue; >- if (!typeParameter.protocol) >- continue; >- let signatures = >- typeParameter.protocol.protocolDecl.signaturesByNameWithTypeVariable(this.name, typeParameter); >- if (!signatures) >- continue; >- overload = resolveOverloadImpl(signatures, this.typeArguments, this.argumentTypes, this.returnType); >- if (overload.func) >- break; >+ let overload = resolveOverloadImpl( >+ possibleOverloads, this.argumentTypes, this.returnType); >+ if (!overload.func) { > failures.push(...overload.failures); >- overload = null; >- } >- if (!overload) { >- overload = resolveOverloadImpl( >- possibleOverloads, this.typeArguments, this.argumentTypes, this.returnType); >- if (!overload.func) { >- failures.push(...overload.failures); >- let message = "Did not find function named " + this.name + " for call with "; >- if (this.typeArguments.length) >- message += "type arguments <" + this.typeArguments + "> and "; >- message += "argument types (" + this.argumentTypes + ")"; >- if (this.returnType) >- message +=" and return type " + this.returnType; >- if (failures.length) >- message += ", but considered:\n" + failures.join("\n") >- throw new WTypeError(this.origin.originString, message); >- } >- } >- for (let i = 0; i < typeArguments.length; ++i) { >- let typeArgumentType = typeArguments[i]; >- let typeParameter = overload.func.typeParameters[i]; >- if (!(typeParameter instanceof ConstexprTypeParameter)) >- continue; >- if (!typeParameter.type.equalsWithCommit(typeArgumentType)) >- throw new Error("At " + this.origin.originString + " constexpr type argument and parameter types not equal: argument = " + typeArgumentType + ", parameter = " + typeParameter.type); >+ let message = "Did not find function named " + this.name + " for call with "; >+ if (this.typeArguments.length) >+ message += "type arguments <" + this.typeArguments + "> and "; >+ message += "argument types (" + this.argumentTypes + ")"; >+ if (this.returnType) >+ message +=" and return type " + this.returnType; >+ if (failures.length) >+ message += ", but considered:\n" + failures.join("\n") >+ throw new WTypeError(this.origin.originString, message); > } > for (let i = 0; i < this.argumentTypes.length; ++i) { > let argumentType = this.argumentTypes[i]; >@@ -112,8 +84,6 @@ class CallExpression extends Expression { > resolveToOverload(overload) > { > this.func = overload.func; >- this.actualTypeArguments = overload.typeArguments.map(typeArgument => typeArgument instanceof Type ? typeArgument.visit(new AutoWrapper()) : typeArgument); >- this.instantiatedActualTypeArguments = this.actualTypeArguments; > let result = overload.func.returnType.substituteToUnification( > overload.func.typeParameters, overload.unificationContext); > if (!result) >@@ -125,11 +95,10 @@ class CallExpression extends Expression { > > becomeCast(returnType) > { >- this._returnType = new TypeRef(this.origin, this.name, this._typeArguments); >+ this._returnType = new TypeRef(this.origin, this.name); > this._returnType.type = returnType; > this._name = "operator cast"; > this._isCast = true; >- this._typeArguments = []; > } > > setCastData(returnType) >@@ -141,8 +110,6 @@ class CallExpression extends Expression { > toString() > { > return (this.isCast ? "operator " + this.returnType : this.name) + >- "<" + this.typeArguments + ">" + >- (this.actualTypeArguments ? "<<" + this.actualTypeArguments + ">>" : "") + > "(" + this.argumentList + ")"; > } > } >diff --git a/Tools/WebGPUShadingLanguageRI/CallFunction.js b/Tools/WebGPUShadingLanguageRI/CallFunction.js >index f0f039f5462d0781d82b3464c87478714c0a1737..7495760f2c5d81d839456cde4c459770bcc330fc 100644 >--- a/Tools/WebGPUShadingLanguageRI/CallFunction.js >+++ b/Tools/WebGPUShadingLanguageRI/CallFunction.js >@@ -25,17 +25,17 @@ > "use strict"; > > // This allows you to pass structs and arrays in-place, but it's a more annoying API. >-function callFunction(program, name, typeArguments, argumentList) >+function callFunction(program, name, argumentList) > { > let argumentTypes = argumentList.map(argument => argument.type); >- let funcOrFailures = resolveInlinedFunction(program, name, typeArguments, argumentTypes, true); >+ let funcOrFailures = resolveInlinedFunction(program, name, argumentTypes, true); > if (!(funcOrFailures instanceof Func)) { > let failures = funcOrFailures; >- throw new WTypeError("<callFunction>", "Cannot resolve function call " + name + "<" + typeArguments + ">(" + argumentList + ")" + (failures.length ? "; tried:\n" + failures.join("\n") : "")); >+ throw new WTypeError("<callFunction>", "Cannot resolve function call " + name + "(" + argumentList + ")" + (failures.length ? "; tried:\n" + failures.join("\n") : "")); > } > let func = funcOrFailures; > for (let i = 0; i < func.parameters.length; ++i) { >- let type = argumentTypes[i].instantiatedType; >+ let type = argumentTypes[i]; > type.visit(new StructLayoutBuilder()); > func.parameters[i].ePtr.copyFrom(argumentList[i].ePtr, type.size); > } >diff --git a/Tools/WebGPUShadingLanguageRI/Checker.js b/Tools/WebGPUShadingLanguageRI/Checker.js >index 8d55c50d836c15486fd2580c58e9606cad596ecb..b724c0a657f12e83cfc002169e42a2e07e27488f 100644 >--- a/Tools/WebGPUShadingLanguageRI/Checker.js >+++ b/Tools/WebGPUShadingLanguageRI/Checker.js >@@ -43,8 +43,6 @@ class Checker extends Visitor { > > for (let type of node.types.values()) > doStatement(type); >- for (let protocol of node.protocols.values()) >- doStatement(protocol); > for (let funcs of node.functions.values()) { > for (let func of funcs) { > this.visitFunc(func); >@@ -84,15 +82,6 @@ class Checker extends Visitor { > if (!func.name.startsWith("operator")) > throw new Error("Bad operator overload name: " + func.name); > >- let typeVariableTracker = new TypeVariableTracker(); >- for (let parameterType of func.parameterTypes) >- parameterType.visit(typeVariableTracker); >- Node.visit(func.returnTypeForOverloadResolution, typeVariableTracker); >- for (let typeParameter of func.typeParameters) { >- if (!typeVariableTracker.set.has(typeParameter)) >- throw new WTypeError(typeParameter.origin.originString, "Type parameter " + typeParameter + " to operator " + func.toDeclString() + " is not inferrable from value parameters"); >- } >- > let checkGetter = (kind) => { > let numExpectedParameters = kind == "index" ? 2 : 1; > if (func.parameters.length != numExpectedParameters) >@@ -115,7 +104,7 @@ class Checker extends Visitor { > if (!getterFuncs) > throw new WTypeError(func.origin.originString, "Every setter must have a matching getter, but did not find any function named " + getterName + " to match " + func.name); > let argumentTypes = func.parameterTypes.slice(0, numExpectedParameters - 1); >- let overload = resolveOverloadImpl(getterFuncs, [], argumentTypes, null); >+ let overload = resolveOverloadImpl(getterFuncs, argumentTypes, null); > if (!overload.func) > throw new WTypeError(func.origin.originString, "Did not find function named " + func.name + " with arguments " + argumentTypes + (overload.failures.length ? "; tried:\n" + overload.failures.join("\n") : "")); > let resultType = overload.func.returnType.substituteToUnification( >@@ -211,23 +200,6 @@ class Checker extends Visitor { > { > } > >- visitProtocolDecl(node) >- { >- for (let signature of node.signatures) { >- let typeVariableTracker = new TypeVariableTracker(); >- for (let parameterType of signature.parameterTypes) >- parameterType.visit(typeVariableTracker); >- Node.visit(signature.returnTypeForOverloadResolution, typeVariableTracker); >- for (let typeParameter of signature.typeParameters) { >- if (!typeVariableTracker.set.has(typeParameter)) >- throw WTypeError(typeParameter.origin.originString, "Type parameter to protocol signature not inferrable from value parameters"); >- } >- if (!typeVariableTracker.set.has(node.typeVariable)) >- throw new WTypeError(signature.origin.originString, "Protocol's type variable (" + node.name + ") not mentioned in signature: " + signature); >- this._checkOperatorOverload(signature, name => node.signaturesByName(name)); >- } >- } >- > visitEnumType(node) > { > node.baseType.visit(this); >@@ -278,29 +250,12 @@ class Checker extends Visitor { > throw new WTypeError(node.origin.originString, "Enum does not have a member with the value zero"); > } > >- _checkTypeArguments(origin, typeParameters, typeArguments) >- { >- for (let i = 0; i < typeParameters.length; ++i) { >- let argumentIsType = typeArguments[i] instanceof Type; >- let result = typeArguments[i].visit(this); >- if (argumentIsType) { >- let result = typeArguments[i].inherits(typeParameters[i].protocol); >- if (!result.result) >- throw new WTypeError(origin.originString, "Type argument does not inherit protocol: " + result.reason); >- } else { >- if (!result.equalsWithCommit(typeParameters[i].type)) >- throw new WTypeError(origin.originString, "Wrong type for constexpr"); >- } >- } >- } >- > visitTypeRef(node) > { > if (!node.type) > throw new Error("Type reference without a type in checker: " + node + " at " + node.origin); > if (!(node.type instanceof StructType)) > node.type.visit(this); >- this._checkTypeArguments(node.origin, node.type.typeParameters, node.typeArguments); > } > > visitArrayType(node) >diff --git a/Tools/WebGPUShadingLanguageRI/ConstexprTypeParameter.js b/Tools/WebGPUShadingLanguageRI/ConstexprTypeParameter.js >deleted file mode 100644 >index e3c1826ed55f3fe56f7e0ed2a03dfda028da5b39..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/ConstexprTypeParameter.js >+++ /dev/null >@@ -1,74 +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"; >- >-class ConstexprTypeParameter extends Value { >- constructor(origin, name, type) >- { >- super(); >- this._origin = origin; >- this._name = name; >- this._type = type; >- } >- >- get origin() { return this._origin; } >- get name() { return this._name; } >- get type() { return this._type; } >- get isConstexpr() { return true; } >- get isUnifiable() { return true; } >- get varIsLValue() { return false; } >- >- typeVariableUnify(unificationContext, other) >- { >- if (!(other instanceof Value)) >- return false; >- >- if (!this.type.unify(unificationContext, other.type)) >- return false; >- >- return this._typeVariableUnifyImpl(unificationContext, other); >- } >- >- unifyImpl(unificationContext, other) >- { >- return this.typeVariableUnify(unificationContext, other); >- } >- >- verifyAsArgument(unificationContext) >- { >- return {result: true}; >- } >- >- verifyAsParameter(unificationContext) >- { >- return {result: true}; >- } >- >- toString() >- { >- return this.type + " " + this.name; >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/CreateLiteralType.js b/Tools/WebGPUShadingLanguageRI/CreateLiteralType.js >index 12914da3137fd6b90feda7258627effffbd4e541..f36a5d631879293b03823b701cbe81a5c773252c 100644 >--- a/Tools/WebGPUShadingLanguageRI/CreateLiteralType.js >+++ b/Tools/WebGPUShadingLanguageRI/CreateLiteralType.js >@@ -32,7 +32,7 @@ function createLiteralType(config) > super(); > this._origin = origin; > this._value = value; >- this.preferredType = new TypeRef(origin, config.preferredTypeName, []); >+ this.preferredType = new TypeRef(origin, config.preferredTypeName); > } > > get origin() { return this._origin; } >@@ -58,7 +58,7 @@ function createLiteralType(config) > prepareToVerify(unificationContext) > { > let realThis = unificationContext.find(this); >- if (realThis instanceof TypeVariable || realThis.isLiteral) { >+ if (realThis.isLiteral) { > return () => { > if (realThis.unify(unificationContext, this.preferredType)) > return {result: true}; >diff --git a/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js b/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >index 30e6b031a6dd66597407f3f6b7fe713ed8fdcc4a..a45e3e3c15b37d974b060bbab3ebbce051404ed6 100644 >--- a/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >+++ b/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >@@ -46,11 +46,6 @@ class ExpressionFinder extends Visitor { > this._callback(node.type); > } > >- visitConstexprTypeParameter(node) >- { >- this._callback(node.type); >- } >- > visitAssignment(node) > { > this._callback(node); >diff --git a/Tools/WebGPUShadingLanguageRI/FlattenProtocolExtends.js b/Tools/WebGPUShadingLanguageRI/FlattenProtocolExtends.js >deleted file mode 100644 >index 76172d98d1e2c008edb5d8183f5eefd678dc8ee9..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/FlattenProtocolExtends.js >+++ /dev/null >@@ -1,53 +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"; >- >-function flattenProtocolExtends(program) >-{ >- let visiting = new VisitingSet(); >- >- function flatten(protocol) >- { >- if (!protocol.extends.length) >- return; >- >- visiting.doVisit(protocol, () => { >- for (let parent of protocol.extends) { >- parent = parent.protocolDecl; >- flatten(parent); >- for (let signature of parent.signatures) { >- let newSignature = signature.visit( >- new Substitution([parent.typeVariable], [protocol.typeVariable])); >- protocol.add(newSignature); >- } >- } >- protocol.extends = []; >- }); >- } >- >- for (let protocol of program.protocols.values()) >- flatten(protocol); >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/Func.js b/Tools/WebGPUShadingLanguageRI/Func.js >index 6fa7c9d1b6f4b958335981c2728be865a56e73ae..6fc7332761d463c35a8c40c2a76f2f4b36c23223 100644 >--- a/Tools/WebGPUShadingLanguageRI/Func.js >+++ b/Tools/WebGPUShadingLanguageRI/Func.js >@@ -25,7 +25,7 @@ > "use strict"; > > class Func extends Node { >- constructor(origin, name, returnType, typeParameters, parameters, isCast, shaderType) >+ constructor(origin, name, returnType, parameters, isCast, shaderType) > { > if (!(origin instanceof LexerToken)) > throw new Error("Bad origin: " + origin); >@@ -39,7 +39,6 @@ class Func extends Node { > this._origin = origin; > this._name = name; > this._returnType = returnType; >- this._typeParameters = typeParameters; > this._parameters = parameters; > this._isCast = isCast; > this._shaderType = shaderType; >@@ -48,8 +47,6 @@ class Func extends Node { > get origin() { return this._origin; } > get name() { return this._name; } > get returnType() { return this._returnType; } >- get typeParameters() { return this._typeParameters; } >- get typeParametersForCallResolution() { return this.typeParameters; } > get parameters() { return this._parameters; } > get parameterTypes() { return this.parameters.map(parameter => parameter.type); } > get isCast() { return this._isCast; } >@@ -65,9 +62,9 @@ class Func extends Node { > if (this.shaderType) > result += this.shaderType + " "; > if (this.isCast) >- result += "operator<" + this.typeParameters + "> " + this.returnType; >+ result += "operator " + this.returnType; > else >- result += this.returnType + " " + this.name + "<" + this.typeParameters + ">"; >+ result += this.returnType + " " + this.name; > return result + "(" + this.parameters + ")"; > } > >diff --git a/Tools/WebGPUShadingLanguageRI/FuncDef.js b/Tools/WebGPUShadingLanguageRI/FuncDef.js >index 11fa092e3b2278e215a0a67e951e17daba136a83..ca0597fcd294dfab6044214e0754f7ef944b878e 100644 >--- a/Tools/WebGPUShadingLanguageRI/FuncDef.js >+++ b/Tools/WebGPUShadingLanguageRI/FuncDef.js >@@ -25,9 +25,9 @@ > "use strict"; > > class FuncDef extends Func { >- constructor(origin, name, returnType, typeParameters, parameters, body, isCast, shaderType) >+ constructor(origin, name, returnType, parameters, body, isCast, shaderType) > { >- super(origin, name, returnType, typeParameters, parameters, isCast, shaderType); >+ super(origin, name, returnType, parameters, isCast, shaderType); > this._body = body; > this.isRestricted = false; > } >@@ -36,8 +36,6 @@ class FuncDef extends Func { > > rewrite(rewriter) > { >- if (this._typeParameters.length) >- throw new Error("Cannot rewrite an uninstantiated function"); > this._returnType = this._returnType.visit(rewriter); > this._parameters = this._parameters.map(parameter => parameter.visit(rewriter)); > this._body = this.body.visit(rewriter); >diff --git a/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js b/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js >deleted file mode 100644 >index 892862a6dd8565ee37e420631d7af70d5227e586..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/FuncInstantiator.js >+++ /dev/null >@@ -1,154 +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"; >- >-class FuncInstantiator { >- constructor(program) >- { >- this._program = program; >- this._instances = new Map(); >- } >- >- get instances() { return this._instances; } >- >- // Returns a Func object that uniquely identifies a particular system of type arguments. You must >- // intantiate things with concrete types, because this code casually assumes this. Note that this >- // will return a different func from `func` no matter what. This ensures that we can use the >- // returned func for rewrites that instantiate types without destroying our ability to do overload >- // resolutions on the original Program. >- getUnique(func, typeArguments) >- { >- class FindTypeVariable extends Visitor { >- visitTypeRef(node) >- { >- for (let typeArgument of node.typeArguments) >- typeArgument.visit(this); >- } >- >- visitTypeVariable(node) { >- throw new Error("Unexpected type variable: " + node + " when instantiating " + func + " with arguments " + typeArguments); >- } >- } >- for (let typeArgument of typeArguments) >- typeArgument.visit(new FindTypeVariable()); >- >- let instances = this._instances.get(func); >- if (!instances) >- this._instances.set(func, instances = []); >- >- for (let instance of instances) { >- let ok = true; >- for (let i = instance.typeArguments.length; i--;) { >- if (!instance.typeArguments[i].equals(typeArguments[i])) { >- ok = false; >- break; >- } >- } >- if (!ok) >- continue; >- return instance.func; >- } >- >- let thisInstantiator = this; >- >- class InstantiationSubstitution extends Substitution { >- visitCallExpression(node) >- { >- let result = super.visitCallExpression(node); >- >- // We may have to re-resolve the function call, if it was a call to a protocol >- // signature. >- if (result.func instanceof ProtocolFuncDecl) { >- let overload = resolveOverloadImpl(result.possibleOverloads, result.typeArguments, result.argumentTypes, result.returnType); >- if (!overload.func) >- throw new Error("Could not resolve protocol signature function call during instantiation: " + result.func + (overload.failures.length ? "; tried:\n" + overload.failures.join("\n") : "")); >- result.resolveToOverload(overload); >- } >- >- if (result.func.isNative) >- result.nativeFuncInstance = thisInstantiator.getUnique(result.func, result.actualTypeArguments); >- >- return result; >- } >- } >- >- let substitution = new InstantiationSubstitution(func.typeParameters, typeArguments); >- >- class InstantiationInstantiateImmediates extends InstantiateImmediates { >- visitCallExpression(node) >- { >- // We need to preserve certain things that would have instantiated, but that we cannot >- // instantiate without breaking chain-instantiations (generic function calls generic >- // function so therefore the instantiated generic function must still have the original >- // (uninstantiated) types to instantiate the generic function that it calls). >- let result = new CallExpression( >- node.origin, node.name, node.typeArguments, >- node.argumentList.map(argument => Node.visit(argument, this))); >- result = this.processDerivedCallData(node, result); >- >- result.argumentTypes = Array.from(node.argumentTypes); >- if (node.isCast) >- result.setCastData(node.returnType); >- result.actualTypeArguments = Array.from(node.actualTypeArguments); >- >- return result; >- } >- } >- >- let instantiateImmediates = new InstantiationInstantiateImmediates(); >- >- class Instantiate { >- visitFuncDef(func) >- { >- let returnType = func.returnType.visit(substitution); >- returnType = returnType.visit(instantiateImmediates); >- let parameters = func.parameters.map(parameter => parameter.visit(substitution)); >- parameters = parameters.map(parameter => parameter.visit(instantiateImmediates)); >- let body = func.body.visit(substitution); >- body = body.visit(instantiateImmediates); >- return new FuncDef( >- func.origin, func.name, returnType, [], parameters, body, func.isCast, >- func.shaderType); >- } >- >- visitNativeFunc(func) >- { >- return new NativeFuncInstance( >- func, >- func.returnType.visit(substitution).visit(instantiateImmediates), >- func.parameters.map(parameter => parameter.visit(substitution).visit(instantiateImmediates)), >- func.isCast, >- func.shaderType, >- func.instantiateImplementation(substitution)); >- } >- } >- let resultingFunc = func.visit(new Instantiate()); >- resultingFunc.uninstantiatedReturnType = func.returnType.visit(substitution); >- let instance = {func: resultingFunc, typeArguments}; >- instances.push(instance); >- return resultingFunc; >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js b/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >index 446b351da5715c68a35d7697969d698ec73e74f8..09a7e8f6875096d59c78abf204eb2943781c3db0 100644 >--- a/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >+++ b/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >@@ -24,19 +24,11 @@ > */ > "use strict"; > >-function inferTypesForCall(func, typeArguments, argumentTypes, returnType) >+function inferTypesForCall(func, argumentTypes, returnType) > { >- if (typeArguments.length && typeArguments.length != func.typeParameters.length) >- return {failure: new OverloadResolutionFailure(func, "Wrong number of type arguments (passed " + typeArguments.length + ", require " + func.typeParameters.length + ")")}; > if (argumentTypes.length != func.parameters.length) > return {failure: new OverloadResolutionFailure(func, "Wrong number of arguments (passed " + argumentTypes.length + ", require " + func.parameters.length + ")")}; > let unificationContext = new UnificationContext(func.typeParametersForCallResolution); >- for (let i = 0; i < typeArguments.length; ++i) { >- let argument = typeArguments[i]; >- let parameter = func.typeParameters[i]; >- if (!argument.unify(unificationContext, parameter)) >- return {failure: new OverloadResolutionFailure(func, "Type argument #" + (i + 1) + " for parameter " + parameter.name + " does not match (passed " + argument + ", require " + parameter + ")")}; >- } > for (let i = 0; i < argumentTypes.length; ++i) { > if (!argumentTypes[i]) > throw new Error("Null argument type at i = " + i); >@@ -48,16 +40,6 @@ function inferTypesForCall(func, typeArguments, argumentTypes, returnType) > let verificationResult = unificationContext.verify(); > if (!verificationResult.result) > return {failure: new OverloadResolutionFailure(func, verificationResult.reason)}; >- let shouldBuildTypeArguments = !typeArguments.length; >- if (shouldBuildTypeArguments) >- typeArguments = []; >- for (let typeParameter of func.typeParameters) { >- let typeArgument = unificationContext.find(typeParameter); >- if (typeArgument == typeParameter) >- return {failure: new OverloadResolutionFailure(func, "Type parameter " + typeParameter + " did not get assigned a type")}; >- if (shouldBuildTypeArguments) >- typeArguments.push(typeArgument); >- } >- return {func, unificationContext, typeArguments}; >+ return {func, unificationContext}; > } > >diff --git a/Tools/WebGPUShadingLanguageRI/Inline.js b/Tools/WebGPUShadingLanguageRI/Inline.js >index f02873bd273d910b3df04fd2a51a3c7c0a467cef..8405e3cabadd53e40e5e8b59fb0ef5273847b6d0 100644 >--- a/Tools/WebGPUShadingLanguageRI/Inline.js >+++ b/Tools/WebGPUShadingLanguageRI/Inline.js >@@ -29,7 +29,6 @@ function inline(program) > for (let funcList of program.functions.values()) { > for (let func of funcList) { > if (!func.typeParameters.length) { >- func = program.funcInstantiator.getUnique(func, []) > _inlineFunction(program, func, new VisitingSet(func)); > } > } >@@ -55,14 +54,14 @@ function _inlineFunction(program, func, visiting) > func.inlined = true; > } > >-function resolveInlinedFunction(program, name, typeArguments, argumentTypes, allowEntryPoint = false) >+function resolveInlinedFunction(program, name, argumentTypes, allowEntryPoint = false) > { >- let overload = program.globalNameContext.resolveFuncOverload(name, typeArguments, argumentTypes, undefined, allowEntryPoint); >+ let overload = program.globalNameContext.resolveFuncOverload(name, argumentTypes, undefined, allowEntryPoint); > if (!overload.func) > return overload.failures; > if (!overload.func.typeParameters) > return overload.func; >- let func = program.funcInstantiator.getUnique(overload.func, overload.typeArguments); >+ let func = overload.func; > _inlineFunction(program, func, new VisitingSet(overload.func)); > return func; > } >diff --git a/Tools/WebGPUShadingLanguageRI/Inliner.js b/Tools/WebGPUShadingLanguageRI/Inliner.js >index 491ef3e221fc06318ee0367a381699e5723bfe5a..d906f76dd533e6de6e35cadf40b341c01935f862 100644 >--- a/Tools/WebGPUShadingLanguageRI/Inliner.js >+++ b/Tools/WebGPUShadingLanguageRI/Inliner.js >@@ -38,7 +38,7 @@ class Inliner extends Rewriter { > if (result.nativeFuncInstance) > return result; > return this._visiting.doVisit(node.func, () => { >- let func = this._program.funcInstantiator.getUnique(result.func, result.actualTypeArguments); >+ let func = result.func; > if (func.isNative) > throw new Error("Unexpected native func: " + func); > _inlineFunction(this._program, func, this._visiting); >diff --git a/Tools/WebGPUShadingLanguageRI/InstantiateImmediates.js b/Tools/WebGPUShadingLanguageRI/InstantiateImmediates.js >deleted file mode 100644 >index 2b39ed6638141348abc127696b6ee31e0b0c58b6..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/InstantiateImmediates.js >+++ /dev/null >@@ -1,44 +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"; >- >-class InstantiateImmediates extends Rewriter { >- visitTypeRef(node) >- { >- node = super.visitTypeRef(node); >- if (!node.type.instantiate) { >- if (node.typeArguments.length) >- throw new Error("type does not support instantiation: " + type + " (" + type.constructor.name + ")"); >- return node; >- } >- return node.type.instantiate(node.typeArguments).visit(new AutoWrapper()); >- } >- >- visitReferenceType(node) >- { >- return node; >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/Intrinsics.js b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >index 933dfe011302b0fbc8344994a1a5c1f77c052a6f..093283cce031e1d4e1ff6aa54bd905ec2993c897 100644 >--- a/Tools/WebGPUShadingLanguageRI/Intrinsics.js >+++ b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >@@ -499,33 +499,6 @@ class Intrinsics { > func.implementation = ([left, right]) => > EPtr.box(left.loadValue() >= right.loadValue()); > }); >- >- for (let addressSpace of addressSpaces) { >- this._map.set( >- `native T* ${addressSpace} operator&[]<T>(T[] ${addressSpace},uint)`, >- func => { >- func.implementation = ([ref, index], node) => { >- ref = ref.loadValue(); >- if (!ref) >- throw new WTrapError(node.origin.originString, "Null dereference"); >- index = index.loadValue(); >- if (index > ref.length) >- throw new WTrapError(node.origin.originString, "Array index " + index + " is out of bounds of " + ref); >- return EPtr.box(ref.ptr.plus(index * node.instantiatedActualTypeArguments[0].size)); >- }; >- }); >- >- this._map.set( >- `native uint operator.length<T>(T[] ${addressSpace})`, >- func => { >- func.implementation = ([ref], node) => { >- ref = ref.loadValue(); >- if (!ref) >- return EPtr.box(0); >- return EPtr.box(ref.length); >- }; >- }); >- } > > for (let swizzle of SwizzleOp.allSwizzleOperators()) { > this._map.set(swizzle.toString(), >diff --git a/Tools/WebGPUShadingLanguageRI/NameContext.js b/Tools/WebGPUShadingLanguageRI/NameContext.js >index c31bc428294430bd4527796f4d7a9960539f6188..afcce71234f5aacdef3e3aedd217d68d35f7b107 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameContext.js >+++ b/Tools/WebGPUShadingLanguageRI/NameContext.js >@@ -104,13 +104,13 @@ class NameContext { > yield thing; > } > >- resolveFuncOverload(name, typeArguments, argumentTypes, returnType, allowEntryPoint = false) >+ resolveFuncOverload(name, argumentTypes, returnType, allowEntryPoint = false) > { > let functions = this.get(Func, name); > if (!functions) > return {failures: []}; > >- return resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType, allowEntryPoint); >+ return resolveOverloadImpl(functions, argumentTypes, returnType, allowEntryPoint); > } > > get currentStatement() >diff --git a/Tools/WebGPUShadingLanguageRI/NameFinder.js b/Tools/WebGPUShadingLanguageRI/NameFinder.js >index fc2fdbd032527ccc54cad71ba576b99221ee9c7d..43e471aac61ada43f74c7f0832f73e80caa3b4e5 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameFinder.js >+++ b/Tools/WebGPUShadingLanguageRI/NameFinder.js >@@ -43,12 +43,6 @@ class NameFinder extends Visitor { > this._worklist.push(name); > } > >- visitProtocolRef(node) >- { >- this.add(node.name); >- super.visitProtocolRef(node); >- } >- > visitTypeRef(node) > { > this.add(node.name); >diff --git a/Tools/WebGPUShadingLanguageRI/NameResolver.js b/Tools/WebGPUShadingLanguageRI/NameResolver.js >index 731964fc78221ae73118981252232503bcfabc30..44abf0900be9e394cc42b198b5865751ad3f8b13 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/NameResolver.js >@@ -115,34 +115,6 @@ class NameResolver extends Visitor { > node.body.visit(newResolver); > } > >- visitProtocolDecl(node) >- { >- for (let parent of node.extends) >- parent.visit(this); >- let nameContext = new NameContext(this._nameContext); >- nameContext.add(node.typeVariable); >- let checker = new NameResolver(nameContext); >- for (let signature of node.signatures) >- signature.visit(checker); >- } >- >- visitProtocolRef(node) >- { >- let result = this._nameContext.get(Protocol, node.name); >- if (!result) >- throw new WTypeError(node.origin.originString, "Could not find protocol named " + node.name); >- node.protocolDecl = result; >- } >- >- visitProtocolFuncDecl(node) >- { >- this.visitFunc(node); >- let funcs = this._nameContext.get(Func, node.name); >- if (!funcs) >- throw new WTypeError(node.origin.originString, "Cannot find any functions named " + node.name); >- node.possibleOverloads = funcs; >- } >- > visitTypeDef(node) > { > let nameContext = new NameContext(this._nameContext); >@@ -177,7 +149,7 @@ class NameResolver extends Visitor { > if (thing instanceof Value) > typeArguments[i] = new VariableRef(typeArgument.origin, typeArgument.name); > else if (thing instanceof Type) >- typeArguments[i] = new TypeRef(typeArgument.origin, typeArgument.name, []); >+ typeArguments[i] = new TypeRef(typeArgument.origin, typeArgument.name); > else > throw new WTypeError(typeArgument.origin.originString, "Type argument resolved to wrong kind of thing: " + thing.kind); > } >@@ -203,12 +175,9 @@ class NameResolver extends Visitor { > if (type.typeParameters.length != node.typeArguments.length) > throw new WTypeError(node.origin.originString, "Wrong number of type arguments (passed " + node.typeArguments.length + ", expected " + type.typeParameters.length + ")"); > for (let i = 0; i < type.typeParameters.length; ++i) { >- let parameterIsType = type.typeParameters[i] instanceof TypeVariable; > let argumentIsType = node.typeArguments[i] instanceof Type; > node.typeArguments[i].visit(this); >- if (parameterIsType && !argumentIsType) >- throw new WTypeError(node.origin.originString, "Expected type, but got value at argument #" + i); >- if (!parameterIsType && argumentIsType) >+ if (argumentIsType) > throw new WTypeError(node.origin.originString, "Expected value, but got type at argument #" + i); > } > } >diff --git a/Tools/WebGPUShadingLanguageRI/NativeFunc.js b/Tools/WebGPUShadingLanguageRI/NativeFunc.js >index a553352d9aee60bca62ad6e123288b8905182487..dc0ff781b692e184627864850ef68dd35b9a8f05 100644 >--- a/Tools/WebGPUShadingLanguageRI/NativeFunc.js >+++ b/Tools/WebGPUShadingLanguageRI/NativeFunc.js >@@ -25,13 +25,12 @@ > "use strict"; > > class NativeFunc extends Func { >- constructor(origin, name, returnType, typeParameters, parameters, isCast, shaderType) >+ constructor(origin, name, returnType, parameters, isCast, shaderType) > { >- super(origin, name, returnType, typeParameters, parameters, isCast, shaderType); >+ super(origin, name, returnType, parameters, isCast, shaderType); > this.isRestricted = false; > this.implementation = null; > this._implementationData = null; >- this.instantiateImplementation = (substitution) => {}; > this.visitImplementationData = (implementationData, visitor) => null; > this.didLayoutStructsInImplementationData = implementationData => null; > } >diff --git a/Tools/WebGPUShadingLanguageRI/NativeType.js b/Tools/WebGPUShadingLanguageRI/NativeType.js >index b8b1a47330b5fd51ff021af06586844c2acba8ea..20eb590d0c33719b82f15b5dfd14d833e4cdf0db 100644 >--- a/Tools/WebGPUShadingLanguageRI/NativeType.js >+++ b/Tools/WebGPUShadingLanguageRI/NativeType.js >@@ -25,14 +25,14 @@ > "use strict"; > > class NativeType extends Type { >- constructor(origin, name, typeParameters) >+ constructor(origin, name, typeArguments) > { > if (!(typeParameters instanceof Array)) > throw new Error("type parameters not array: " + typeParameters); > super(); > this._origin = origin; > this._name = name; >- this._typeParameters = typeParameters; >+ this._typeArguments = typeArguments; > this._isNumber = false; > this._isInt = false; > this._isFloating = false; >@@ -41,7 +41,7 @@ class NativeType extends Type { > > get origin() { return this._origin; } > get name() { return this._name; } >- get typeParameters() { return this._typeParameters; } >+ get typeArguments() { return this._typeArguments; } > get isNative() { return true; } > > // We let Intrinsics.js set these as it likes. >@@ -54,15 +54,6 @@ class NativeType extends Type { > get isPrimitive() { return this._isPrimitive; } > set isPrimitive(value) { this._isPrimitive = value; } > >- instantiate(typeArguments) >- { >- if (typeArguments.length != this.typeParameters.length) >- throw new Error("Wrong number of type arguments to instantiation"); >- if (!typeArguments.length) >- return this; >- return new NativeTypeInstance(this, typeArguments); >- } >- > toString() > { > return "native typedef " + this.name + "<" + this.typeParameters + ">"; >diff --git a/Tools/WebGPUShadingLanguageRI/Parse.js b/Tools/WebGPUShadingLanguageRI/Parse.js >index 6d2b431615601ab9dd3d0938fbfb385ee2a4daf1..fbee1d71a94b7fe834f06180e0bd51707613a2b8 100644 >--- a/Tools/WebGPUShadingLanguageRI/Parse.js >+++ b/Tools/WebGPUShadingLanguageRI/Parse.js >@@ -121,12 +121,6 @@ function parse(program, origin, originKind, lineNumberOffset, text) > return result; > } > >- function parseProtocolRef() >- { >- let protocolToken = consumeKind("identifier"); >- return new ProtocolRef(protocolToken, protocolToken.text); >- } >- > function consumeEndOfTypeArgs() > { > let rightShift = tryConsume(">>"); >@@ -136,34 +130,6 @@ function parse(program, origin, originKind, lineNumberOffset, text) > consume(">"); > } > >- function parseTypeParameters() >- { >- if (!test("<")) >- return []; >- >- let result = []; >- consume("<"); >- while (!test(">")) { >- let constexpr = lexer.backtrackingScope(() => { >- let type = parseType(); >- let name = consumeKind("identifier"); >- assertNext(",", ">", ">>"); >- return new ConstexprTypeParameter(type.origin, name.text, type); >- }); >- if (constexpr) >- result.push(constexpr); >- else { >- let name = consumeKind("identifier"); >- let protocol = tryConsume(":") ? parseProtocolRef() : null; >- result.push(new TypeVariable(name, name.text, protocol)); >- } >- if (!tryConsume(",")) >- break; >- } >- consumeEndOfTypeArgs(); >- return result; >- } >- > function parseTerm() > { > let token; >@@ -222,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); >@@ -282,8 +248,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > addressSpace = token.text; > > let name = consumeKind("identifier"); >- let typeArguments = parseTypeArguments(); >- let type = new TypeRef(name, name.text, typeArguments); >+ let type = new TypeRef(name, name.text); > > function getAddressSpace() > { >@@ -318,11 +283,10 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > let origin = consume("typedef"); > let name = consumeKind("identifier").text; >- let typeParameters = parseTypeParameters(); > consume("="); > let type = parseType(); > consume(";"); >- return new TypeDef(origin, name, typeParameters, type); >+ return new TypeDef(origin, name, type); > } > > function genericParseLeft(texts, nextParser, constructor) >@@ -339,13 +303,12 @@ 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(")")) { >@@ -355,7 +318,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > break; > } > consume(")"); >- let result = new CallExpression(name, name.text, typeArguments, argumentList); >+ let result = new CallExpression(name, name.text, argumentList); > return result; > } > >@@ -363,7 +326,6 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > return lexer.testScope(() => { > consumeKind("identifier"); >- parseTypeArguments(); > consume("("); > }); > } >@@ -381,7 +343,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) >@@ -454,7 +416,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("&")) >@@ -463,7 +425,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(); > } >@@ -493,7 +455,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; >@@ -519,7 +481,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() >@@ -656,7 +618,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() >@@ -666,7 +628,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() >@@ -687,7 +649,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(")")) >@@ -708,7 +670,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() >@@ -858,13 +820,11 @@ function parse(program, origin, originKind, lineNumberOffset, text) > let origin; > let returnType; > let name; >- let typeParameters; > let isCast; > let shaderType; > let operatorToken = tryConsume("operator"); > if (operatorToken) { > origin = operatorToken; >- typeParameters = parseTypeParameters(); > returnType = parseType(); > name = "operator cast"; > isCast = true; >@@ -877,44 +837,17 @@ function parse(program, origin, originKind, lineNumberOffset, text) > } else > origin = returnType.origin; > name = parseFuncName(); >- typeParameters = parseTypeParameters(); > isCast = false; > } > let parameters = parseParameters(); >- return new Func(origin, name, returnType, typeParameters, parameters, isCast, shaderType); >+ return new Func(origin, name, returnType, parameters, isCast, shaderType); > } > >- function parseProtocolFuncDecl() >- { >- let func = parseFuncDecl(); >- return new ProtocolFuncDecl(func.origin, func.name, func.returnType, func.typeParameters, func.parameters, func.isCast, func.shaderType); >- } >- > function parseFuncDef() > { > let func = parseFuncDecl(); > let body = parseBlock(); >- return new FuncDef(func.origin, func.name, func.returnType, func.typeParameters, func.parameters, body, func.isCast, func.shaderType); >- } >- >- function parseProtocolDecl() >- { >- let origin = consume("protocol"); >- let name = consumeKind("identifier").text; >- let result = new ProtocolDecl(origin, name); >- if (tryConsume(":")) { >- while (!test("{")) { >- result.addExtends(parseProtocolRef()); >- if (!tryConsume(",")) >- break; >- } >- } >- consume("{"); >- while (!tryConsume("}")) { >- result.add(parseProtocolFuncDecl()); >- consume(";"); >- } >- return result; >+ return new FuncDef(func.origin, func.name, func.returnType, func.parameters, body, func.isCast, func.shaderType); > } > > function parseField() >@@ -929,8 +862,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > let origin = consume("struct"); > let name = consumeKind("identifier").text; >- let typeParameters = parseTypeParameters(); >- let result = new StructType(origin, name, typeParameters); >+ let result = new StructType(origin, name); > consume("{"); > while (!tryConsume("}")) > result.add(parseField()); >@@ -941,7 +873,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > { > let func = parseFuncDecl(); > consume(";"); >- return new NativeFunc(func.origin, func.name, func.returnType, func.typeParameters, func.parameters, func.isCast, func.shaderType); >+ return new NativeFunc(func.origin, func.name, func.returnType, func.parameters, func.isCast, func.shaderType); > } > > function parseNative() >@@ -949,9 +881,9 @@ function parse(program, origin, originKind, lineNumberOffset, text) > let origin = consume("native"); > if (tryConsume("typedef")) { > let name = consumeKind("identifier"); >- let parameters = parseTypeParameters(); >+ let arguments = parseTypeArguments(); > consume(";"); >- return new NativeType(origin, name.text, parameters); >+ return new NativeType(origin, name.text, arguments); > } > return parseNativeFunc(); > } >@@ -985,7 +917,7 @@ function parse(program, origin, originKind, lineNumberOffset, text) > if (tryConsume(":")) > baseType = parseType(); > else >- baseType = new TypeRef(name, "int", []); >+ baseType = new TypeRef(name, "int"); > consume("{"); > let result = new EnumType(name, name.text, baseType); > while (!test("}")) { >@@ -1013,8 +945,6 @@ function parse(program, origin, originKind, lineNumberOffset, text) > program.add(parseStructType()); > else if (token.text == "enum") > program.add(parseEnumType()); >- else if (token.text == "protocol") >- program.add(parseProtocolDecl()); > else > program.add(parseFuncDef()); > } >diff --git a/Tools/WebGPUShadingLanguageRI/Prepare.js b/Tools/WebGPUShadingLanguageRI/Prepare.js >index a2048a9ad3e83bd18b76444ca5546e48fe0119a0..e7c3f236604f8ba087ac1e66f58d678601c576c6 100644 >--- a/Tools/WebGPUShadingLanguageRI/Prepare.js >+++ b/Tools/WebGPUShadingLanguageRI/Prepare.js >@@ -42,16 +42,13 @@ let prepare = (() => { > foldConstexprs(program); > let nameResolver = createNameResolver(program); > resolveNamesInTypes(program, nameResolver); >- resolveNamesInProtocols(program, nameResolver); > resolveTypeDefsInTypes(program); >- resolveTypeDefsInProtocols(program); > checkRecursiveTypes(program); > synthesizeStructAccessors(program); > synthesizeEnumFunctions(program); > resolveNamesInFunctions(program, nameResolver); > resolveTypeDefsInFunctions(program); >- >- flattenProtocolExtends(program); >+ > check(program); > checkLiteralTypes(program); > resolveProperties(program); >diff --git a/Tools/WebGPUShadingLanguageRI/Program.js b/Tools/WebGPUShadingLanguageRI/Program.js >index bbc4b24a6227b1ce5b06d733ac20d92b596a4c73..8fc6f793ee6e73eeca5a6aa74a440a67b86be6fa 100644 >--- a/Tools/WebGPUShadingLanguageRI/Program.js >+++ b/Tools/WebGPUShadingLanguageRI/Program.js >@@ -31,8 +31,6 @@ class Program extends Node { > this._topLevelStatements = []; > this._functions = new Map(); > this._types = new Map(); >- this._protocols = new Map(); >- this._funcInstantiator = new FuncInstantiator(this); > this._globalNameContext = new NameContext(); > this._globalNameContext.program = this; > this._globalNameContext.recognizeIntrinsics(); >@@ -42,8 +40,6 @@ class Program extends Node { > get topLevelStatements() { return this._topLevelStatements; } > get functions() { return this._functions; } > get types() { return this._types; } >- get protocols() { return this._protocols; } >- get funcInstantiator() { return this._funcInstantiator; } > get globalNameContext() { return this._globalNameContext; } > > add(statement) >@@ -56,8 +52,6 @@ class Program extends Node { > array.push(statement); > } else if (statement instanceof Type) > this._types.set(statement.name, statement); >- else if (statement instanceof Protocol) >- this._protocols.set(statement.name, statement); > else > throw new Error("Statement is not a function or type: " + statement); > this._topLevelStatements.push(statement); >diff --git a/Tools/WebGPUShadingLanguageRI/Protocol.js b/Tools/WebGPUShadingLanguageRI/Protocol.js >deleted file mode 100644 >index 33f8456477eca2e8dcf66cf45c2d473ca0857d88..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/Protocol.js >+++ /dev/null >@@ -1,43 +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"; >- >-class Protocol extends Node { >- constructor(origin, name) >- { >- super(); >- this._origin = origin; >- this._name = name; >- } >- >- get origin() { return this._origin; } >- get name() { return this._name; } >- get kind() { return Protocol; } >- >- toString() >- { >- return this.name; >- } >-} >diff --git a/Tools/WebGPUShadingLanguageRI/ProtocolDecl.js b/Tools/WebGPUShadingLanguageRI/ProtocolDecl.js >deleted file mode 100644 >index b50bcfcf33ba7395c56d952a579d09927b0be767..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/ProtocolDecl.js >+++ /dev/null >@@ -1,119 +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"; >- >-class ProtocolDecl extends Protocol { >- constructor(origin, name) >- { >- super(origin, name); >- this.extends = []; >- this._signatures = []; >- this._signatureMap = new Map(); >- this._typeVariable = new TypeVariable(origin, name, null); >- } >- >- addExtends(protocol) >- { >- this.extends.push(protocol); >- } >- >- add(signature) >- { >- if (!(signature instanceof ProtocolFuncDecl)) >- throw new Error("Signature isn't a ProtocolFuncDecl but a " + signature.constructor.name); >- >- signature.protocolDecl = this; >- this._signatures.push(signature); >- let overloads = this._signatureMap.get(signature.name); >- if (!overloads) >- this._signatureMap.set(signature.name, overloads = []); >- overloads.push(signature); >- } >- >- get signatures() { return this._signatures; } >- signaturesByName(name) { return this._signatureMap.get(name); } >- get typeVariable() { return this._typeVariable; } >- >- signaturesByNameWithTypeVariable(name, typeVariable) >- { >- let substitution = new Substitution([this.typeVariable], [typeVariable]); >- let result = this.signaturesByName(name); >- if (!result) >- return null; >- return result.map(signature => signature.visit(substitution)); >- } >- >- inherits(otherProtocol) >- { >- if (!otherProtocol) >- return {result: true}; >- >- if (otherProtocol instanceof ProtocolRef) >- otherProtocol = otherProtocol.protocolDecl; >- >- for (let otherSignature of otherProtocol.signatures) { >- let signatures = this.signaturesByName(otherSignature.name); >- if (!signatures) >- return {result: false, reason: "Protocol " + this.name + " does not have a function named " + otherSignature.name + " (looking at signature " + otherSignature + ")"}; >- let overload = resolveOverloadImpl( >- signatures, [], >- otherSignature.parameterTypes, >- otherSignature.returnTypeForOverloadResolution); >- if (!overload.func) >- return {result: false, reason: "Did not find matching signature for " + otherSignature + " in " + this.name + (overload.failures.length ? " (tried: " + overload.failures.join("; ") + ")" : "")}; >- let substitutedReturnType = >- overload.func.returnType.substituteToUnification( >- overload.func.typeParameters, overload.unificationContext); >- if (!substitutedReturnType.equals(otherSignature.returnType)) >- return {result: false, reason: "Return type mismatch between " + otherSignature.returnType + " and " + substitutedReturnType}; >- } >- return {result: true}; >- } >- >- hasHeir(type) >- { >- let substitution = new Substitution([this._typeVariable], [type]); >- let signatures = this.signatures; >- for (let originalSignature of signatures) { >- let signature = originalSignature.visit(substitution); >- let overload = resolveOverloadImpl(signature.possibleOverloads, signature.typeParameters, signature.parameterTypes, signature.returnTypeForOverloadResolution); >- if (!overload.func) >- return {result: false, reason: "Did not find matching signature for " + originalSignature + " (at " + originalSignature.origin.originString + ") with type " + type + (overload.failures.length ? " (tried: " + overload.failures.join("; ") + ")" : "")}; >- >- let substitutedReturnType = overload.func.returnType.substituteToUnification( >- overload.func.typeParameters, overload.unificationContext); >- if (!substitutedReturnType.equals(signature.returnType)) >- return {result: false, reason: "At signature " + originalSignature + " (at " + originalSignature.origin.originString + "): return type mismatch between " + signature.returnType + " and " + substitutedReturnType + " in found function " + overload.func.toDeclString()}; >- } >- return {result: true}; >- } >- >- toString() >- { >- return "protocol " + this.name + " { " + this.signatures.join("; ") + "; }"; >- } >-} >- >- >diff --git a/Tools/WebGPUShadingLanguageRI/ProtocolFuncDecl.js b/Tools/WebGPUShadingLanguageRI/ProtocolFuncDecl.js >deleted file mode 100644 >index 89b5c9b8e7161868a1ce45d58866392c022244d3..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/ProtocolFuncDecl.js >+++ /dev/null >@@ -1,33 +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"; >- >-class ProtocolFuncDecl extends Func { >- get typeParametersForCallResolution() >- { >- return this.typeParameters.concat(this.protocolDecl.typeVariable); >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/ProtocolRef.js b/Tools/WebGPUShadingLanguageRI/ProtocolRef.js >deleted file mode 100644 >index d3c0ea30d748d8b9e16107a9f808c23b32865e64..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/ProtocolRef.js >+++ /dev/null >@@ -1,48 +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"; >- >-class ProtocolRef extends Protocol { >- constructor(origin, name) >- { >- super(origin, name); >- this.protocolDecl = null; >- } >- >- inherits(other) >- { >- return this.protocolDecl.inherits(other); >- } >- >- hasHeir(type) >- { >- return this.protocolDecl.hasHeir(type); >- } >- >- get isPrimitive() >- { >- return this.protocolDecl.isPrimitive; >- } >-} >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveNames.js b/Tools/WebGPUShadingLanguageRI/ResolveNames.js >index 1922e8ec27fc39d95b4aa8bfa9a56c910f6e68b2..49dc8637d4e143a9b07d59cf3fb975cf84a65e16 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveNames.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveNames.js >@@ -35,12 +35,6 @@ function resolveNamesInTypes(program, nameResolver) > nameResolver.doStatement(type); > } > >-function resolveNamesInProtocols(program, nameResolver) >-{ >- for (let protocol of program.protocols.values()) >- nameResolver.doStatement(protocol); >-} >- > function resolveNamesInFunctions(program, nameResolver) > { > for (let funcs of program.functions.values()) { >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js b/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >index 7e22156de1ac5e2a6c724ad3469dc91e746f2566..d54b94d36cdb0b068299626af0565a82ba7775c7 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >@@ -24,7 +24,7 @@ > */ > "use strict"; > >-function resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType, allowEntryPoint = false) >+function resolveOverloadImpl(functions, argumentTypes, returnType, allowEntryPoint = false) > { > if (!functions) > throw new Error("Null functions; that should have been caught by the caller."); >@@ -36,7 +36,7 @@ function resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType > failures.push(new OverloadResolutionFailure(func, "Function is a " + func.shaderType + " shader, so it cannot be called from within an existing shader.")) > continue; > } >- let overload = inferTypesForCall(func, typeArguments, argumentTypes, returnType); >+ let overload = inferTypesForCall(func, argumentTypes, returnType); > if (overload.failure) > failures.push(overload.failure); > else >@@ -74,7 +74,6 @@ function resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType > let parameterFunc = successes[j].func; > let overload = inferTypesForCall( > parameterFunc, >- typeArguments.length ? argumentFunc.typeParameters : [], > argumentFunc.parameterTypes, > argumentFunc.returnTypeForOverloadResolution); > if (!overload.func) { >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js b/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >index 3bd2a4d65f564f708b0ef4759e43b2c88d48c234..e87bdc3c348319952ff9d8f0399f348ea950d60e 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >@@ -31,13 +31,6 @@ function resolveTypeDefsInTypes(program) > type.visit(resolver); > } > >-function resolveTypeDefsInProtocols(program) >-{ >- let resolver = new TypeDefResolver(); >- for (let protocol of program.protocols.values()) >- protocol.visit(resolver); >-} >- > function resolveTypeDefsInFunctions(program) > { > let resolver = new TypeDefResolver(); >diff --git a/Tools/WebGPUShadingLanguageRI/Rewriter.js b/Tools/WebGPUShadingLanguageRI/Rewriter.js >index f40d6b88b26eedcbf829f1babb10a2045b7a8e83..79fbc7997b3ca4fbd85bbc6ddd6e8dd5d4a9c5ad 100644 >--- a/Tools/WebGPUShadingLanguageRI/Rewriter.js >+++ b/Tools/WebGPUShadingLanguageRI/Rewriter.js >@@ -57,30 +57,8 @@ class Rewriter { > visitNativeType(node) { return node; } > visitTypeDef(node) { return node; } > visitStructType(node) { return node; } >- visitConstexprTypeParameter(node) { return node; } >- visitProtocolDecl(node) { return node; } > visitEnumType(node) { return node; } > >- // This is almost wrong. We instantiate Func in Substitution in ProtocolDecl. Then, we end up >- // not rewriting type variables. I think that just works because not rewriting them there is OK. >- // Everywhere else, it's mandatory that we don't rewrite these because we always assume that >- // type variables are outside the scope of rewriting. >- visitTypeVariable(node) { return node; } >- >- visitProtocolFuncDecl(node) >- { >- let result = new ProtocolFuncDecl( >- node.origin, node.name, >- node.returnType.visit(this), >- node.typeParameters.map(parameter => parameter.visit(this)), >- node.parameters.map(parameter => parameter.visit(this)), >- node.isCast, >- node.shaderType); >- result.protocolDecl = node.protocolDecl; >- result.possibleOverloads = node.possibleOverloads; >- return result; >- } >- > visitNativeTypeInstance(node) > { > return new NativeTypeInstance( >@@ -125,14 +103,9 @@ class Rewriter { > })); > } > >- visitProtocolRef(node) >- { >- return node; >- } >- > visitTypeRef(node) > { >- let result = new TypeRef(node.origin, node.name, node.typeArguments.map(typeArgument => typeArgument.visit(this))); >+ let result = new TypeRef(node.origin, node.name); > result.type = Node.visit(node.type, this); > return result; > } >@@ -317,14 +290,6 @@ class Rewriter { > > processDerivedCallData(node, result) > { >- let handleTypeArguments = actualTypeArguments => { >- if (actualTypeArguments) >- return actualTypeArguments.map(actualTypeArgument => actualTypeArgument.visit(this)); >- else >- return null; >- } >- result.actualTypeArguments = handleTypeArguments(node.actualTypeArguments); >- result.instantiatedActualTypeArguments = handleTypeArguments(node.instantiatedActualTypeArguments); > let argumentTypes = node.argumentTypes; > if (argumentTypes) > result.argumentTypes = argumentTypes.map(argumentType => argumentType.visit(this)); >@@ -342,7 +307,6 @@ class Rewriter { > { > let result = new CallExpression( > node.origin, node.name, >- node.typeArguments.map(typeArgument => typeArgument.visit(this)), > node.argumentList.map(argument => Node.visit(argument, this))); > return this.processDerivedCallData(node, result); > } >diff --git a/Tools/WebGPUShadingLanguageRI/SPIRV.html b/Tools/WebGPUShadingLanguageRI/SPIRV.html >index 93f6b9b932d272d77a3dc3167f525fa40a61ed23..b636e92ccf0101a48990dcd0a9f0bee9f26e2087 100644 >--- a/Tools/WebGPUShadingLanguageRI/SPIRV.html >+++ b/Tools/WebGPUShadingLanguageRI/SPIRV.html >@@ -42,7 +42,6 @@ td { > <script src="CloneProgram.js"></script> > <script src="CommaExpression.js"></script> > <script src="ConstexprFolder.js"></script> >- <script src="ConstexprTypeParameter.js"></script> > <script src="Continue.js"></script> > <script src="ConvertPtrToArrayRefExpression.js"></script> > <script src="DoWhileLoop.js"></script> >@@ -61,7 +60,6 @@ td { > <script src="ExternalOrigin.js"></script> > <script src="Field.js"></script> > <script src="FindHighZombies.js"></script> >- <script src="FlattenProtocolExtends.js"></script> > <script src="FlattenedStructOffsetGatherer.js"></script> > <script src="FloatLiteral.js"></script> > <script src="FloatLiteralType.js"></script> >@@ -79,7 +77,6 @@ td { > <script src="InferTypesForCall.js"></script> > <script src="Inline.js"></script> > <script src="Inliner.js"></script> >- <script src="InstantiateImmediates.js"></script> > <script src="IntLiteral.js"></script> > <script src="IntLiteralType.js"></script> > <script src="Intrinsics.js"></script> >@@ -109,10 +106,6 @@ td { > <script src="PropertyResolver.js"></script> > <script src="Program.js"></script> > <script src="ProgramWithUnnecessaryThingsRemoved.js"></script> >- <script src="Protocol.js"></script> >- <script src="ProtocolDecl.js"></script> >- <script src="ProtocolFuncDecl.js"></script> >- <script src="ProtocolRef.js"></script> > <script src="PtrType.js"></script> > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> >@@ -141,10 +134,7 @@ td { > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeOrVariableRef.js"></script> >- <script src="TypeParameterRewriter.js"></script> > <script src="TypeRef.js"></script> >- <script src="TypeVariable.js"></script> >- <script src="TypeVariableTracker.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script> >diff --git a/Tools/WebGPUShadingLanguageRI/SPIRVCodegen.js b/Tools/WebGPUShadingLanguageRI/SPIRVCodegen.js >index b4f50859a87afb60e54b360c6059c4aac8c23bca..a9fdeece4758668663ed1032f72b203e82052aa1 100644 >--- a/Tools/WebGPUShadingLanguageRI/SPIRVCodegen.js >+++ b/Tools/WebGPUShadingLanguageRI/SPIRVCodegen.js >@@ -53,7 +53,7 @@ function generateSPIRV(spirv, program) > typeMap.set(program.intrinsics.uint32, currentId++); > > for (let entryPoint of findEntryPoints()) { >- let inlinedShader = program.funcInstantiator.getUnique(entryPoint, []); >+ let inlinedShader = entryPoint; > _inlineFunction(program, inlinedShader, new VisitingSet(entryPoint)); > > let typeAnalyzer = new SPIRVTypeAnalyzer(program, typeMap, currentId); >diff --git a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >index 1988723c3548081c667fac7862f40267f9f8b857..de6c4a16368f76aea0217ca7217d51b61000737c 100644 >--- a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >+++ b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >@@ -145,14 +145,6 @@ bool operator~(bool value) > return !value; > } > >-protocol Addable { >- Addable operator+(Addable, Addable); >-} >- >-protocol Equatable { >- bool operator==(Equatable, Equatable); >-} >- > restricted operator<T> T() > { > T defaultValue; >@@ -164,11 +156,6 @@ restricted operator<T> T(T x) > return x; > } > >-operator<T:Equatable> bool(T x) >-{ >- return x != T(); >-} >- > struct vec2<T> { > T x; > T y; >@@ -186,11 +173,6 @@ operator<T> vec2<T>(T x, T y) > return result; > } > >-bool operator==<T:Equatable>(vec2<T> a, vec2<T> b) >-{ >- return a.x == b.x && a.y == b.y; >-} >- > thread T* operator&[]<T>(thread vec2<T>* foo, uint index) > { > if (index == 0) >@@ -237,11 +219,6 @@ operator<T> vec3<T>(T x, vec2<T> v2) > return result; > } > >-bool operator==<T:Equatable>(vec3<T> a, vec3<T> b) >-{ >- return a.x == b.x && a.y == b.y && a.z == b.z; >-} >- > thread T* operator&[]<T>(thread vec3<T>* foo, uint index) > { > if (index == 0) >@@ -334,11 +311,6 @@ operator<T> vec4<T>(T x, vec3<T> v3) > return result; > } > >-bool operator==<T:Equatable>(vec4<T> a, vec4<T> b) >-{ >- return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >-} >- > thread T* operator&[]<T>(thread vec4<T>* foo, uint index) > { > if (index == 0) >@@ -386,4 +358,4 @@ function intToString(x) > > // There are 481 swizzle operators, so we compile them as native functions > standardLibrary += SwizzleOp.allSwizzleOperators().join(";\n") + ";"; >-console.log(standardLibrary); >\ No newline at end of file >+console.log(standardLibrary); >diff --git a/Tools/WebGPUShadingLanguageRI/StatementCloner.js b/Tools/WebGPUShadingLanguageRI/StatementCloner.js >index c9479a285ba0e13535dea37f7fc1a63bc71cf316..64a2f0b748f3680bbba61477842c9d7f2a9346d1 100644 >--- a/Tools/WebGPUShadingLanguageRI/StatementCloner.js >+++ b/Tools/WebGPUShadingLanguageRI/StatementCloner.js >@@ -27,11 +27,9 @@ > class StatementCloner extends Rewriter { > visitFuncDef(node) > { >- let typeParameters = node.typeParameters.map(typeParameter => typeParameter.visit(this)); > let result = new FuncDef( > node.origin, node.name, > node.returnType.visit(this), >- typeParameters, > node.parameters.map(parameter => parameter.visit(this)), > node.body.visit(this), > node.isCast, node.shaderType); >@@ -44,7 +42,6 @@ class StatementCloner extends Rewriter { > let result = new NativeFunc( > node.origin, node.name, > node.returnType.visit(this), >- node.typeParameters.map(typeParameter => typeParameter.visit(this)), > node.parameters.map(parameter => parameter.visit(this)), > node.isCast, node.shaderType); > result.isRestricted = node.isRestricted; >@@ -75,31 +72,6 @@ class StatementCloner extends Rewriter { > return result; > } > >- visitConstexprTypeParameter(node) >- { >- return new ConstexprTypeParameter(node.origin, node.name, node.type.visit(this)); >- } >- >- visitProtocolDecl(node) >- { >- let result = new ProtocolDecl(node.origin, node.name); >- for (let protocol of node.extends) >- result.addExtends(protocol.visit(this)); >- for (let signature of node.signatures) >- result.add(signature.visit(this)); >- return result; >- } >- >- visitTypeVariable(node) >- { >- return new TypeVariable(node.origin, node.name, Node.visit(node.protocol, this)); >- } >- >- visitProtocolRef(node) >- { >- return new ProtocolRef(node.origin, node.name); >- } >- > visitBoolLiteral(node) > { > return new BoolLiteral(node.origin, node.value); >diff --git a/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js b/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js >index 4f98c573a1a38237e16450ae10b86cb2e61d1230..a0f5219b4e348942be2d9698046e11ac55756348 100644 >--- a/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js >+++ b/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js >@@ -76,13 +76,6 @@ class StructLayoutBuilder extends Visitor { > { > for (let argument of node.argumentList) > Node.visit(argument, this); >- let handleTypeArguments = actualTypeArguments => { >- if (actualTypeArguments) { >- for (let argument of actualTypeArguments) >- argument.visit(this); >- } >- }; >- handleTypeArguments(node.instantiatedActualTypeArguments); > Node.visit(node.nativeFuncInstance, this); > Node.visit(node.resultType, this); > } >diff --git a/Tools/WebGPUShadingLanguageRI/StructType.js b/Tools/WebGPUShadingLanguageRI/StructType.js >index f9d8c7da485832161e55d22a43876299337cb936..3947fdbac07000de80fff65fd66c6e0058a27ec1 100644 >--- a/Tools/WebGPUShadingLanguageRI/StructType.js >+++ b/Tools/WebGPUShadingLanguageRI/StructType.js >@@ -25,12 +25,11 @@ > "use strict"; > > class StructType extends Type { >- constructor(origin, name, typeParameters) >+ constructor(origin, name) > { > super(); > this._origin = origin; > this._name = name; >- this._typeParameters = typeParameters; > this._fields = new Map(); > } > >@@ -44,7 +43,6 @@ class StructType extends Type { > > get name() { return this._name; } > get origin() { return this._origin; } >- get typeParameters() { return this._typeParameters; } > > get fieldNames() { return this._fields.keys(); } > fieldByName(name) { return this._fields.get(name); } >@@ -58,32 +56,6 @@ class StructType extends Type { > return result; > } > >- instantiate(typeArguments = null) >- { >- let substitution = null; >- let typeParameters = this.typeParameters; >- >- if (typeArguments) { >- if (typeArguments.length != this.typeParameters.length) >- throw new WTypeError(this.origin.originString, "Wrong number of type arguments to instantiation"); >- >- substitution = new Substitution(this.typeParameters, typeArguments); >- typeParameters = []; >- } >- >- let instantiateImmediates = new InstantiateImmediates(); >- let result = new StructType(this.origin, this.name, typeParameters); >- for (let field of this.fields) { >- let newField = field; >- if (substitution) >- newField = newField.visit(substitution); >- newField = newField.visit(instantiateImmediates); >- result.add(newField); >- } >- >- return result; >- } >- > populateDefaultValue(buffer, offset) > { > if (this.size == null) >@@ -94,6 +66,6 @@ class StructType extends Type { > > toString() > { >- return "struct " + this.name + "<" + this.typeParameters + "> { " + Array.from(this.fields).join("; ") + "; }"; >+ return "struct " + this.name + " { " + Array.from(this.fields).join("; ") + "; }"; > } > } >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js b/Tools/WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js >index 5af2bdf93a805fc08c29f1ea0510ce29e280a56f..17b61848ab5d8bc92a7459de8d640314400179b2 100644 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js >+++ b/Tools/WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js >@@ -35,31 +35,31 @@ function synthesizeEnumFunctions(program) > let shaderType; > > nativeFunc = new NativeFunc( >- type.origin, "operator==", new TypeRef(type.origin, "bool", []), [], >+ type.origin, "operator==", new TypeRef(type.origin, "bool"), > [ >- new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name, [])), >- new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name, [])) >+ new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name)), >+ new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name)) > ], > isCast, shaderType); > nativeFunc.implementation = ([left, right]) => EPtr.box(left.loadValue() == right.loadValue()); > program.add(nativeFunc); > > nativeFunc = new NativeFunc( >- type.origin, "operator.value", type.baseType.visit(new Rewriter()), [], >- [new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name, []))], >+ type.origin, "operator.value", type.baseType.visit(new Rewriter()), >+ [new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name))], > isCast, shaderType); > nativeFunc.implementation = ([value]) => value; > program.add(nativeFunc); > > nativeFunc = new NativeFunc( >- type.origin, "operator cast", type.baseType.visit(new Rewriter()), [], >- [new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name, []))], >+ type.origin, "operator cast", type.baseType.visit(new Rewriter()), >+ [new FuncParameter(type.origin, null, new TypeRef(type.origin, type.name))], > isCast, shaderType); > nativeFunc.implementation = ([value]) => value; > program.add(nativeFunc); > > nativeFunc = new NativeFunc( >- type.origin, "operator cast", new TypeRef(type.origin, type.name, []), [], >+ type.origin, "operator cast", new TypeRef(type.origin, type.name), > [new FuncParameter(type.origin, null, type.baseType.visit(new Rewriter()))], > isCast, shaderType); > nativeFunc.implementation = ([value]) => value; >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js b/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >index f7816f2b252e9ba4da9ec84def611c55e4bfe3a9..a7987885522a79e82a20734164f152b1838c422f 100644 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >+++ b/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >@@ -31,28 +31,8 @@ function synthesizeStructAccessors(program) > continue; > > for (let field of type.fields) { >- function createTypeParameters() >- { >- return type.typeParameters.map( >- typeParameter => typeParameter.visit(new TypeParameterRewriter())); >- } >- >- function createTypeArguments() >- { >- return typeParameters.map(typeParameter => typeParameter.visit(new AutoWrapper())); >- } >- > function setupImplementationData(nativeFunc, implementation) > { >- nativeFunc.instantiateImplementation = substitution => { >- let newType = type.instantiate(nativeFunc.typeParameters.map(typeParameter => { >- let substitute = substitution.map.get(typeParameter); >- if (!substitute) >- throw new Error("Null substitute for type parameter " + typeParameter); >- return substitute; >- })); >- return {type: newType, fieldName: field.name}; >- }; > nativeFunc.visitImplementationData = (implementationData, visitor) => { > // Visiting the type first ensures that the struct layout builder figures out the field's > // offset. >@@ -94,7 +74,7 @@ function synthesizeStructAccessors(program) > > function createTypeRef() > { >- return TypeRef.instantiate(type, createTypeArguments()); >+ return TypeRef.instantiate(type); > } > > let isCast = false; >@@ -103,9 +83,8 @@ function synthesizeStructAccessors(program) > let nativeFunc; > > // The getter: operator.field >- typeParameters = createTypeParameters(); > nativeFunc = new NativeFunc( >- field.origin, "operator." + field.name, createFieldType(), typeParameters, >+ field.origin, "operator." + field.name, createFieldType(), > [new FuncParameter(field.origin, null, createTypeRef())], isCast, shaderType); > setupImplementationData(nativeFunc, ([base], offset, structSize, fieldSize) => { > let result = new EPtr(new EBuffer(fieldSize), 0); >@@ -115,9 +94,8 @@ function synthesizeStructAccessors(program) > program.add(nativeFunc); > > // The setter: operator.field= >- typeParameters = createTypeParameters(); > nativeFunc = new NativeFunc( >- field.origin, "operator." + field.name + "=", createTypeRef(), typeParameters, >+ field.origin, "operator." + field.name + "=", createTypeRef(), > [ > new FuncParameter(field.origin, null, createTypeRef()), > new FuncParameter(field.origin, null, createFieldType()) >@@ -134,10 +112,8 @@ function synthesizeStructAccessors(program) > // The ander: operator&.field > function setupAnder(addressSpace) > { >- typeParameters = createTypeParameters(); > nativeFunc = new NativeFunc( > field.origin, "operator&." + field.name, new PtrType(field.origin, addressSpace, createFieldType()), >- typeParameters, > [ > new FuncParameter( > field.origin, null, >diff --git a/Tools/WebGPUShadingLanguageRI/Test.html b/Tools/WebGPUShadingLanguageRI/Test.html >index a641d3046493dabc2d745e7d0ec96d0bdd441bbc..eb272c13705d37f0629e60015d1f8d5602d0adbf 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.html >+++ b/Tools/WebGPUShadingLanguageRI/Test.html >@@ -36,7 +36,6 @@ > <script src="CloneProgram.js"></script> > <script src="CommaExpression.js"></script> > <script src="ConstexprFolder.js"></script> >-<script src="ConstexprTypeParameter.js"></script> > <script src="Continue.js"></script> > <script src="ConvertPtrToArrayRefExpression.js"></script> > <script src="DoWhileLoop.js"></script> >@@ -55,7 +54,6 @@ > <script src="ExternalOrigin.js"></script> > <script src="Field.js"></script> > <script src="FindHighZombies.js"></script> >-<script src="FlattenProtocolExtends.js"></script> > <script src="FlattenedStructOffsetGatherer.js"></script> > <script src="FloatLiteral.js"></script> > <script src="FloatLiteralType.js"></script> >@@ -73,7 +71,6 @@ > <script src="InferTypesForCall.js"></script> > <script src="Inline.js"></script> > <script src="Inliner.js"></script> >-<script src="InstantiateImmediates.js"></script> > <script src="IntLiteral.js"></script> > <script src="IntLiteralType.js"></script> > <script src="Intrinsics.js"></script> >@@ -103,10 +100,6 @@ > <script src="PropertyResolver.js"></script> > <script src="Program.js"></script> > <script src="ProgramWithUnnecessaryThingsRemoved.js"></script> >-<script src="Protocol.js"></script> >-<script src="ProtocolDecl.js"></script> >-<script src="ProtocolFuncDecl.js"></script> >-<script src="ProtocolRef.js"></script> > <script src="PtrType.js"></script> > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> >@@ -131,10 +124,7 @@ > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeOrVariableRef.js"></script> >-<script src="TypeParameterRewriter.js"></script> > <script src="TypeRef.js"></script> >-<script src="TypeVariable.js"></script> >-<script src="TypeVariableTracker.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script> >diff --git a/Tools/WebGPUShadingLanguageRI/Test.js b/Tools/WebGPUShadingLanguageRI/Test.js >index 2b056902a66cc32d04a1ea720d251e3f70cf9648..76cca879ab2fafb10559fecf8e843315761e1759 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.js >+++ b/Tools/WebGPUShadingLanguageRI/Test.js >@@ -187,7 +187,7 @@ tests.commentParsing = function() { > runs over multiple lines */ > bool foo() { return true; } > `); >- checkBool(program, callFunction(program, "foo", [], []), true); >+ checkBool(program, callFunction(program, "foo", []), true); > > checkFail( > () => doPrep(` >@@ -200,92 +200,92 @@ tests.commentParsing = function() { > > tests.literalBool = function() { > let program = doPrep("bool foo() { return true; }"); >- checkBool(program, callFunction(program, "foo", [], []), true); >+ checkBool(program, callFunction(program, "foo", []), true); > } > > tests.identityBool = function() { > let program = doPrep("bool foo(bool x) { return x; }"); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), false); > } > > tests.intSimpleMath = function() { > let program = doPrep("int foo(int x, int y) { return x + y; }"); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 5)]), 12); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 12); > program = doPrep("int foo(int x, int y) { return x - y; }"); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 5)]), 2); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5), makeInt(program, 7)]), -2); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 2); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5), makeInt(program, 7)]), -2); > program = doPrep("int foo(int x, int y) { return x * y; }"); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 5)]), 35); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, -5)]), -35); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 35); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, -5)]), -35); > program = doPrep("int foo(int x, int y) { return x / y; }"); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 2)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, -2)]), -3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 2)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, -2)]), -3); > } > > tests.uintSimpleMath = function() { > let program = doPrep("uint foo(uint x, uint y) { return x + y; }"); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 5)]), 12); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 12); > program = doPrep("uint foo(uint x, uint y) { return x - y; }"); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 5)]), 2); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 5), makeUint(program, 7)]), 4294967294); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 2); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 5), makeUint(program, 7)]), 4294967294); > program = doPrep("uint foo(uint x, uint y) { return x * y; }"); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 5)]), 35); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 35); > program = doPrep("uint foo(uint x, uint y) { return x / y; }"); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 2)]), 3); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 2)]), 3); > } > > tests.uint8SimpleMath = function() { > let program = doPrep("uint8 foo(uint8 x, uint8 y) { return x + y; }"); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 5)]), 12); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 5)]), 12); > program = doPrep("uint8 foo(uint8 x, uint8 y) { return x - y; }"); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 5)]), 2); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 5), makeUint8(program, 7)]), 254); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 5)]), 2); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 5), makeUint8(program, 7)]), 254); > program = doPrep("uint8 foo(uint8 x, uint8 y) { return x * y; }"); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 5)]), 35); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 5)]), 35); > program = doPrep("uint8 foo(uint8 x, uint8 y) { return x / y; }"); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 2)]), 3); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 2)]), 3); > } > > tests.equality = function() { > let program = doPrep("bool foo(uint x, uint y) { return x == y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 5)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 7)]), true); >+ checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), false); >+ checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 7)]), true); > program = doPrep("bool foo(uint8 x, uint8 y) { return x == y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 5)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 7)]), true); >+ checkBool(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 5)]), false); >+ checkBool(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 7)]), true); > program = doPrep("bool foo(int x, int y) { return x == y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 5)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 7)]), true); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), false); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 7)]), true); > program = doPrep("bool foo(bool x, bool y) { return x == y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, true)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, false)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, true)]), true); > } > > tests.logicalNegation = function() > { > let program = doPrep("bool foo(bool x) { return !x; }"); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), true); > } > > tests.notEquality = function() { > let program = doPrep("bool foo(uint x, uint y) { return x != y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 5)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeUint(program, 7), makeUint(program, 7)]), false); >+ checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), true); >+ checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 7)]), false); > program = doPrep("bool foo(uint8 x, uint8 y) { return x != y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 5)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeUint8(program, 7), makeUint8(program, 7)]), false); >+ checkBool(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 5)]), true); >+ checkBool(program, callFunction(program, "foo", [makeUint8(program, 7), makeUint8(program, 7)]), false); > program = doPrep("bool foo(int x, int y) { return x != y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 5)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeInt(program, 7), makeInt(program, 7)]), false); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), true); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 7)]), false); > program = doPrep("bool foo(bool x, bool y) { return x != y; }"); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, true)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, false)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, true)]), false); > } > > tests.equalityTypeFailure = function() >@@ -298,13 +298,13 @@ tests.equalityTypeFailure = function() > tests.generalNegation = function() > { > 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); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 7)]), false); >+ checkBool(program, callFunction(program, "foo", [makeInt(program, 0)]), true); > } > > tests.add1 = function() { > let program = doPrep("int foo(int x) { return x + 1; }"); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 42)]), 43); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 42)]), 43); > } > > tests.simpleGeneric = function() { >@@ -312,7 +312,7 @@ tests.simpleGeneric = function() { > T id<T>(T x) { return x; } > int foo(int x) { return id(x) + 1; } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 42)]), 43); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 42)]), 43); > } > > tests.nameResolutionFailure = function() >@@ -331,7 +331,7 @@ tests.simpleVariable = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 42)]), 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 42)]), 42); > } > > tests.simpleAssignment = function() >@@ -344,7 +344,7 @@ tests.simpleAssignment = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 42)]), 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 42)]), 42); > } > > tests.simpleDefault = function() >@@ -356,7 +356,7 @@ tests.simpleDefault = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 0); >+ checkInt(program, callFunction(program, "foo", []), 0); > } > > tests.simpleDereference = function() >@@ -369,7 +369,7 @@ tests.simpleDereference = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 13); >- checkInt(program, callFunction(program, "foo", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); >+ checkInt(program, callFunction(program, "foo", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); > } > > tests.dereferenceStore = function() >@@ -382,7 +382,7 @@ tests.dereferenceStore = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 13); >- callFunction(program, "foo", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]); >+ callFunction(program, "foo", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]); > if (buffer.get(0) != 52) > throw new Error("Expected buffer to contain 52 but it contains: " + buffer.get(0)); > } >@@ -396,7 +396,7 @@ tests.simpleMakePtr = function() > return &x; > } > `); >- let result = callFunction(program, "foo", [], []); >+ let result = callFunction(program, "foo", []); > if (!result.type.isPtr) > throw new Error("Return type is not a pointer: " + result.type); > if (!result.type.elementType.equals(program.intrinsics.int32)) >@@ -418,7 +418,7 @@ tests.threadArrayLoad = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 89); >- let result = callFunction(program, "foo", [], [TypedValue.box(new ArrayRefType(externalOrigin, "thread", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); >+ let result = callFunction(program, "foo", [TypedValue.box(new ArrayRefType(externalOrigin, "thread", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); > checkInt(program, result, 89); > } > >@@ -432,7 +432,7 @@ tests.threadArrayLoadIntLiteral = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 89); >- let result = callFunction(program, "foo", [], [TypedValue.box(new ArrayRefType(externalOrigin, "thread", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); >+ let result = callFunction(program, "foo", [TypedValue.box(new ArrayRefType(externalOrigin, "thread", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); > checkInt(program, result, 89); > } > >@@ -446,7 +446,7 @@ tests.deviceArrayLoad = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 89); >- let result = callFunction(program, "foo", [], [TypedValue.box(new ArrayRefType(externalOrigin, "device", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); >+ let result = callFunction(program, "foo", [TypedValue.box(new ArrayRefType(externalOrigin, "device", program.intrinsics.int32), new EArrayRef(new EPtr(buffer, 0), 1))]); > checkInt(program, result, 89); > } > >@@ -463,10 +463,10 @@ tests.threadArrayStore = function() > let arrayRef = TypedValue.box( > new ArrayRefType(externalOrigin, "thread", program.intrinsics.int32), > new EArrayRef(new EPtr(buffer, 0), 1)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, 65)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, 65)]); > if (buffer.get(0) != 65) > throw new Error("Bad value stored into buffer (expected 65): " + buffer.get(0)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, -111)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, -111)]); > if (buffer.get(0) != -111) > throw new Error("Bad value stored into buffer (expected -111): " + buffer.get(0)); > } >@@ -484,10 +484,10 @@ tests.deviceArrayStore = function() > let arrayRef = TypedValue.box( > new ArrayRefType(externalOrigin, "device", program.intrinsics.int32), > new EArrayRef(new EPtr(buffer, 0), 1)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, 65)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, 65)]); > if (buffer.get(0) != 65) > throw new Error("Bad value stored into buffer (expected 65): " + buffer.get(0)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, -111)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, -111)]); > if (buffer.get(0) != -111) > throw new Error("Bad value stored into buffer (expected -111): " + buffer.get(0)); > } >@@ -505,32 +505,14 @@ tests.deviceArrayStoreIntLiteral = function() > let arrayRef = TypedValue.box( > new ArrayRefType(externalOrigin, "device", program.intrinsics.int32), > new EArrayRef(new EPtr(buffer, 0), 1)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, 65)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, 65)]); > if (buffer.get(0) != 65) > throw new Error("Bad value stored into buffer (expected 65): " + buffer.get(0)); >- callFunction(program, "foo", [], [arrayRef, makeInt(program, -111)]); >+ callFunction(program, "foo", [arrayRef, makeInt(program, -111)]); > if (buffer.get(0) != -111) > throw new Error("Bad value stored into buffer (expected -111): " + buffer.get(0)); > } > >-tests.simpleProtocol = function() >-{ >- let program = doPrep(` >- protocol MyAddable { >- MyAddable operator+(MyAddable, MyAddable); >- } >- T add<T:MyAddable>(T a, T b) >- { >- return a + b; >- } >- int foo(int x) >- { >- return add(x, 73); >- } >- `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 45)]), 45 + 73); >-} >- > tests.typeMismatchReturn = function() > { > checkFail( >@@ -666,7 +648,7 @@ tests.simpleStruct = function() > let buffer = new EBuffer(2); > buffer.set(0, 62); > buffer.set(1, 24); >- let result = callFunction(program, "foo", [], [new TypedValue(structType, new EPtr(buffer, 0))]); >+ let result = callFunction(program, "foo", [new TypedValue(structType, new EPtr(buffer, 0))]); > if (!result.type.equals(structType)) > throw new Error("Wrong result type: " + result.type); > let x = result.ePtr.get(0); >@@ -677,34 +659,6 @@ tests.simpleStruct = function() > throw new Error("Wrong result for y: " + y + " (x + " + x + ")"); > } > >-tests.genericStructInstance = function() >-{ >- let program = doPrep(` >- struct Foo<T> { >- T x; >- T y; >- } >- Foo<int> foo(Foo<int> foo) >- { >- Foo<int> result; >- result.x = foo.y; >- result.y = foo.x; >- return result; >- } >- `); >- let structType = TypeRef.instantiate(program.types.get("Foo"), [program.intrinsics.int32]); >- let buffer = new EBuffer(2); >- buffer.set(0, 62); >- buffer.set(1, 24); >- let result = callFunction(program, "foo", [], [new TypedValue(structType, new EPtr(buffer, 0))]); >- let x = result.ePtr.get(0); >- let y = result.ePtr.get(1); >- if (x != 24) >- throw new Error("Wrong result for x: " + x + " (y = " + y + ")"); >- if (y != 62) >- throw new Error("Wrong result for y: " + y + " (x + " + x + ")"); >-} >- > tests.doubleGenericCallsDoubleGeneric = function() > { > doPrep(` >@@ -747,7 +701,7 @@ tests.returnNull = function() > let program = doPrep(` > thread int* foo() { return null; } > `); >- let result = callFunction(program, "foo", [], []); >+ let result = callFunction(program, "foo", []); > if (!result.type.isPtr) > throw new Error("Return type is not a pointer: " + result.type); > if (!result.type.elementType.equals(program.intrinsics.int32)) >@@ -766,7 +720,7 @@ tests.dereferenceDefaultNull = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > (e) => e instanceof WTrapError); > } > >@@ -780,7 +734,7 @@ tests.defaultInitializedNull = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > (e) => e instanceof WTrapError); > } > >@@ -797,7 +751,7 @@ tests.passNullToPtrMonomorphic = function() > } > `); > checkFail( >- () => callFunction(program, "bar", [], []), >+ () => callFunction(program, "bar", []), > (e) => e instanceof WTrapError); > } > >@@ -857,7 +811,7 @@ tests.returnNullArrayRef = function() > let program = doPrep(` > thread int[] foo() { return null; } > `); >- let result = callFunction(program, "foo", [], []); >+ let result = callFunction(program, "foo", []); > if (!result.type.isArrayRef) > throw new Error("Return type is not an array reference: " + result.type); > if (!result.type.elementType.equals(program.intrinsics.int32)) >@@ -876,7 +830,7 @@ tests.dereferenceDefaultNullArrayRef = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > (e) => e instanceof WTrapError); > } > >@@ -890,7 +844,7 @@ tests.defaultInitializedNullArrayRef = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > (e) => e instanceof WTrapError); > } > >@@ -904,7 +858,7 @@ tests.defaultInitializedNullArrayRefIntLiteral = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > (e) => e instanceof WTrapError); > } > >@@ -921,7 +875,7 @@ tests.passNullToPtrMonomorphicArrayRef = function() > } > `); > checkFail( >- () => callFunction(program, "bar", [], []), >+ () => callFunction(program, "bar", []), > (e) => e instanceof WTrapError); > } > >@@ -944,13 +898,13 @@ tests.passNullToPtrPolymorphicArrayRef = function() > tests.returnIntLiteralUint = function() > { > let program = doPrep("uint foo() { return 42; }"); >- checkNumber(program, callFunction(program, "foo", [], []), 42); >+ checkNumber(program, callFunction(program, "foo", []), 42); > } > > tests.returnIntLiteralFloat = function() > { > let program = doPrep("float foo() { return 42; }"); >- checkNumber(program, callFunction(program, "foo", [], []), 42); >+ checkNumber(program, callFunction(program, "foo", []), 42); > } > > tests.badIntLiteralForInt = function() >@@ -988,7 +942,7 @@ tests.passNullAndNotNull = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 13); >- checkInt(program, callFunction(program, "foo", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); >+ checkInt(program, callFunction(program, "foo", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); > } > > tests.passNullAndNotNullFullPoly = function() >@@ -1005,7 +959,7 @@ tests.passNullAndNotNullFullPoly = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 13); >- checkInt(program, callFunction(program, "foo", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); >+ checkInt(program, callFunction(program, "foo", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); > } > > tests.passNullAndNotNullFullPolyReverse = function() >@@ -1022,65 +976,7 @@ tests.passNullAndNotNullFullPolyReverse = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 13); >- checkInt(program, callFunction(program, "foo", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); >-} >- >-tests.nullTypeVariableUnify = function() >-{ >- let left = new NullType(externalOrigin); >- let right = new TypeVariable(externalOrigin, "T", null); >- if (left.equals(right)) >- throw new Error("Should not be equal but are: " + left + " and " + right); >- if (right.equals(left)) >- throw new Error("Should not be equal but are: " + left + " and " + right); >- >- function everyOrder(array, callback) >- { >- function recurse(array, callback, order) >- { >- if (!array.length) >- return callback.call(null, order); >- >- for (let i = 0; i < array.length; ++i) { >- let nextArray = array.concat(); >- nextArray.splice(i, 1); >- recurse(nextArray, callback, order.concat([array[i]])); >- } >- } >- >- recurse(array, callback, []); >- } >- >- function everyPair(things) >- { >- let result = []; >- for (let i = 0; i < things.length; ++i) { >- for (let j = 0; j < things.length; ++j) { >- if (i != j) >- result.push([things[i], things[j]]); >- } >- } >- return result; >- } >- >- everyOrder( >- everyPair(["nullType", "variableType", "ptrType"]), >- order => { >- let types = {}; >- types.nullType = new NullType(externalOrigin); >- types.variableType = new TypeVariable(externalOrigin, "T", null); >- types.ptrType = new PtrType(externalOrigin, "constant", new NativeType(externalOrigin, "foo_t", [])); >- let unificationContext = new UnificationContext([types.variableType]); >- for (let [leftName, rightName] of order) { >- let left = types[leftName]; >- let right = types[rightName]; >- let result = left.unify(unificationContext, right); >- if (!result) >- throw new Error("In order " + order + " cannot unify " + left + " with " + right); >- } >- if (!unificationContext.verify().result) >- throw new Error("In order " + order.map(value => "(" + value + ")") + " cannot verify"); >- }); >+ checkInt(program, callFunction(program, "foo", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 13); > } > > tests.doubleNot = function() >@@ -1091,8 +987,8 @@ tests.doubleNot = function() > return !!x; > } > `); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), false); > } > > tests.simpleRecursion = function() >@@ -1107,114 +1003,6 @@ tests.simpleRecursion = function() > (e) => e instanceof WTypeError); > } > >-tests.protocolMonoSigPolyDef = function() >-{ >- let program = doPrep(` >- struct IntAnd<T> { >- int first; >- T second; >- } >- IntAnd<T> intAnd<T>(int first, T second) >- { >- IntAnd<T> result; >- result.first = first; >- result.second = second; >- return result; >- } >- protocol IntAndable { >- IntAnd<int> intAnd(IntAndable, int); >- } >- int foo<T:IntAndable>(T first, int second) >- { >- IntAnd<int> result = intAnd(first, second); >- return result.first + result.second; >- } >- `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12)]), 54 + 12); >-} >- >-tests.protocolPolySigPolyDef = function() >-{ >- let program = doPrep(` >- struct IntAnd<T> { >- int first; >- T second; >- } >- IntAnd<T> intAnd<T>(int first, T second) >- { >- IntAnd<T> result; >- result.first = first; >- result.second = second; >- return result; >- } >- protocol IntAndable { >- IntAnd<T> intAnd<T>(IntAndable, T); >- } >- int foo<T:IntAndable>(T first, int second) >- { >- IntAnd<int> result = intAnd(first, second); >- return result.first + result.second; >- } >- `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12)]), 54 + 12); >-} >- >-tests.protocolDoublePolySigDoublePolyDef = function() >-{ >- let program = doPrep(` >- struct IntAnd<T, U> { >- int first; >- T second; >- U third; >- } >- IntAnd<T, U> intAnd<T, U>(int first, T second, U third) >- { >- IntAnd<T, U> result; >- result.first = first; >- result.second = second; >- result.third = third; >- return result; >- } >- protocol IntAndable { >- IntAnd<T, U> intAnd<T, U>(IntAndable, T, U); >- } >- int foo<T:IntAndable>(T first, int second, int third) >- { >- IntAnd<int, int> result = intAnd(first, second, third); >- return result.first + result.second + result.third; >- } >- `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12), makeInt(program, 39)]), 54 + 12 + 39); >-} >- >-tests.protocolDoublePolySigDoublePolyDefExplicit = function() >-{ >- let program = doPrep(` >- struct IntAnd<T, U> { >- int first; >- T second; >- U third; >- } >- IntAnd<T, U> intAnd<T, U>(int first, T second, U third) >- { >- IntAnd<T, U> result; >- result.first = first; >- result.second = second; >- result.third = third; >- return result; >- } >- protocol IntAndable { >- IntAnd<T, U> intAnd<T, U>(IntAndable, T, U); >- } >- int foo<T:IntAndable>(T first, int second, int third) >- { >- IntAnd<int, int> result = intAnd<int, int>(first, second, third); >- return result.first + result.second + result.third; >- } >- `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12), makeInt(program, 39)]), 54 + 12 + 39); >-} >- > tests.variableShadowing = function() > { > let program = doPrep(` >@@ -1229,7 +1017,7 @@ tests.variableShadowing = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 8); >+ checkInt(program, callFunction(program, "foo", []), 8); > program = doPrep(` > int foo() > { >@@ -1242,7 +1030,7 @@ tests.variableShadowing = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 7); >+ checkInt(program, callFunction(program, "foo", []), 7); > } > > tests.ifStatement = function() >@@ -1257,13 +1045,13 @@ tests.ifStatement = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 6); > } > > tests.ifElseStatement = function() >@@ -1280,13 +1068,13 @@ tests.ifElseStatement = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 9); > } > > tests.ifElseIfStatement = function() >@@ -1303,13 +1091,13 @@ tests.ifElseIfStatement = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 6); > } > > tests.ifElseIfElseStatement = function() >@@ -1328,13 +1116,13 @@ tests.ifElseIfElseStatement = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 10); > } > > tests.returnIf = function() >@@ -1387,13 +1175,13 @@ tests.returnIf = function() > } > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 10); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1419,13 +1207,13 @@ tests.returnIf = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 8)]), 9); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 9); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1449,7 +1237,7 @@ tests.returnIf = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 6); > } > > tests.simpleWhile = function() >@@ -1462,39 +1250,7 @@ tests.simpleWhile = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 16); >-} >- >-tests.protocolMonoPolySigDoublePolyDefExplicit = function() >-{ >- checkFail( >- () => { >- let program = doPrep(` >- struct IntAnd<T, U> { >- int first; >- T second; >- U third; >- } >- IntAnd<T, U> intAnd<T, U>(int first, T second, U third) >- { >- IntAnd<T, U> result; >- result.first = first; >- result.second = second; >- result.third = third; >- return result; >- } >- protocol IntAndable { >- IntAnd<T, int> intAnd<T>(IntAndable, T, int); >- } >- int foo<T:IntAndable>(T first, int second, int third) >- { >- IntAnd<int, int> result = intAnd<int>(first, second, third); >- return result.first + result.second + result.third; >- } >- `); >- callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12), makeInt(program, 39)]); >- }, >- (e) => e instanceof WTypeError); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 16); > } > > tests.ambiguousOverloadSimple = function() >@@ -1537,7 +1293,7 @@ tests.intOverloadResolution = function() > int foo(float) { return 3; } > int bar() { return foo(42); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 1); >+ checkInt(program, callFunction(program, "bar", []), 1); > } > > tests.intOverloadResolutionReverseOrder = function() >@@ -1548,7 +1304,7 @@ tests.intOverloadResolutionReverseOrder = function() > int foo(int) { return 1; } > int bar() { return foo(42); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 1); >+ checkInt(program, callFunction(program, "bar", []), 1); > } > > tests.intOverloadResolutionGeneric = function() >@@ -1558,7 +1314,7 @@ tests.intOverloadResolutionGeneric = function() > int foo<T>(T) { return 2; } > int bar() { return foo(42); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 1); >+ checkInt(program, callFunction(program, "bar", []), 1); > } > > tests.intLiteralGeneric = function() >@@ -1567,19 +1323,7 @@ tests.intLiteralGeneric = function() > int foo<T>(T x) { return 3478; } > int bar() { return foo(42); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 3478); >-} >- >-tests.intLiteralGenericWithProtocols = function() >-{ >- let program = doPrep(` >- protocol MyConvertibleToInt { >- operator int(MyConvertibleToInt); >- } >- int foo<T:MyConvertibleToInt>(T x) { return int(x); } >- int bar() { return foo(42); } >- `); >- checkInt(program, callFunction(program, "bar", [], []), 42); >+ checkInt(program, callFunction(program, "bar", []), 3478); > } > > tests.uintLiteralGeneric = function() >@@ -1588,19 +1332,7 @@ tests.uintLiteralGeneric = function() > int foo<T>(T x) { return 3478; } > int bar() { return foo(42u); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 3478); >-} >- >-tests.uintLiteralGenericWithProtocols = function() >-{ >- let program = doPrep(` >- protocol MyConvertibleToUint { >- operator uint(MyConvertibleToUint); >- } >- uint foo<T:MyConvertibleToUint>(T x) { return uint(x); } >- uint bar() { return foo(42u); } >- `); >- checkUint(program, callFunction(program, "bar", [], []), 42); >+ checkInt(program, callFunction(program, "bar", []), 3478); > } > > tests.intLiteralGenericSpecific = function() >@@ -1609,7 +1341,7 @@ tests.intLiteralGenericSpecific = function() > T foo<T>(T x) { return x; } > int bar() { return foo(int(42)); } > `); >- checkInt(program, callFunction(program, "bar", [], []), 42); >+ checkInt(program, callFunction(program, "bar", []), 42); > } > > tests.simpleConstexpr = function() >@@ -1624,7 +1356,7 @@ tests.simpleConstexpr = function() > return foo<42>(b); > } > `); >- checkInt(program, callFunction(program, "bar", [], [makeInt(program, 58)]), 58 + 42); >+ checkInt(program, callFunction(program, "bar", [makeInt(program, 58)]), 58 + 42); > } > > tests.break = function() >@@ -1640,8 +1372,8 @@ tests.break = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 10)]), 20); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 10)]), 20); > program = doPrep(` > int foo(int x) > { >@@ -1658,8 +1390,8 @@ tests.break = function() > > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 10)]), 19); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 10)]), 19); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1695,7 +1427,7 @@ tests.break = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 7); > program = doPrep(` > int foo(int x) > { >@@ -1705,7 +1437,7 @@ tests.break = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 1); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 1); > program = doPrep(` > int foo() > { >@@ -1714,7 +1446,7 @@ tests.break = function() > } > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 7); >+ checkInt(program, callFunction(program, "foo", []), 7); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1743,7 +1475,7 @@ tests.continue = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 18); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 18); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1769,8 +1501,8 @@ tests.doWhile = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 8); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 11)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 11)]), 8); > program = doPrep(` > int foo(int x) > { >@@ -1782,7 +1514,7 @@ tests.doWhile = function() > return y; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), 8); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8); > program = doPrep(` > int foo(int x) > { >@@ -1798,7 +1530,7 @@ tests.doWhile = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 19); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 9)]), 19); > } > > tests.forLoop = function() >@@ -1814,9 +1546,9 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); > program = doPrep(` > int foo(int x) > { >@@ -1827,9 +1559,9 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); > program = doPrep(` > int foo(int x) > { >@@ -1841,9 +1573,9 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); > program = doPrep(` > int foo(int x) > { >@@ -1856,10 +1588,10 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 11); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 11); > program = doPrep(` > int foo(int x) > { >@@ -1872,11 +1604,11 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 10); > program = doPrep(` > int foo(int x) > { >@@ -1889,11 +1621,11 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 15); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 21); > program = doPrep(` > int foo(int x) > { >@@ -1907,11 +1639,11 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 15); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 21); > program = doPrep(` > int foo(int x) > { >@@ -1926,11 +1658,11 @@ tests.forLoop = function() > return sum; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 3); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 15); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 21); > checkFail( > () => doPrep(` > void foo(int x) >@@ -1950,11 +1682,11 @@ tests.forLoop = function() > } > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 7); > checkFail( > () => doPrep(` > int foo(int x) >@@ -1973,11 +1705,11 @@ tests.forLoop = function() > } > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 3)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 7); > } > > tests.chainConstexpr = function() >@@ -1996,7 +1728,7 @@ tests.chainConstexpr = function() > return bar<42>(b); > } > `); >- checkInt(program, callFunction(program, "baz", [], [makeInt(program, 58)]), 58 + 42); >+ checkInt(program, callFunction(program, "baz", [makeInt(program, 58)]), 58 + 42); > } > > tests.chainGeneric = function() >@@ -2015,7 +1747,7 @@ tests.chainGeneric = function() > return bar(&x); > } > `); >- checkInt(program, callFunction(program, "baz", [], [makeInt(program, 37)]), 37); >+ checkInt(program, callFunction(program, "baz", [makeInt(program, 37)]), 37); > } > > tests.chainStruct = function() >@@ -2038,7 +1770,7 @@ tests.chainStruct = function() > return foo(&x); > } > `); >- checkInt(program, callFunction(program, "bar", [], [makeInt(program, 4657)]), 4657); >+ checkInt(program, callFunction(program, "bar", [makeInt(program, 4657)]), 4657); > } > > tests.chainStructNewlyValid = function() >@@ -2063,7 +1795,7 @@ tests.chainStructNewlyValid = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 78453); >- checkInt(program, callFunction(program, "bar", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 78453); >+ checkInt(program, callFunction(program, "bar", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 78453); > } > > tests.chainStructDevice = function() >@@ -2088,7 +1820,7 @@ tests.chainStructDevice = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 79201); >- checkInt(program, callFunction(program, "bar", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 79201); >+ checkInt(program, callFunction(program, "bar", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 79201); > } > > tests.paramChainStructDevice = function() >@@ -2113,89 +1845,7 @@ tests.paramChainStructDevice = function() > `); > let buffer = new EBuffer(1); > buffer.set(0, 79201); >- checkInt(program, callFunction(program, "bar", [], [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 79201); >-} >- >-tests.simpleProtocolExtends = function() >-{ >- let program = doPrep(` >- protocol Foo { >- void foo(thread Foo*); >- } >- protocol Bar : Foo { >- void bar(thread Bar*); >- } >- void fuzz<T:Foo>(thread T* p) >- { >- foo(p); >- } >- void buzz<T:Bar>(thread T* p) >- { >- fuzz(p); >- bar(p); >- } >- void foo(thread int* p) >- { >- *p = *p + 743; >- } >- void bar(thread int* p) >- { >- *p = *p + 91; >- } >- int thingy(int a) >- { >- buzz(&a); >- return a; >- } >- `); >- checkInt(program, callFunction(program, "thingy", [], [makeInt(program, 642)]), 642 + 743 + 91); >-} >- >-tests.protocolExtendsTwo = function() >-{ >- let program = doPrep(` >- protocol Foo { >- void foo(thread Foo*); >- } >- protocol Bar { >- void bar(thread Bar*); >- } >- protocol Baz : Foo, Bar { >- void baz(thread Baz*); >- } >- void fuzz<T:Foo>(thread T* p) >- { >- foo(p); >- } >- void buzz<T:Bar>(thread T* p) >- { >- bar(p); >- } >- void xuzz<T:Baz>(thread T* p) >- { >- fuzz(p); >- buzz(p); >- baz(p); >- } >- void foo(thread int* p) >- { >- *p = *p + 743; >- } >- void bar(thread int* p) >- { >- *p = *p + 91; >- } >- void baz(thread int* p) >- { >- *p = *p + 39; >- } >- int thingy(int a) >- { >- xuzz(&a); >- return a; >- } >- `); >- checkInt(program, callFunction(program, "thingy", [], [makeInt(program, 642)]), 642 + 743 + 91 + 39); >+ checkInt(program, callFunction(program, "bar", [TypedValue.box(new PtrType(externalOrigin, "device", program.intrinsics.int32), new EPtr(buffer, 0))]), 79201); > } > > tests.prefixPlusPlus = function() >@@ -2207,7 +1857,7 @@ tests.prefixPlusPlus = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 65); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 65); > } > > tests.prefixPlusPlusResult = function() >@@ -2218,7 +1868,7 @@ tests.prefixPlusPlusResult = function() > return ++x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 65); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 65); > } > > tests.postfixPlusPlus = function() >@@ -2230,7 +1880,7 @@ tests.postfixPlusPlus = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 65); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 65); > } > > tests.postfixPlusPlusResult = function() >@@ -2241,7 +1891,7 @@ tests.postfixPlusPlusResult = function() > return x++; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 64); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 64); > } > > tests.prefixMinusMinus = function() >@@ -2253,7 +1903,7 @@ tests.prefixMinusMinus = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 63); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 63); > } > > tests.prefixMinusMinusResult = function() >@@ -2264,7 +1914,7 @@ tests.prefixMinusMinusResult = function() > return --x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 63); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 63); > } > > tests.postfixMinusMinus = function() >@@ -2276,7 +1926,7 @@ tests.postfixMinusMinus = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 63); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 63); > } > > tests.postfixMinusMinusResult = function() >@@ -2287,7 +1937,7 @@ tests.postfixMinusMinusResult = function() > return x--; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 64)]), 64); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 64)]), 64); > } > > tests.plusEquals = function() >@@ -2299,7 +1949,7 @@ tests.plusEquals = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 + 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 + 42); > } > > tests.plusEqualsResult = function() >@@ -2310,7 +1960,7 @@ tests.plusEqualsResult = function() > return x += 42; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 + 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 + 42); > } > > tests.minusEquals = function() >@@ -2322,7 +1972,7 @@ tests.minusEquals = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 - 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 - 42); > } > > tests.minusEqualsResult = function() >@@ -2333,7 +1983,7 @@ tests.minusEqualsResult = function() > return x -= 42; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 - 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 - 42); > } > > tests.timesEquals = function() >@@ -2345,7 +1995,7 @@ tests.timesEquals = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 * 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 * 42); > } > > tests.timesEqualsResult = function() >@@ -2356,7 +2006,7 @@ tests.timesEqualsResult = function() > return x *= 42; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), 385 * 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), 385 * 42); > } > > tests.divideEquals = function() >@@ -2368,7 +2018,7 @@ tests.divideEquals = function() > return x; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), (385 / 42) | 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), (385 / 42) | 0); > } > > tests.divideEqualsResult = function() >@@ -2379,7 +2029,7 @@ tests.divideEqualsResult = function() > return x /= 42; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 385)]), (385 / 42) | 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 385)]), (385 / 42) | 0); > } > > tests.twoIntLiterals = function() >@@ -2390,7 +2040,7 @@ tests.twoIntLiterals = function() > return 42 == 42; > } > `); >- checkBool(program, callFunction(program, "foo", [], []), true); >+ checkBool(program, callFunction(program, "foo", []), true); > } > > tests.unifyDifferentLiterals = function() >@@ -2479,7 +2129,7 @@ tests.buildArrayThenSumIt = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 42 * 5 + 42 * 41 / 2); >+ checkInt(program, callFunction(program, "foo", []), 42 * 5 + 42 * 41 / 2); > } > > tests.buildArrayThenSumItUsingArrayReference = function() >@@ -2500,7 +2150,7 @@ tests.buildArrayThenSumItUsingArrayReference = function() > return bar(@array); > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 42 * 5 + 42 * 41 / 2); >+ checkInt(program, callFunction(program, "foo", []), 42 * 5 + 42 * 41 / 2); > } > > tests.overrideSubscriptStruct = function() >@@ -2526,7 +2176,7 @@ tests.overrideSubscriptStruct = function() > return foo[0] + foo[1] * 3; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 498 + 19 * 3); >+ checkInt(program, callFunction(program, "foo", []), 498 + 19 * 3); > } > > tests.overrideSubscriptStructAndDoStores = function() >@@ -2552,7 +2202,7 @@ tests.overrideSubscriptStructAndDoStores = function() > return foo.x + foo.y; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 498 + 19); >+ checkInt(program, callFunction(program, "foo", []), 498 + 19); > } > > tests.overrideSubscriptStructAndUsePointers = function() >@@ -2582,7 +2232,7 @@ tests.overrideSubscriptStructAndUsePointers = function() > return bar(&foo); > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 498 + 19); >+ checkInt(program, callFunction(program, "foo", []), 498 + 19); > } > > tests.overrideSubscriptStructAndUsePointersIncorrectly = function() >@@ -2629,7 +2279,7 @@ tests.makeArrayRefFromLocal = function() > return bar(@x); > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 48); >+ checkInt(program, callFunction(program, "foo", []), 48); > } > > tests.makeArrayRefFromPointer = function() >@@ -2649,7 +2299,7 @@ tests.makeArrayRefFromPointer = function() > return baz(&x); > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 48); >+ checkInt(program, callFunction(program, "foo", []), 48); > } > > tests.makeArrayRefFromArrayRef = function() >@@ -2682,7 +2332,7 @@ tests.simpleLength = function() > return (@array).length; > } > `); >- checkUint(program, callFunction(program, "foo", [], []), 754); >+ checkUint(program, callFunction(program, "foo", []), 754); > } > > tests.nonArrayRefArrayLengthSucceed = function() >@@ -2694,7 +2344,7 @@ tests.nonArrayRefArrayLengthSucceed = function() > return array.length; > } > `); >- checkUint(program, callFunction(program, "foo", [], []), 754); >+ checkUint(program, callFunction(program, "foo", []), 754); > } > > tests.nonArrayRefArrayLengthFail = function() >@@ -2793,7 +2443,7 @@ tests.simpleGetter = function() > return foo.y; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 7804); >+ checkInt(program, callFunction(program, "foo", []), 7804); > } > > tests.simpleSetter = function() >@@ -2818,7 +2468,7 @@ tests.simpleSetter = function() > return foo.x; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 7804); >+ checkInt(program, callFunction(program, "foo", []), 7804); > } > > tests.genericAccessors = function() >@@ -2903,354 +2553,103 @@ tests.genericAccessors = function() > return foo.sum; > } > `); >- checkInt(program, callFunction(program, "testSuperBasic", [], []), 1 + 2 + 3 + 4); >- checkInt(program, callFunction(program, "testZSetterDidSetY", [], []), 932); >- checkInt(program, callFunction(program, "testZSetter", [], []), 53 + 932); >- checkInt(program, callFunction(program, "testZGetter", [], []), 1 + 3); >- checkInt(program, callFunction(program, "testLValueEmulation", [], []), 1 + 2 + 3 * 5 + 4); >-} >- >-tests.bitSubscriptAccessor = function() >-{ >- let program = doPrep(` >- protocol MyBitmaskable : Equatable { >- MyBitmaskable operator&(MyBitmaskable, MyBitmaskable); >- MyBitmaskable operator|(MyBitmaskable, MyBitmaskable); >- MyBitmaskable operator~(MyBitmaskable); >- MyBitmaskable operator<<(MyBitmaskable, uint); >- MyBitmaskable operator>>(MyBitmaskable, uint); >- operator MyBitmaskable(int); >- } >- T maskForBitIndex<T:MyBitmaskable>(uint index) >- { >- return T(1) << index; >- } >- bool operator[]<T:MyBitmaskable>(T value, uint index) >- { >- return bool(value & maskForBitIndex<T>(index)); >- } >- T operator[]=<T:MyBitmaskable>(T value, uint index, bool bit) >- { >- T mask = maskForBitIndex<T>(index); >- if (bit) >- value |= mask; >- else >- value &= ~mask; >- return value; >- } >- uint operator.length(int) >- { >- return 32; >- } >- uint operator.length(uint) >- { >- return 32; >- } >- int testIntSetBit3() >- { >- int foo; >- foo[3] = true; >- return foo; >- } >- bool testIntSetGetBit5() >- { >- int foo; >- foo[5] = true; >- return foo[5]; >- } >- bool testIntGetBit1() >- { >- int foo; >- return foo[1]; >- } >- int testUintSumBits() >- { >- int foo = 42; >- int result; >- for (uint i = 0; i < foo.length; ++i) { >- if (foo[i]) >- result++; >- } >- return result; >- } >- int testUintSwapBits() >- { >- int foo = 42; >- for (uint i = 0; i < foo.length / 2; ++i) { >- bool tmp = foo[i]; >- foo[i] = foo[foo.length - i - 1]; >- foo[foo.length - i - 1] = tmp; >- } >- return foo; >- } >- struct Foo { >- uint f; >- uint g; >- } >- operator Foo(uint f, uint g) >- { >- Foo result; >- result.f = f; >- result.g = g; >- return result; >- } >- int operator.h(Foo foo) >- { >- return int((foo.f & 0xffff) | ((foo.g & 0xffff) << 16)); >- } >- Foo operator.h=(Foo foo, int value) >- { >- foo.f &= ~0xffffu; >- foo.f |= uint(value) & 0xffff; >- foo.g &= ~0xffffu; >- foo.g |= (uint(value) >> 16) & 0xffff; >- return foo; >- } >- int testLValueEmulation() >- { >- Foo foo; >- foo.f = 42; >- foo.g = 37; >- for (uint i = 0; i < foo.h.length; ++i) >- foo.h[i] ^= true; >- return int(foo.f + foo.g); >- } >- struct Bar { >- Foo a; >- Foo b; >- } >- Foo operator.c(Bar bar) >- { >- return Foo(uint(bar.a.h), uint(bar.b.h)); >- } >- Bar operator.c=(Bar bar, Foo foo) >- { >- bar.a.h = int(foo.f); >- bar.b.h = int(foo.g); >- return bar; >- } >- int testCrazyLValueEmulation() >- { >- Bar bar; >- bar.a.f = 1; >- bar.a.g = 2; >- bar.b.f = 3; >- bar.b.g = 4; >- for (uint i = 0; i < bar.c.h.length; i += 2) >- bar.c.h[i] ^= true; >- return int(bar.a.f + bar.a.g + bar.b.f + bar.b.g); >- } >- `); >- checkInt(program, callFunction(program, "testIntSetBit3", [], []), 8); >- checkBool(program, callFunction(program, "testIntSetGetBit5", [], []), true); >- checkBool(program, callFunction(program, "testIntGetBit1", [], []), false); >- checkInt(program, callFunction(program, "testUintSumBits", [], []), 3); >- checkInt(program, callFunction(program, "testUintSwapBits", [], []), 1409286144); >- checkInt(program, callFunction(program, "testLValueEmulation", [], []), 130991); >- checkInt(program, callFunction(program, "testCrazyLValueEmulation", [], []), 43696); >+ checkInt(program, callFunction(program, "testSuperBasic", []), 1 + 2 + 3 + 4); >+ checkInt(program, callFunction(program, "testZSetterDidSetY", []), 932); >+ checkInt(program, callFunction(program, "testZSetter", []), 53 + 932); >+ checkInt(program, callFunction(program, "testZGetter", []), 1 + 3); >+ checkInt(program, callFunction(program, "testLValueEmulation", []), 1 + 2 + 3 * 5 + 4); > } > > tests.nestedSubscriptLValueEmulationSimple = function() > { > let program = doPrep(` > struct Foo { >- int[7] array; >- } >- int operator[](Foo foo, uint index) >- { >- return foo.array[index]; >- } >- Foo operator[]=(Foo foo, uint index, int value) >- { >- foo.array[index] = value; >- return foo; >- } >- uint operator.length(Foo foo) >- { >- return foo.array.length; >- } >- int sum(Foo foo) >- { >- int result = 0; >- for (uint i = foo.length; i--;) >- result += foo[i]; >- return result; >- } >- struct Bar { >- Foo[6] array; >- } >- uint operator.length(Bar bar) >- { >- return bar.array.length; >- } >- Foo operator[](Bar bar, uint index) >- { >- return bar.array[index]; >- } >- Bar operator[]=(Bar bar, uint index, Foo value) >- { >- bar.array[index] = value; >- return bar; >- } >- int sum(Bar bar) >- { >- int result = 0; >- for (uint i = bar.length; i--;) >- result += sum(bar[i]); >- return result; >- } >- struct Baz { >- Bar[5] array; >- } >- Bar operator[](Baz baz, uint index) >- { >- return baz.array[index]; >- } >- Baz operator[]=(Baz baz, uint index, Bar value) >- { >- baz.array[index] = value; >- return baz; >- } >- uint operator.length(Baz baz) >- { >- return baz.array.length; >- } >- int sum(Baz baz) >- { >- int result = 0; >- for (uint i = baz.length; i--;) >- result += sum(baz[i]); >- return result; >- } >- void setValues(thread Baz* baz) >- { >- for (uint i = baz->length; i--;) { >- for (uint j = (*baz)[i].length; j--;) { >- for (uint k = (*baz)[i][j].length; k--;) >- (*baz)[i][j][k] = int(i + j + k); >- } >- } >- } >- int testSetValuesAndSum() >- { >- Baz baz; >- setValues(&baz); >- return sum(baz); >- } >- int testSetValuesMutateValuesAndSum() >- { >- Baz baz; >- setValues(&baz); >- for (uint i = baz.length; i--;) { >- for (uint j = baz[i].length; j--;) { >- for (uint k = baz[i][j].length; k--;) >- baz[i][j][k] *= int(k); >- } >- } >- return sum(baz); >- } >- `); >- checkInt(program, callFunction(program, "testSetValuesAndSum", [], []), 1575); >- checkInt(program, callFunction(program, "testSetValuesMutateValuesAndSum", [], []), 5565); >-} >- >-tests.nestedSubscriptLValueEmulationGeneric = function() >-{ >- let program = doPrep(` >- struct Foo<T> { >- T[7] array; >+ int[7] array; > } >- T operator[]<T>(Foo<T> foo, uint index) >+ int operator[](Foo foo, uint index) > { > return foo.array[index]; > } >- Foo<T> operator[]=<T>(Foo<T> foo, uint index, T value) >+ Foo operator[]=(Foo foo, uint index, int value) > { > foo.array[index] = value; > return foo; > } >- uint operator.length<T>(Foo<T> foo) >+ uint operator.length(Foo foo) > { > return foo.array.length; > } >- protocol MyAddable { >- MyAddable operator+(MyAddable, MyAddable); >- } >- T sum<T:MyAddable>(Foo<T> foo) >+ int sum(Foo foo) > { >- T result; >+ int result = 0; > for (uint i = foo.length; i--;) > result += foo[i]; > return result; > } >- struct Bar<T> { >- Foo<T>[6] array; >+ struct Bar { >+ Foo[6] array; > } >- uint operator.length<T>(Bar<T> bar) >+ uint operator.length(Bar bar) > { > return bar.array.length; > } >- Foo<T> operator[]<T>(Bar<T> bar, uint index) >+ Foo operator[](Bar bar, uint index) > { > return bar.array[index]; > } >- Bar<T> operator[]=<T>(Bar<T> bar, uint index, Foo<T> value) >+ Bar operator[]=(Bar bar, uint index, Foo value) > { > bar.array[index] = value; > return bar; > } >- T sum<T:MyAddable>(Bar<T> bar) >+ int sum(Bar bar) > { >- T result; >+ int result = 0; > for (uint i = bar.length; i--;) > result += sum(bar[i]); > return result; > } >- struct Baz<T> { >- Bar<T>[5] array; >+ struct Baz { >+ Bar[5] array; > } >- Bar<T> operator[]<T>(Baz<T> baz, uint index) >+ Bar operator[](Baz baz, uint index) > { > return baz.array[index]; > } >- Baz<T> operator[]=<T>(Baz<T> baz, uint index, Bar<T> value) >+ Baz operator[]=(Baz baz, uint index, Bar value) > { > baz.array[index] = value; > return baz; > } >- uint operator.length<T>(Baz<T> baz) >+ uint operator.length(Baz baz) > { > return baz.array.length; > } >- T sum<T:MyAddable>(Baz<T> baz) >+ int sum(Baz baz) > { >- T result; >+ int result = 0; > for (uint i = baz.length; i--;) > result += sum(baz[i]); > return result; > } >- protocol MyConvertibleFromUint { >- operator MyConvertibleFromUint(uint); >- } >- protocol SetValuable : MyAddable, MyConvertibleFromUint { } >- void setValues<T:SetValuable>(thread Baz<T>* baz) >+ void setValues(thread Baz* baz) > { > for (uint i = baz->length; i--;) { > for (uint j = (*baz)[i].length; j--;) { > for (uint k = (*baz)[i][j].length; k--;) >- (*baz)[i][j][k] = T(i + j + k); >+ (*baz)[i][j][k] = int(i + j + k); > } > } > } > int testSetValuesAndSum() > { >- Baz<int> baz; >+ Baz baz; > setValues(&baz); > return sum(baz); > } > int testSetValuesMutateValuesAndSum() > { >- Baz<int> baz; >+ Baz baz; > setValues(&baz); > for (uint i = baz.length; i--;) { > for (uint j = baz[i].length; j--;) { >@@ -3261,8 +2660,8 @@ tests.nestedSubscriptLValueEmulationGeneric = function() > return sum(baz); > } > `); >- checkInt(program, callFunction(program, "testSetValuesAndSum", [], []), 1575); >- checkInt(program, callFunction(program, "testSetValuesMutateValuesAndSum", [], []), 5565); >+ checkInt(program, callFunction(program, "testSetValuesAndSum", []), 1575); >+ checkInt(program, callFunction(program, "testSetValuesMutateValuesAndSum", []), 5565); > } > > tests.boolBitAnd = function() >@@ -3273,10 +2672,10 @@ tests.boolBitAnd = function() > return a & b; > } > `); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, true)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, true)]), true); > } > > tests.boolBitOr = function() >@@ -3287,10 +2686,10 @@ tests.boolBitOr = function() > return a | b; > } > `); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, false)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, true)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, true)]), true); > } > > tests.boolBitXor = function() >@@ -3301,10 +2700,10 @@ tests.boolBitXor = function() > return a ^ b; > } > `); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, false)]), false); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, false)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false), makeBool(program, true)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true), makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, true)]), false); > } > > tests.boolBitNot = function() >@@ -3315,8 +2714,8 @@ tests.boolBitNot = function() > return ~a; > } > `); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, false)]), true); >- checkBool(program, callFunction(program, "foo", [], [makeBool(program, true)]), false); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), true); >+ checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), false); > } > > tests.intBitAnd = function() >@@ -3327,10 +2726,10 @@ tests.intBitAnd = function() > return a & b; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1), makeInt(program, 7)]), 1); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535), makeInt(program, 42)]), 42); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1), makeInt(program, -7)]), -7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0), makeInt(program, 85732)]), 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1), makeInt(program, 7)]), 1); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535), makeInt(program, 42)]), 42); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1), makeInt(program, -7)]), -7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0), makeInt(program, 85732)]), 0); > } > > tests.intBitOr = function() >@@ -3341,10 +2740,10 @@ tests.intBitOr = function() > return a | b; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1), makeInt(program, 7)]), 7); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535), makeInt(program, 42)]), 65535); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1), makeInt(program, -7)]), -1); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0), makeInt(program, 85732)]), 85732); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1), makeInt(program, 7)]), 7); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535), makeInt(program, 42)]), 65535); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1), makeInt(program, -7)]), -1); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0), makeInt(program, 85732)]), 85732); > } > > tests.intBitXor = function() >@@ -3355,10 +2754,10 @@ tests.intBitXor = function() > return a ^ b; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1), makeInt(program, 7)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535), makeInt(program, 42)]), 65493); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1), makeInt(program, -7)]), 6); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0), makeInt(program, 85732)]), 85732); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1), makeInt(program, 7)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535), makeInt(program, 42)]), 65493); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1), makeInt(program, -7)]), 6); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0), makeInt(program, 85732)]), 85732); > } > > tests.intBitNot = function() >@@ -3369,10 +2768,10 @@ tests.intBitNot = function() > return ~a; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1)]), -2); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535)]), -65536); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1)]), 0); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0)]), -1); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), -2); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535)]), -65536); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1)]), 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0)]), -1); > } > > tests.intLShift = function() >@@ -3383,10 +2782,10 @@ tests.intLShift = function() > return a << b; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1), makeUint(program, 7)]), 128); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535), makeUint(program, 2)]), 262140); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1), makeUint(program, 5)]), -32); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0), makeUint(program, 3)]), 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1), makeUint(program, 7)]), 128); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535), makeUint(program, 2)]), 262140); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1), makeUint(program, 5)]), -32); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0), makeUint(program, 3)]), 0); > } > > tests.intRShift = function() >@@ -3397,10 +2796,10 @@ tests.intRShift = function() > return a >> b; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 1), makeUint(program, 7)]), 0); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 65535), makeUint(program, 2)]), 16383); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, -1), makeUint(program, 5)]), -1); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0), makeUint(program, 3)]), 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 1), makeUint(program, 7)]), 0); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 65535), makeUint(program, 2)]), 16383); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, -1), makeUint(program, 5)]), -1); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0), makeUint(program, 3)]), 0); > } > > tests.uintBitAnd = function() >@@ -3411,10 +2810,10 @@ tests.uintBitAnd = function() > return a & b; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1), makeUint(program, 7)]), 1); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535), makeUint(program, 42)]), 42); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1), makeUint(program, -7)]), 4294967289); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0), makeUint(program, 85732)]), 0); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1), makeUint(program, 7)]), 1); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535), makeUint(program, 42)]), 42); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1), makeUint(program, -7)]), 4294967289); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0), makeUint(program, 85732)]), 0); > } > > tests.uintBitOr = function() >@@ -3425,10 +2824,10 @@ tests.uintBitOr = function() > return a | b; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1), makeUint(program, 7)]), 7); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535), makeUint(program, 42)]), 65535); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1), makeUint(program, -7)]), 4294967295); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0), makeUint(program, 85732)]), 85732); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1), makeUint(program, 7)]), 7); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535), makeUint(program, 42)]), 65535); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1), makeUint(program, -7)]), 4294967295); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0), makeUint(program, 85732)]), 85732); > } > > tests.uintBitXor = function() >@@ -3439,10 +2838,10 @@ tests.uintBitXor = function() > return a ^ b; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1), makeUint(program, 7)]), 6); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535), makeUint(program, 42)]), 65493); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1), makeUint(program, -7)]), 6); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0), makeUint(program, 85732)]), 85732); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1), makeUint(program, 7)]), 6); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535), makeUint(program, 42)]), 65493); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1), makeUint(program, -7)]), 6); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0), makeUint(program, 85732)]), 85732); > } > > tests.uintBitNot = function() >@@ -3453,10 +2852,10 @@ tests.uintBitNot = function() > return ~a; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1)]), 4294967294); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535)]), 4294901760); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1)]), 0); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0)]), 4294967295); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1)]), 4294967294); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535)]), 4294901760); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1)]), 0); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0)]), 4294967295); > } > > tests.uintLShift = function() >@@ -3467,10 +2866,10 @@ tests.uintLShift = function() > return a << b; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1), makeUint(program, 7)]), 128); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535), makeUint(program, 2)]), 262140); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1), makeUint(program, 5)]), 4294967264); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0), makeUint(program, 3)]), 0); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1), makeUint(program, 7)]), 128); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535), makeUint(program, 2)]), 262140); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1), makeUint(program, 5)]), 4294967264); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0), makeUint(program, 3)]), 0); > } > > tests.uintRShift = function() >@@ -3481,10 +2880,10 @@ tests.uintRShift = function() > return a >> b; > } > `); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 1), makeUint(program, 7)]), 0); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 65535), makeUint(program, 2)]), 16383); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, -1), makeUint(program, 5)]), 134217727); >- checkUint(program, callFunction(program, "foo", [], [makeUint(program, 0), makeUint(program, 3)]), 0); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 1), makeUint(program, 7)]), 0); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 65535), makeUint(program, 2)]), 16383); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, -1), makeUint(program, 5)]), 134217727); >+ checkUint(program, callFunction(program, "foo", [makeUint(program, 0), makeUint(program, 3)]), 0); > } > > tests.uint8BitAnd = function() >@@ -3495,10 +2894,10 @@ tests.uint8BitAnd = function() > return a & b; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1), makeUint8(program, 7)]), 1); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535), makeUint8(program, 42)]), 42); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1), makeUint8(program, -7)]), 249); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0), makeUint8(program, 85732)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1), makeUint8(program, 7)]), 1); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535), makeUint8(program, 42)]), 42); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1), makeUint8(program, -7)]), 249); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0), makeUint8(program, 85732)]), 0); > } > > tests.uint8BitOr = function() >@@ -3509,10 +2908,10 @@ tests.uint8BitOr = function() > return a | b; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1), makeUint8(program, 7)]), 7); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535), makeUint8(program, 42)]), 255); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1), makeUint8(program, -7)]), 255); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0), makeUint8(program, 85732)]), 228); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1), makeUint8(program, 7)]), 7); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535), makeUint8(program, 42)]), 255); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1), makeUint8(program, -7)]), 255); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0), makeUint8(program, 85732)]), 228); > } > > tests.uint8BitXor = function() >@@ -3523,10 +2922,10 @@ tests.uint8BitXor = function() > return a ^ b; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1), makeUint8(program, 7)]), 6); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535), makeUint8(program, 42)]), 213); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1), makeUint8(program, -7)]), 6); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0), makeUint8(program, 85732)]), 228); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1), makeUint8(program, 7)]), 6); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535), makeUint8(program, 42)]), 213); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1), makeUint8(program, -7)]), 6); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0), makeUint8(program, 85732)]), 228); > } > > tests.uint8BitNot = function() >@@ -3537,10 +2936,10 @@ tests.uint8BitNot = function() > return ~a; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1)]), 254); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535)]), 0); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1)]), 0); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0)]), 255); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1)]), 254); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0)]), 255); > } > > tests.uint8LShift = function() >@@ -3551,10 +2950,10 @@ tests.uint8LShift = function() > return a << b; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1), makeUint(program, 7)]), 128); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535), makeUint(program, 2)]), 252); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1), makeUint(program, 5)]), 224); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0), makeUint(program, 3)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1), makeUint(program, 7)]), 128); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535), makeUint(program, 2)]), 252); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1), makeUint(program, 5)]), 224); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0), makeUint(program, 3)]), 0); > } > > tests.uint8RShift = function() >@@ -3565,10 +2964,10 @@ tests.uint8RShift = function() > return a >> b; > } > `); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 1), makeUint(program, 7)]), 0); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 65535), makeUint(program, 2)]), 255); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, -1), makeUint(program, 5)]), 255); >- checkUint8(program, callFunction(program, "foo", [], [makeUint8(program, 0), makeUint(program, 3)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 1), makeUint(program, 7)]), 0); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 65535), makeUint(program, 2)]), 255); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, -1), makeUint(program, 5)]), 255); >+ checkUint8(program, callFunction(program, "foo", [makeUint8(program, 0), makeUint(program, 3)]), 0); > } > > tests.floatMath = function() >@@ -3624,17 +3023,17 @@ tests.floatMath = function() > return float(x); > } > `); >- checkBool(program, callFunction(program, "foo", [], []), true); >- checkBool(program, callFunction(program, "foo2", [], []), true); >- checkBool(program, callFunction(program, "foo3", [], []), true); >- checkBool(program, callFunction(program, "foo4", [], []), true); >- checkBool(program, callFunction(program, "foo5", [], []), true); >- checkFloat(program, callFunction(program, "foo6", [], []), 7.5); >- checkFloat(program, callFunction(program, "foo7", [], []), 7.5); >- checkFloat(program, callFunction(program, "foo9", [], []), 7.5); >- checkFloat(program, callFunction(program, "foo10", [], []), 7.5); >- checkFloat(program, callFunction(program, "foo12", [], []), 7); >- checkFloat(program, callFunction(program, "foo13", [], []), 7.5); >+ checkBool(program, callFunction(program, "foo", []), true); >+ checkBool(program, callFunction(program, "foo2", []), true); >+ checkBool(program, callFunction(program, "foo3", []), true); >+ checkBool(program, callFunction(program, "foo4", []), true); >+ checkBool(program, callFunction(program, "foo5", []), true); >+ checkFloat(program, callFunction(program, "foo6", []), 7.5); >+ checkFloat(program, callFunction(program, "foo7", []), 7.5); >+ checkFloat(program, callFunction(program, "foo9", []), 7.5); >+ checkFloat(program, callFunction(program, "foo10", []), 7.5); >+ checkFloat(program, callFunction(program, "foo12", []), 7); >+ checkFloat(program, callFunction(program, "foo13", []), 7.5); > checkFail( > () => doPrep(` > int bar(int x) >@@ -3729,7 +3128,7 @@ tests.genericCastInfer = function() > return x.real + x.imag; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 3); >+ checkInt(program, callFunction(program, "foo", []), 3); > } > > tests.booleanMath = function() >@@ -3768,14 +3167,14 @@ tests.booleanMath = function() > return false || false; > } > `); >- checkBool(program, callFunction(program, "foo", [], []), true); >- checkBool(program, callFunction(program, "foo2", [], []), false); >- checkBool(program, callFunction(program, "foo3", [], []), false); >- checkBool(program, callFunction(program, "foo4", [], []), false); >- checkBool(program, callFunction(program, "foo5", [], []), true); >- checkBool(program, callFunction(program, "foo6", [], []), true); >- checkBool(program, callFunction(program, "foo7", [], []), true); >- checkBool(program, callFunction(program, "foo8", [], []), false); >+ checkBool(program, callFunction(program, "foo", []), true); >+ checkBool(program, callFunction(program, "foo2", []), false); >+ checkBool(program, callFunction(program, "foo3", []), false); >+ checkBool(program, callFunction(program, "foo4", []), false); >+ checkBool(program, callFunction(program, "foo5", []), true); >+ checkBool(program, callFunction(program, "foo6", []), true); >+ checkBool(program, callFunction(program, "foo7", []), true); >+ checkBool(program, callFunction(program, "foo8", []), false); > } > > tests.booleanShortcircuiting = function() >@@ -3816,10 +3215,10 @@ tests.booleanShortcircuiting = function() > } > `); > >- checkInt(program, callFunction(program, "andTrue", [], []), 2); >- checkInt(program, callFunction(program, "andFalse", [], []), 1); >- checkInt(program, callFunction(program, "orTrue", [], []), 1); >- checkInt(program, callFunction(program, "orFalse", [], []), 2); >+ checkInt(program, callFunction(program, "andTrue", []), 2); >+ checkInt(program, callFunction(program, "andFalse", []), 1); >+ checkInt(program, callFunction(program, "orTrue", []), 1); >+ checkInt(program, callFunction(program, "orFalse", []), 2); > } > > tests.typedefArray = function() >@@ -3832,7 +3231,7 @@ tests.typedefArray = function() > return arrayTypedef[0]; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 0); >+ checkInt(program, callFunction(program, "foo", []), 0); > } > > tests.shaderTypes = function() >@@ -4084,24 +3483,24 @@ tests.builtinVectors = function() > return b == c; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 3); >- checkInt(program, callFunction(program, "foo2", [], []), 4); >- checkInt(program, callFunction(program, "foo3", [], []), 3); >- checkInt(program, callFunction(program, "foo4", [], []), 5); >- checkBool(program, callFunction(program, "foo5", [], []), true); >- checkBool(program, callFunction(program, "foo6", [], []), false); >- checkUint(program, callFunction(program, "foou", [], []), 3); >- checkUint(program, callFunction(program, "foou2", [], []), 4); >- checkUint(program, callFunction(program, "foou3", [], []), 3); >- checkUint(program, callFunction(program, "foou4", [], []), 5); >- checkBool(program, callFunction(program, "foou5", [], []), true); >- checkBool(program, callFunction(program, "foou6", [], []), false); >- checkFloat(program, callFunction(program, "foof", [], []), 3); >- checkFloat(program, callFunction(program, "foof2", [], []), 4); >- checkFloat(program, callFunction(program, "foof3", [], []), 3); >- checkFloat(program, callFunction(program, "foof4", [], []), 5); >- checkBool(program, callFunction(program, "foof5", [], []), true); >- checkBool(program, callFunction(program, "foof6", [], []), false); >+ checkInt(program, callFunction(program, "foo", []), 3); >+ checkInt(program, callFunction(program, "foo2", []), 4); >+ checkInt(program, callFunction(program, "foo3", []), 3); >+ checkInt(program, callFunction(program, "foo4", []), 5); >+ checkBool(program, callFunction(program, "foo5", []), true); >+ checkBool(program, callFunction(program, "foo6", []), false); >+ checkUint(program, callFunction(program, "foou", []), 3); >+ checkUint(program, callFunction(program, "foou2", []), 4); >+ checkUint(program, callFunction(program, "foou3", []), 3); >+ checkUint(program, callFunction(program, "foou4", []), 5); >+ checkBool(program, callFunction(program, "foou5", []), true); >+ checkBool(program, callFunction(program, "foou6", []), false); >+ checkFloat(program, callFunction(program, "foof", []), 3); >+ checkFloat(program, callFunction(program, "foof2", []), 4); >+ checkFloat(program, callFunction(program, "foof3", []), 3); >+ checkFloat(program, callFunction(program, "foof4", []), 5); >+ checkBool(program, callFunction(program, "foof5", []), true); >+ checkBool(program, callFunction(program, "foof6", []), false); > } > > tests.instantiateStructInStruct = function() >@@ -4121,7 +3520,7 @@ tests.instantiateStructInStruct = function() > return x.x.x; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 43); >+ checkInt(program, callFunction(program, "foo", []), 43); > } > > tests.instantiateStructInStructWithInt2 = function() >@@ -4138,7 +3537,7 @@ tests.instantiateStructInStructWithInt2 = function() > return x.x.x; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 43); >+ checkInt(program, callFunction(program, "foo", []), 43); > } > > tests.simpleEnum = function() >@@ -4263,32 +3662,32 @@ tests.simpleEnum = function() > return Foo(intDeath()); > } > `); >- checkEnum(program, callFunction(program, "war", [], []), 0); >- checkEnum(program, callFunction(program, "famine", [], []), 1); >- checkEnum(program, callFunction(program, "pestilence", [], []), 2); >- checkEnum(program, callFunction(program, "death", [], []), 3); >- checkBool(program, callFunction(program, "testSimpleEqual", [], []), true); >- checkBool(program, callFunction(program, "testAnotherEqual", [], []), true); >- checkBool(program, callFunction(program, "testNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testSimpleNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testAnotherNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testNotNotEqual", [], []), true); >- checkInt(program, callFunction(program, "intWar", [], []), 0); >- checkInt(program, callFunction(program, "intFamine", [], []), 1); >- checkInt(program, callFunction(program, "intPestilence", [], []), 2); >- checkInt(program, callFunction(program, "intDeath", [], []), 3); >- checkInt(program, callFunction(program, "warValue", [], []), 0); >- checkInt(program, callFunction(program, "famineValue", [], []), 1); >- checkInt(program, callFunction(program, "pestilenceValue", [], []), 2); >- checkInt(program, callFunction(program, "deathValue", [], []), 3); >- checkInt(program, callFunction(program, "warValueLiteral", [], []), 0); >- checkInt(program, callFunction(program, "famineValueLiteral", [], []), 1); >- checkInt(program, callFunction(program, "pestilenceValueLiteral", [], []), 2); >- checkInt(program, callFunction(program, "deathValueLiteral", [], []), 3); >- checkEnum(program, callFunction(program, "intWarBackwards", [], []), 0); >- checkEnum(program, callFunction(program, "intFamineBackwards", [], []), 1); >- checkEnum(program, callFunction(program, "intPestilenceBackwards", [], []), 2); >- checkEnum(program, callFunction(program, "intDeathBackwards", [], []), 3); >+ checkEnum(program, callFunction(program, "war", []), 0); >+ checkEnum(program, callFunction(program, "famine", []), 1); >+ checkEnum(program, callFunction(program, "pestilence", []), 2); >+ checkEnum(program, callFunction(program, "death", []), 3); >+ checkBool(program, callFunction(program, "testSimpleEqual", []), true); >+ checkBool(program, callFunction(program, "testAnotherEqual", []), true); >+ checkBool(program, callFunction(program, "testNotEqual", []), false); >+ checkBool(program, callFunction(program, "testSimpleNotEqual", []), false); >+ checkBool(program, callFunction(program, "testAnotherNotEqual", []), false); >+ checkBool(program, callFunction(program, "testNotNotEqual", []), true); >+ checkInt(program, callFunction(program, "intWar", []), 0); >+ checkInt(program, callFunction(program, "intFamine", []), 1); >+ checkInt(program, callFunction(program, "intPestilence", []), 2); >+ checkInt(program, callFunction(program, "intDeath", []), 3); >+ checkInt(program, callFunction(program, "warValue", []), 0); >+ checkInt(program, callFunction(program, "famineValue", []), 1); >+ checkInt(program, callFunction(program, "pestilenceValue", []), 2); >+ checkInt(program, callFunction(program, "deathValue", []), 3); >+ checkInt(program, callFunction(program, "warValueLiteral", []), 0); >+ checkInt(program, callFunction(program, "famineValueLiteral", []), 1); >+ checkInt(program, callFunction(program, "pestilenceValueLiteral", []), 2); >+ checkInt(program, callFunction(program, "deathValueLiteral", []), 3); >+ checkEnum(program, callFunction(program, "intWarBackwards", []), 0); >+ checkEnum(program, callFunction(program, "intFamineBackwards", []), 1); >+ checkEnum(program, callFunction(program, "intPestilenceBackwards", []), 2); >+ checkEnum(program, callFunction(program, "intDeathBackwards", []), 3); > } > > tests.enumWithManualValues = function() >@@ -4317,10 +3716,10 @@ tests.enumWithManualValues = function() > return Foo.Death; > } > `); >- checkEnum(program, callFunction(program, "war", [], []), 72); >- checkEnum(program, callFunction(program, "famine", [], []), 0); >- checkEnum(program, callFunction(program, "pestilence", [], []), 23); >- checkEnum(program, callFunction(program, "death", [], []), -42); >+ checkEnum(program, callFunction(program, "war", []), 72); >+ checkEnum(program, callFunction(program, "famine", []), 0); >+ checkEnum(program, callFunction(program, "pestilence", []), 23); >+ checkEnum(program, callFunction(program, "death", []), -42); > } > > tests.enumWithoutZero = function() >@@ -4377,10 +3776,10 @@ tests.enumWithSomeManualValues = function() > return Foo.Death; > } > `); >- checkEnum(program, callFunction(program, "war", [], []), 72); >- checkEnum(program, callFunction(program, "famine", [], []), 73); >- checkEnum(program, callFunction(program, "pestilence", [], []), 0); >- checkEnum(program, callFunction(program, "death", [], []), 1); >+ checkEnum(program, callFunction(program, "war", []), 72); >+ checkEnum(program, callFunction(program, "famine", []), 73); >+ checkEnum(program, callFunction(program, "pestilence", []), 0); >+ checkEnum(program, callFunction(program, "death", []), 1); > } > > tests.enumConstexprGenericFunction = function() >@@ -4391,8 +3790,8 @@ tests.enumConstexprGenericFunction = function() > int testX() { return foo<Axis.X>(); } > int testY() { return foo<Axis.Y>(); } > `); >- checkInt(program, callFunction(program, "testX", [], []), 0); >- checkInt(program, callFunction(program, "testY", [], []), 1); >+ checkInt(program, callFunction(program, "testX", []), 0); >+ checkInt(program, callFunction(program, "testY", []), 1); > } > > tests.enumConstexprGenericStruct = function() >@@ -4412,8 +3811,8 @@ tests.enumConstexprGenericStruct = function() > return foo(f); > } > `); >- checkInt(program, callFunction(program, "testX", [], []), 0); >- checkInt(program, callFunction(program, "testY", [], []), 1); >+ checkInt(program, callFunction(program, "testX", []), 0); >+ checkInt(program, callFunction(program, "testY", []), 1); > } > > tests.trap = function() >@@ -4439,14 +3838,14 @@ tests.trap = function() > } > `); > checkFail( >- () => callFunction(program, "foo", [], []), >+ () => callFunction(program, "foo", []), > e => e instanceof WTrapError); >- checkInt(program, callFunction(program, "foo2", [], [makeInt(program, 1)]), 4); >+ checkInt(program, callFunction(program, "foo2", [makeInt(program, 1)]), 4); > checkFail( >- () => callFunction(program, "foo2", [], [makeInt(program, 3)]), >+ () => callFunction(program, "foo2", [makeInt(program, 3)]), > e => e instanceof WTrapError); > checkFail( >- () => callFunction(program, "foo3", [], []), >+ () => callFunction(program, "foo3", []), > e => e instanceof WTrapError); > } > >@@ -4470,9 +3869,9 @@ tests.swizzle = function() > return quix.z; > } > `); >- checkFloat(program, callFunction(program, "foo", [], []), 3); >- checkFloat(program, callFunction(program, "foo2", [], []), 6); >- checkFloat(program, callFunction(program, "foo3", [], []), 4); >+ checkFloat(program, callFunction(program, "foo", []), 3); >+ checkFloat(program, callFunction(program, "foo2", []), 6); >+ checkFloat(program, callFunction(program, "foo3", []), 4); > } > > tests.enumWithExplicitIntBase = function() >@@ -4597,32 +3996,32 @@ tests.enumWithExplicitIntBase = function() > return Foo(intDeath()); > } > `); >- checkEnum(program, callFunction(program, "war", [], []), 0); >- checkEnum(program, callFunction(program, "famine", [], []), 1); >- checkEnum(program, callFunction(program, "pestilence", [], []), 2); >- checkEnum(program, callFunction(program, "death", [], []), 3); >- checkBool(program, callFunction(program, "testSimpleEqual", [], []), true); >- checkBool(program, callFunction(program, "testAnotherEqual", [], []), true); >- checkBool(program, callFunction(program, "testNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testSimpleNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testAnotherNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testNotNotEqual", [], []), true); >- checkInt(program, callFunction(program, "intWar", [], []), 0); >- checkInt(program, callFunction(program, "intFamine", [], []), 1); >- checkInt(program, callFunction(program, "intPestilence", [], []), 2); >- checkInt(program, callFunction(program, "intDeath", [], []), 3); >- checkInt(program, callFunction(program, "warValue", [], []), 0); >- checkInt(program, callFunction(program, "famineValue", [], []), 1); >- checkInt(program, callFunction(program, "pestilenceValue", [], []), 2); >- checkInt(program, callFunction(program, "deathValue", [], []), 3); >- checkInt(program, callFunction(program, "warValueLiteral", [], []), 0); >- checkInt(program, callFunction(program, "famineValueLiteral", [], []), 1); >- checkInt(program, callFunction(program, "pestilenceValueLiteral", [], []), 2); >- checkInt(program, callFunction(program, "deathValueLiteral", [], []), 3); >- checkEnum(program, callFunction(program, "intWarBackwards", [], []), 0); >- checkEnum(program, callFunction(program, "intFamineBackwards", [], []), 1); >- checkEnum(program, callFunction(program, "intPestilenceBackwards", [], []), 2); >- checkEnum(program, callFunction(program, "intDeathBackwards", [], []), 3); >+ checkEnum(program, callFunction(program, "war", []), 0); >+ checkEnum(program, callFunction(program, "famine", []), 1); >+ checkEnum(program, callFunction(program, "pestilence", []), 2); >+ checkEnum(program, callFunction(program, "death", []), 3); >+ checkBool(program, callFunction(program, "testSimpleEqual", []), true); >+ checkBool(program, callFunction(program, "testAnotherEqual", []), true); >+ checkBool(program, callFunction(program, "testNotEqual", []), false); >+ checkBool(program, callFunction(program, "testSimpleNotEqual", []), false); >+ checkBool(program, callFunction(program, "testAnotherNotEqual", []), false); >+ checkBool(program, callFunction(program, "testNotNotEqual", []), true); >+ checkInt(program, callFunction(program, "intWar", []), 0); >+ checkInt(program, callFunction(program, "intFamine", []), 1); >+ checkInt(program, callFunction(program, "intPestilence", []), 2); >+ checkInt(program, callFunction(program, "intDeath", []), 3); >+ checkInt(program, callFunction(program, "warValue", []), 0); >+ checkInt(program, callFunction(program, "famineValue", []), 1); >+ checkInt(program, callFunction(program, "pestilenceValue", []), 2); >+ checkInt(program, callFunction(program, "deathValue", []), 3); >+ checkInt(program, callFunction(program, "warValueLiteral", []), 0); >+ checkInt(program, callFunction(program, "famineValueLiteral", []), 1); >+ checkInt(program, callFunction(program, "pestilenceValueLiteral", []), 2); >+ checkInt(program, callFunction(program, "deathValueLiteral", []), 3); >+ checkEnum(program, callFunction(program, "intWarBackwards", []), 0); >+ checkEnum(program, callFunction(program, "intFamineBackwards", []), 1); >+ checkEnum(program, callFunction(program, "intPestilenceBackwards", []), 2); >+ checkEnum(program, callFunction(program, "intDeathBackwards", []), 3); > } > > tests.enumWithUintBase = function() >@@ -4747,32 +4146,32 @@ tests.enumWithUintBase = function() > return Foo(uintDeath()); > } > `); >- checkEnum(program, callFunction(program, "war", [], []), 0); >- checkEnum(program, callFunction(program, "famine", [], []), 1); >- checkEnum(program, callFunction(program, "pestilence", [], []), 2); >- checkEnum(program, callFunction(program, "death", [], []), 3); >- checkBool(program, callFunction(program, "testSimpleEqual", [], []), true); >- checkBool(program, callFunction(program, "testAnotherEqual", [], []), true); >- checkBool(program, callFunction(program, "testNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testSimpleNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testAnotherNotEqual", [], []), false); >- checkBool(program, callFunction(program, "testNotNotEqual", [], []), true); >- checkUint(program, callFunction(program, "uintWar", [], []), 0); >- checkUint(program, callFunction(program, "uintFamine", [], []), 1); >- checkUint(program, callFunction(program, "uintPestilence", [], []), 2); >- checkUint(program, callFunction(program, "uintDeath", [], []), 3); >- checkUint(program, callFunction(program, "warValue", [], []), 0); >- checkUint(program, callFunction(program, "famineValue", [], []), 1); >- checkUint(program, callFunction(program, "pestilenceValue", [], []), 2); >- checkUint(program, callFunction(program, "deathValue", [], []), 3); >- checkUint(program, callFunction(program, "warValueLiteral", [], []), 0); >- checkUint(program, callFunction(program, "famineValueLiteral", [], []), 1); >- checkUint(program, callFunction(program, "pestilenceValueLiteral", [], []), 2); >- checkUint(program, callFunction(program, "deathValueLiteral", [], []), 3); >- checkEnum(program, callFunction(program, "uintWarBackwards", [], []), 0); >- checkEnum(program, callFunction(program, "uintFamineBackwards", [], []), 1); >- checkEnum(program, callFunction(program, "uintPestilenceBackwards", [], []), 2); >- checkEnum(program, callFunction(program, "uintDeathBackwards", [], []), 3); >+ checkEnum(program, callFunction(program, "war", []), 0); >+ checkEnum(program, callFunction(program, "famine", []), 1); >+ checkEnum(program, callFunction(program, "pestilence", []), 2); >+ checkEnum(program, callFunction(program, "death", []), 3); >+ checkBool(program, callFunction(program, "testSimpleEqual", []), true); >+ checkBool(program, callFunction(program, "testAnotherEqual", []), true); >+ checkBool(program, callFunction(program, "testNotEqual", []), false); >+ checkBool(program, callFunction(program, "testSimpleNotEqual", []), false); >+ checkBool(program, callFunction(program, "testAnotherNotEqual", []), false); >+ checkBool(program, callFunction(program, "testNotNotEqual", []), true); >+ checkUint(program, callFunction(program, "uintWar", []), 0); >+ checkUint(program, callFunction(program, "uintFamine", []), 1); >+ checkUint(program, callFunction(program, "uintPestilence", []), 2); >+ checkUint(program, callFunction(program, "uintDeath", []), 3); >+ checkUint(program, callFunction(program, "warValue", []), 0); >+ checkUint(program, callFunction(program, "famineValue", []), 1); >+ checkUint(program, callFunction(program, "pestilenceValue", []), 2); >+ checkUint(program, callFunction(program, "deathValue", []), 3); >+ checkUint(program, callFunction(program, "warValueLiteral", []), 0); >+ checkUint(program, callFunction(program, "famineValueLiteral", []), 1); >+ checkUint(program, callFunction(program, "pestilenceValueLiteral", []), 2); >+ checkUint(program, callFunction(program, "deathValueLiteral", []), 3); >+ checkEnum(program, callFunction(program, "uintWarBackwards", []), 0); >+ checkEnum(program, callFunction(program, "uintFamineBackwards", []), 1); >+ checkEnum(program, callFunction(program, "uintPestilenceBackwards", []), 2); >+ checkEnum(program, callFunction(program, "uintDeathBackwards", []), 3); > } > > tests.enumFloatBase = function() >@@ -4818,7 +4217,7 @@ tests.emptyStruct = function() > return 46; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 46); >+ checkInt(program, callFunction(program, "foo", []), 46); > } > > tests.enumStructBase = function() >@@ -4857,9 +4256,9 @@ tests.simpleSwitch = function() > } > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 767)]), 27); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 69)]), 7624); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0)]), 49); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 767)]), 27); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 69)]), 7624); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0)]), 49); > } > > tests.exhaustiveUint8Switch = function() >@@ -4870,7 +4269,7 @@ tests.exhaustiveUint8Switch = function() > text += "} }"; > let program = doPrep(text); > for (let i = 0; i < 0xff; ++i) >- checkFloat(program, callFunction(program, "foo", [], [makeUint8(program, i)]), i * 1.5); >+ checkFloat(program, callFunction(program, "foo", [makeUint8(program, i)]), i * 1.5); > } > > tests.notQuiteExhaustiveUint8Switch = function() >@@ -4891,7 +4290,7 @@ tests.notQuiteExhaustiveUint8SwitchWithDefault = function() > text += "} }"; > let program = doPrep(text); > for (let i = 0; i < 0xff; ++i) >- checkFloat(program, callFunction(program, "foo", [], [makeUint8(program, i)]), i * 1.5); >+ checkFloat(program, callFunction(program, "foo", [makeUint8(program, i)]), i * 1.5); > } > > tests.switchFallThrough = function() >@@ -4913,9 +4312,9 @@ tests.switchFallThrough = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 767)]), 27 + 7624 + 49); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 69)]), 7624 + 49); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0)]), 49); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 767)]), 27 + 7624 + 49); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 69)]), 7624 + 49); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0)]), 49); > } > > tests.switchBreak = function() >@@ -4938,9 +4337,9 @@ tests.switchBreak = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 767)]), 27); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 69)]), 7624); >- checkInt(program, callFunction(program, "foo", [], [makeInt(program, 0)]), 49); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 767)]), 27); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 69)]), 7624); >+ checkInt(program, callFunction(program, "foo", [makeInt(program, 0)]), 49); > } > > tests.enumSwitchBreakExhaustive = function() >@@ -4966,9 +4365,9 @@ tests.enumSwitchBreakExhaustive = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "A")]), 27); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "B")]), 7624); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "C")]), 49); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "A")]), 27); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "B")]), 7624); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "C")]), 49); > } > > tests.enumSwitchBreakNotQuiteExhaustive = function() >@@ -5021,9 +4420,9 @@ tests.enumSwitchBreakNotQuiteExhaustiveWithDefault = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "A")]), 27); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "B")]), 7624); >- checkInt(program, callFunction(program, "foo", [], [makeEnum(program, "Foo", "C")]), 49); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "A")]), 27); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "B")]), 7624); >+ checkInt(program, callFunction(program, "foo", [makeEnum(program, "Foo", "C")]), 49); > } > > tests.simpleRecursiveStruct = function() >@@ -5072,7 +4471,7 @@ tests.mutuallyRecursiveStructWithPointersBroken = function() > } > `); > checkFail( >- () => checkInt(program, callFunction(program, "foo", [], []), -511), >+ () => checkInt(program, callFunction(program, "foo", []), -511), > e => e instanceof WTrapError); > } > >@@ -5098,7 +4497,7 @@ tests.mutuallyRecursiveStructWithPointers = function() > return foo.bar->bar - bar.foo->foo; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), -511); >+ checkInt(program, callFunction(program, "foo", []), -511); > } > > tests.linkedList = function() >@@ -5119,7 +4518,7 @@ tests.linkedList = function() > return x.next->next->value; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 3); >+ checkInt(program, callFunction(program, "foo", []), 3); > } > > tests.pointerToPointer = function() >@@ -5142,7 +4541,7 @@ tests.pointerToPointer = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 76 + 39 + 83); >+ checkInt(program, callFunction(program, "foo", []), 76 + 39 + 83); > } > > tests.arrayRefToArrayRef = function() >@@ -5165,7 +4564,7 @@ tests.arrayRefToArrayRef = function() > return result; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 76 + 39 + 83); >+ checkInt(program, callFunction(program, "foo", []), 76 + 39 + 83); > } > > tests.pointerGetter = function() >@@ -5246,94 +4645,6 @@ tests.setterWithMatchedType = function() > `); > } > >-tests.operatorWithUninferrableTypeVariable = function() >-{ >- checkFail( >- () => doPrep(` >- struct Foo { >- int x; >- } >- Foo operator+<T>(Foo a, Foo b) >- { >- Foo result; >- result.x = a.x + b.x; >- return result; >- } >- `), >- e => e instanceof WTypeError); >-} >- >-tests.operatorWithoutUninferrableTypeVariable = function() >-{ >- let program = doPrep(` >- struct Foo { >- int x; >- } >- Foo operator+(Foo a, Foo b) >- { >- Foo result; >- result.x = a.x + b.x; >- return result; >- } >- int foo() >- { >- Foo a; >- a.x = 645; >- Foo b; >- b.x = -35; >- return (a + b).x; >- } >- `); >- checkInt(program, callFunction(program, "foo", [], []), 645 - 35); >-} >- >-tests.operatorCastWithUninferrableTypeVariable = function() >-{ >- checkFail( >- () => doPrep(` >- struct Foo { >- int x; >- } >- operator<T> Foo(int x) >- { >- Foo result; >- result.x = x; >- return result; >- } >- `), >- e => e instanceof WTypeError); >-} >- >-tests.operatorCastWithTypeVariableInferredFromReturnType = function() >-{ >- let program = doPrep(` >- struct Foo { >- int x; >- } >- protocol Barable { >- void bar(thread Barable*, int); >- } >- void bar(thread float* result, int value) >- { >- *result = float(value); >- } >- operator<T:Barable> T(Foo foo) >- { >- T result; >- bar(&result, foo.x); >- return result; >- } >- int foo() >- { >- Foo foo; >- foo.x = 75; >- float x = float(foo); >- return int(x * 1.5); >- } >- `); >- checkInt(program, callFunction(program, "foo", [], []), 112); >-} >- > tests.incWrongArgumentLength = function() > { > checkFail( >@@ -5823,7 +5134,7 @@ tests.anderWithNothingWrong = function() > return x.foo; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 13); >+ checkInt(program, callFunction(program, "foo", []), 13); > } > > tests.anderWithWrongNumberOfArguments = function() >@@ -5897,7 +5208,7 @@ tests.anderWithArrayRef = function() > return (@x).foo; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 13); >+ checkInt(program, callFunction(program, "foo", []), 13); > } > > tests.pointerIndexGetter = function() >@@ -6083,7 +5394,7 @@ tests.indexAnderWithNothingWrong = function() > return x[666]; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 13); >+ checkInt(program, callFunction(program, "foo", []), 13); > } > > tests.indexAnderWithWrongNumberOfArguments = function() >@@ -6168,7 +5479,7 @@ tests.indexAnderWithArrayRef = function() > return (@x)[float(-1)]; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 13); >+ checkInt(program, callFunction(program, "foo", []), 13); > } > > tests.devicePtrPtr = function() >@@ -6207,306 +5518,6 @@ tests.constantPtrPtr = function() > e => e instanceof WTypeError && e.message.indexOf("Illegal pointer to non-primitive type: int32* constant* constant") != -1); > } > >-tests.pointerIndexGetterInProtocol = function() >-{ >- for (let addressSpace of addressSpaces) { >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[](${addressSpace} Foo*, uint); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Cannot have getter for pointer type") != -1); >- } >-} >- >-tests.loneIndexSetterInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- Foo operator[]=(Foo, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Every setter must have a matching getter") != -1); >-} >- >-tests.notLoneIndexSetterInProtocol = function() >-{ >- doPrep(` >- protocol Foo { >- int operator[](Foo, uint); >- Foo operator[]=(Foo, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `); >-} >- >-tests.indexSetterWithMismatchedTypeInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- float operator[](Foo, uint); >- Foo operator[]=(Foo, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Setter and getter must agree on value type") != -1); >-} >- >-tests.indexOperatorWrongArgumentLengthInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[](); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Protocol's type variable (Foo) not mentioned in signature") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[](Foo); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[](Foo, int, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters") != -1); >-} >- >-tests.indexOperatorSetterWrongArgumentLengthInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[]=(); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Protocol's type variable (Foo) not mentioned in signature") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[]=(Foo); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[]=(Foo, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[]=(Foo, int, int, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters") != -1); >-} >- >-tests.loneIndexSetterPointerInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- thread int* operator[]=(thread Foo* ptr, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Cannot have setter for pointer type") != -1); >-} >- >-tests.indexSetterWithNoGetterOverloadInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator[](int, Foo); >- Foo operator[]=(Foo, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Did not find function named operator[]= with arguments Foo,uint32") != -1); >-} >- >-tests.indexSetterWithNoGetterOverloadFixedInProtocol = function() >-{ >- doPrep(` >- protocol Foo { >- int operator[](Foo, uint); >- Foo operator[]=(Foo, uint, int); >- } >- struct Bar { } >- int operator[](Bar, uint) { return 42; } >- Bar operator[]=(Bar, uint, int) { return Bar(); } >- `); >-} >- >-tests.indexAnderWithNothingWrongInProtocol = function() >-{ >- let program = doPrep(` >- protocol Foo { >- thread int* operator&[](thread Foo* foo, uint); >- } >- int bar<T:Foo>(T x) >- { >- return x[42]; >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- int foo() >- { >- return bar(Bar()); >- } >- `); >- checkInt(program, callFunction(program, "foo", [], []), 1234); >-} >- >-tests.indexAnderWithWrongNumberOfArgumentsInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- thread int* operator&[](); >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Protocol's type variable (Foo) not mentioned in signature") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- thread int* operator&[](thread Foo* foo); >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters for operator&[]") != -1); >- checkFail( >- () => doPrep(` >- protocol Foo { >- thread int* operator&[](thread Foo* foo, uint, uint); >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Incorrect number of parameters for operator&[]") != -1); >-} >- >-tests.indexAnderDoesntReturnPointerInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- int operator&[](thread Foo* foo, uint); >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Return type of ander is not a pointer") != -1); >-} >- >-tests.indexAnderDoesntTakeReferenceInProtocol = function() >-{ >- checkFail( >- () => doPrep(` >- protocol Foo { >- thread int* operator&[](Foo foo, uint); >- } >- struct Bar { } >- thread int* operator&[](thread Bar*, uint) >- { >- int result = 1234; >- return &result; >- } >- `), >- e => e instanceof WTypeError && e.message.indexOf("Parameter to ander is not a reference") != -1); >-} >- >-tests.indexAnderWithArrayRefInProtocol = function() >-{ >- let program = doPrep(` >- protocol Foo { >- thread int* operator&[](thread Foo[] array, float index); >- } >- int bar<T:Foo>(thread T[] x) >- { >- return x[1.5]; >- } >- struct Bar { } >- thread int* operator&[](thread Bar[], float) >- { >- int result = 1234; >- return &result; >- } >- int foo() >- { >- Bar x; >- return bar(@x); >- } >- `); >- checkInt(program, callFunction(program, "foo", [], []), 1234); >-} >- > tests.andReturnedArrayRef = function() > { > let program = doPrep(` >@@ -6522,7 +5533,7 @@ tests.andReturnedArrayRef = function() > return *ptr; > } > `); >- checkInt(program, callFunction(program, "foo", [], []), 354); >+ checkInt(program, callFunction(program, "foo", []), 354); > } > > okToTest = true; >diff --git a/Tools/WebGPUShadingLanguageRI/Type.js b/Tools/WebGPUShadingLanguageRI/Type.js >index 7c287918953a5b1d5e35e850e330f389df6e76e8..21a331958e134bd995803bda81fcccc1efb44c6d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Type.js >+++ b/Tools/WebGPUShadingLanguageRI/Type.js >@@ -25,7 +25,6 @@ > "use strict"; > > class Type extends Node { >- get typeParameters() { return []; } > get kind() { return Type; } > get isPtr() { return false; } > get isArray() { return false; } >@@ -37,15 +36,6 @@ class Type extends Node { > get isEnum() { return false; } > get isPrimitive() { return false; } > >- inherits(protocol) >- { >- if (!protocol) >- return {result: true}; >- return protocol.hasHeir(this); >- } >- >- get instantiatedType() { return this.visit(new InstantiateImmediates()); } >- > // Have to call these on the unifyNode. > argumentForAndOverload(origin, value) > { >diff --git a/Tools/WebGPUShadingLanguageRI/TypeDef.js b/Tools/WebGPUShadingLanguageRI/TypeDef.js >index 6c0f9c174f53235641f4cd302cab4c3aab27c143..d7b00cd2c73eb3a5a88234bf29dc3a6ac7b71c3f 100644 >--- a/Tools/WebGPUShadingLanguageRI/TypeDef.js >+++ b/Tools/WebGPUShadingLanguageRI/TypeDef.js >@@ -25,23 +25,21 @@ > "use strict"; > > class TypeDef extends Type { >- constructor(origin, name, typeParameters, type) >+ constructor(origin, name, type) > { > super(); > this._origin = origin; > this._name = name; >- this._typeParameters = typeParameters; > this._type = type; > } > > get origin() { return this._origin; } > get name() { return this._name; } >- get typeParameters() { return this._typeParameters; } > get type() { return this._type; } > > toString() > { >- return "typedef " + this.name + "<" + this.typeParameters + "> = " + this.type; >+ return "typedef " + this.name + " = " + this.type; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js b/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js >index a81eab42d948fca3e930c6857a964ddccfcee57f..082e72f9f842224691704986a0af29a682cf111f 100644 >--- a/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js >@@ -48,7 +48,7 @@ class TypeDefResolver extends Visitor { > > let newType = node.type.type.substituteToUnification(node.type.typeParameters, unificationContext); > newType.visit(this); >- node.setTypeAndArguments(newType, []); >+ node.setType(newType); > } > }); > } >diff --git a/Tools/WebGPUShadingLanguageRI/TypeParameterRewriter.js b/Tools/WebGPUShadingLanguageRI/TypeParameterRewriter.js >deleted file mode 100644 >index 3bd037c927275160fc45eb2f9a86691777116ba0..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/TypeParameterRewriter.js >+++ /dev/null >@@ -1,38 +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"; >- >-class TypeParameterRewriter { >- visitConstexprTypeParameter(node) >- { >- return new ConstexprTypeParameter(node.origin, node.name, node.type.visit(new Rewriter())); >- } >- >- visitTypeVariable(node) >- { >- return new TypeVariable(node.origin, node.name, node.protocol); >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/TypeRef.js b/Tools/WebGPUShadingLanguageRI/TypeRef.js >index f2b322f3af6a73086141e56d693efce1c351dafc..4f749b740858293a97eb4a8133cef7bb8f09b05b 100644 >--- a/Tools/WebGPUShadingLanguageRI/TypeRef.js >+++ b/Tools/WebGPUShadingLanguageRI/TypeRef.js >@@ -25,69 +25,58 @@ > "use strict"; > > class TypeRef extends Type { >- constructor(origin, name, typeArguments) >+ constructor(origin, name) > { > super(); > this._origin = origin; > this._name = name; > this.type = null; >- this._typeArguments = typeArguments; > } > > static wrap(type) > { >- if (type instanceof TypeRef && !type.typeArguments) >+ if (type instanceof TypeRef) > return type; > let name = type.name; >- let result = new TypeRef(type.origin, name, []); >+ let result = new TypeRef(type.origin, name); > result.type = type; > return result; > } > >- static instantiate(type, typeArguments) >+ static instantiate(type) > { >- let result = new TypeRef(type.origin, type.name, typeArguments); >+ let result = new TypeRef(type.origin, type.name); > result.type = type; > return result; > } > > get origin() { return this._origin; } > get name() { return this._name; } >- get typeArguments() { return this._typeArguments; } > > get unifyNode() > { >- if (!this.typeArguments.length) >- return this.type.unifyNode; >- return this; >+ return this.type.unifyNode; > } > > populateDefaultValue(buffer, offset) > { >- if (!this.typeArguments.length) >- return this.type.populateDefaultValue(buffer, offset); >- throw new Error("Cannot get default value of a type instantiation"); >+ return this.type.populateDefaultValue(buffer, offset); > } > > get size() > { >- if (!this.typeArguments.length) >- return this.type.size; >- throw new Error("Cannot get size of a type instantiation"); >+ return this.type.size; > } > > get isPrimitive() > { >- if (!this.typeArguments.length) >- return this.type.isPrimitive; >- throw new Error("Cannot determine if an uninstantiated type is primitive: " + this); >+ return this.type.isPrimitive; > } > >- setTypeAndArguments(type, typeArguments) >+ setType(type) > { > this._name = null; > this.type = type; >- this._typeArguments = typeArguments; > } > > unifyImpl(unificationContext, other) >@@ -96,12 +85,6 @@ class TypeRef extends Type { > return false; > if (!this.type.unify(unificationContext, other.type)) > return false; >- if (this.typeArguments.length != other.typeArguments.length) >- return false; >- for (let i = 0; i < this.typeArguments.length; ++i) { >- if (!this.typeArguments[i].unify(unificationContext, other.typeArguments[i])) >- return false; >- } > return true; > } > >@@ -109,9 +92,7 @@ class TypeRef extends Type { > { > if (!this.name) > return this.type.toString(); >- if (!this.typeArguments.length) >- return this.name; >- return this.name + "<" + this.typeArguments + ">"; >+ return this.name; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/TypeVariable.js b/Tools/WebGPUShadingLanguageRI/TypeVariable.js >deleted file mode 100644 >index 33218a959f51d1eeb9d0514b950dec9672fa0b7e..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/TypeVariable.js >+++ /dev/null >@@ -1,106 +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"; >- >-class TypeVariable extends Type { >- constructor(origin, name, protocol) >- { >- super(); >- this._origin = origin; >- this._name = name; >- this._protocol = protocol; >- } >- >- get origin() { return this._origin; } >- get name() { return this._name; } >- get protocol() { return this._protocol; } >- >- get isPrimitive() >- { >- return this._protocol && this._protocol.isPrimitive; >- } >- >- get isUnifiable() { return true; } >- >- inherits(protocol) >- { >- if (!protocol) >- return {result: true}; >- if (!this.protocol) >- return {result: false, reason: "Type variable " + this + " does not have a protocol"}; >- return this.protocol.inherits(protocol); >- } >- >- typeVariableUnify(unificationContext, other) >- { >- if (!(other instanceof Type)) >- return false; >- >- return this._typeVariableUnifyImpl(unificationContext, other); >- } >- >- unifyImpl(unificationContext, other) >- { >- return this.typeVariableUnify(unificationContext, other); >- } >- >- verifyAsArgument(unificationContext) >- { >- let realThis = unificationContext.find(this); >- >- // The thing we get unified with must be a type variable that accepts a broader set of >- // things than we do. >- if (!(realThis instanceof TypeVariable)) >- return {result: false, reason: "Type variable argument " + this + " cannot be passed to non-type-variable parameter type " + realThis}; >- >- if (!this.protocol) { >- if (realThis.protocol) >- return {result: false, reason: "Type variable without protocol " + this + " cannot be passed to parameter type variable with protocol " + realThis.protocol}; >- return {result: true}; >- } >- >- let result = this.protocol.inherits(realThis.protocol); >- if (!result.result) >- return {result: false, reason: "Protocol " + this.protocol + " does not subsume protocol " + realThis.protocol + " (passing type " + this + " to type " + realThis + "): " + result.reason}; >- return {result: true}; >- } >- >- verifyAsParameter(unificationContext) >- { >- if (!this.protocol) >- return {result: true}; >- let realThis = unificationContext.find(this); >- let result = realThis.inherits(this.protocol); >- if (!result.result) >- return {result: false, reason: "Type " + realThis + " does not inherit protocol " + this.protocol + " (passing type " + realThis + " to type " + this + "): " + result.reason}; >- return {result: true}; >- } >- >- toString() >- { >- return this.name + (this.protocol ? ":" + this.protocol.name : ""); >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/TypeVariableTracker.js b/Tools/WebGPUShadingLanguageRI/TypeVariableTracker.js >deleted file mode 100644 >index 2e9e29aae1454927cd0d5139c0852391f835f7c7..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/TypeVariableTracker.js >+++ /dev/null >@@ -1,57 +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"; >- >-class TypeVariableTracker extends Visitor { >- constructor() >- { >- super(); >- this._set = new Set(); >- } >- >- get set() { return this._set; } >- >- _consider(thing) >- { >- if (thing.isUnifiable) >- this._set.add(thing); >- } >- >- visitTypeRef(node) >- { >- if (node.typeArguments.length) { >- for (let typeArgument of node.typeArguments) >- typeArgument.visit(this); >- return; >- } >- this._consider(node.type); >- } >- >- visitVariableRef(node) >- { >- this._consider(node.variable); >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/Visitor.js b/Tools/WebGPUShadingLanguageRI/Visitor.js >index 4bf05313e2857d71efe513ee1e35f050def5336d..e864f43e650f204e4533bb59be4103a95be9b8a8 100644 >--- a/Tools/WebGPUShadingLanguageRI/Visitor.js >+++ b/Tools/WebGPUShadingLanguageRI/Visitor.js >@@ -40,11 +40,6 @@ class Visitor { > parameter.visit(this); > } > >- visitProtocolFuncDecl(node) >- { >- this.visitFunc(node); >- } >- > visitFuncParameter(node) > { > node.type.visit(this); >@@ -79,18 +74,6 @@ class Visitor { > expression.visit(this); > } > >- visitProtocolRef(node) >- { >- } >- >- visitProtocolDecl(node) >- { >- for (let protocol of node.extends) >- protocol.visit(this); >- for (let signature of node.signatures) >- signature.visit(this); >- } >- > visitTypeRef(node) > { > for (let typeArgument of node.typeArguments) >@@ -125,16 +108,6 @@ class Visitor { > field.visit(this); > } > >- visitTypeVariable(node) >- { >- Node.visit(node.protocol, this); >- } >- >- visitConstexprTypeParameter(node) >- { >- node.type.visit(this); >- } >- > visitField(node) > { > node.type.visit(this); >@@ -340,14 +313,6 @@ class Visitor { > typeArgument.visit(this); > for (let argument of node.argumentList) > Node.visit(argument, this); >- let handleTypeArguments = actualTypeArguments => { >- if (actualTypeArguments) { >- for (let argument of actualTypeArguments) >- argument.visit(this); >- } >- }; >- handleTypeArguments(node.actualTypeArguments); >- handleTypeArguments(node.instantiatedActualTypeArguments); > Node.visit(node.nativeFuncInstance, this); > Node.visit(node.returnType, this); > Node.visit(node.resultType, this); >diff --git a/Tools/WebGPUShadingLanguageRI/WSL.md b/Tools/WebGPUShadingLanguageRI/WSL.md >deleted file mode 100644 >index d3b66567826a51dd6c754d4e9b24d7578972bb3d..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/WSL.md >+++ /dev/null >@@ -1,479 +0,0 @@ >-# WebGPU Shading Language >- >-WebGPU Shading Language, or WSL for short, is a type-safe low-overhead programming language for GPUs (graphics processing units). This document explains how WSL works. >- >-# Goals >- >-WSL is designed to achieve the following goals: >- >-- WSL should feel *familiar* to C++ programmers. >-- WSL should be have a *sound* and *decidable* type system. >-- WSL should not permit *out-of-bounds* memory accesses. >-- WSL should be have *low overhead*. >- >-The combination of a sound type system and bounds checking makes WSL a secure shader language: the language itself is responsible for isolating the shader from the rest of the GPU. >- >-# Familiar Syntax >- >-WSL is based on C syntax, but excludes features that are either unnecessary, insecure, or replaced by other WSL features: >- >-- No strings. >-- No `register`, `volatile`, `const`, `restrict`, or `extern` keywords. >-- No unions. `union` is not a keyword. >-- No goto or labels. `goto` is not a keyword. >-- No `*` pointers. >-- Effectless expressions are not statements (`a + b;` is a parse error). >-- No undefined values (`int x;` initializes x to 0). >-- No automatic type conversions (`int x; uint y = x;` is a type error). >-- No recursion. >-- No dynamic memory allocation. >-- No modularity. The whole program is one file. >- >-On top of this bare C-like foundation, WSL adds secure versions of familiar C++ features: >- >-- Type-safe pointers (`^`) and array references (`[]`). >-- Generics to replace templates. >-- Operator overloading. Built-in operations like `int operator+(int, int)` are just native functions. >-- Cast overloading. Built-in casts like `operator int(double)` are just native functions. >-- Getters and setters. Property accesses like `vec.x` resolve to overloads like `float operator.field(float4)`. >-- Array access overloading. Array accesses like `vec[0]` resolve to verloads like `float operator[](float4, uint)`. >- >-In the following sections, WSL is shown by example starting with its C-like foundation and then building up to include more sophisticated features like generics. >- >-## Common subset of C and WSL >- >-The following is a valid WSL function definition: >- >- int foo(int x, int y, bool p) >- { >- if (p) >- return x - y; >- return x + y; >- } >- >-WSL source files behave similarly to C source files: >- >-- Top-level statements must be type or function definitions. >-- WSL uses structured C control flow constructs, like `if`, `while`, `for`, `do`, `break`, and `continue`. >-- WSL uses C-like `switch` statements, but does not allow them to overlap other control flow (i.e. no [Duff's device](https://en.wikipedia.org/wiki/Duff%27s_device)). >-- WSL allows variable declarations anywhere C++ would. >- >-WSL types differ from C types. For example, this is an array of 42 integers in WSL: >- >- int[42] array; >- >-The type never surrounds the variable, like it would in C (`int array[42]`). >- >-## Type-safe pointers >- >-WSL includes a secure pointer type. To emphasize that it is not like the C pointer, WSL uses `^` for the pointer type and for dereference. Like in C, `&` is used to take the address of a value. Because GPUs have different kinds of memories, pointers must be annotated with an address space (one of `thread`, `threadgroup`, `device`, or `constant`). For example: >- >- void bar(thread int^ p) >- { >- ^p += 42; >- } >- int foo() >- { >- int x = 24; >- bar(&x); >- return x; // Returns 66. >- } >- >-Pointers can be `null`. Each pointer access is null-checked, though most pointer accesses (like this one) will not have a null check. WSL places enough constraints on the programmer that programs are easy for the compiler to analyze. The compiler will always know that `^p += 42` adds `42` to `x` in this case. >- >-WSL pointers do not support casting or pointer arithmetic. All memory accessible to a shader outlives the shader. This is even true of local variables. This is possible because WSL does not support recursion. Therefore, local variables simply get global storage. Local variables are initialized at the point of their declaration. Hence, the following is a valid program, which will exhibit the same behavior on every WSL implementation: >- >- thread int^ foo() >- { >- int x = 42; >- return &x; >- } >- int bar() >- { >- thread int^ p = foo(); >- thread int^ q = foo(); >- ^p = 53; >- return ^q; // Returns 53. >- } >- int baz() >- { >- thread int^ p = foo(); >- ^p = 53; >- foo(); >- return ^p; // Returns 42. >- } >- >-It's possible to point to any kind of data type. For example, `thread double[42]^` is a pointer to an array of 42 doubles. >- >-## Type-safe array references >- >-WSL supports array references that carry a pointer to the base of the array and the array's length. This allows accesses to the array to be bounds-checked. >- >-An array reference can be created using the `@` operator: >- >- int[42] array; >- thread int[] arrayRef = @array; >- >-Both arrays and array references can be loaded from and stored to using `operator[]`: >- >- int x = array[i]; >- int y = arrayRef[i]; >- >-Both arrays and array references know their length: >- >- uint arrayLength = array.length; >- uint arrayRefLength = arrayRef.length; >- >-Given an array or array reference, it's possible to get a pointer to one of its elements: >- >- thread int^ ptr1 = &array[i]; >- thread int^ ptr2 = &arrayRef[i]; >- >-A pointer is like an array reference with one element. It's possible to perform this conversion: >- >- thread int[] ref = @ptr1; >- ref[0] // Equivalent to ^ptr1. >- ref.length // 0 if ptr1 was null, 1 if ptr1 was not null. >- >-Similarly, using `@` on a non-pointer value results in a reference of length 1: >- >- int x; >- thread int[] ref = @x; >- ref[0] // Aliases x. >- ref.length // Returns 1. >- >-It's not legal to use `@` on an array reference: >- >- thread int[] ref; >- thread int[][] referef = @ref; // Error! >- >-## Generics >- >-WSL supports generic types using a simple syntax. WSL's generic are designed to integrate cleanly into the compiler pipeline: >- >-- Generics have unambiguous syntax. >-- Generic functions can be type checked before they are instantiated. >- >-Semantic errors inside generic functions show up once regardless of the number of times the generic function is instantiated. >- >-This is a simple generic function: >- >- T identity<T>(T value) >- { >- T tmp = value; >- return tmp; >- } >- >-WSL also supports structs, which are also allowed to be generic: >- >- // Not generic. >- struct Foo { >- int x; >- double y; >- } >- // Generic. >- struct Bar<T, U> { >- T x; >- U y; >- } >- >-Type parameters can also be constant expressions. For example: >- >- void initializeArray<T, uint length>(thread T[length]^ array, T value) >- { >- for (uint i = length; i--;) >- (^array)[i] = value; >- } >- >-Constant expressions passed as type arguments must obey a very narrow definition of constantness. Only literals and references to other constant parameters qualify. >- >-WSL is guaranteed to compile generics by instantiation. This is observable, since functions can return pointers to their locals. Here is an example of this phenomenon: >- >- thread int^ allocate<uint>() >- { >- int x; >- return &x; >- } >- >-The `allocate` function will return a different pointer for each unsigned integer constant passed as a type parameter. This allocation is completely static, since the `uint` parameter must be given a compile-time constant. >- >-WSL's `typedef` uses a slightly different syntax than C. For example: >- >- struct Complex<T> { >- T real; >- T imag; >- } >- typedef FComplex = Complex<float>; >- >-`typedef` can be used to create generic types: >- >- struct Foo<T, U> { >- T x; >- U y; >- } >- typedef Bar<T> = Foo<T, T>; >- >-## Protocols >- >-Protocols enable generic functions to work with data of generic type. Because a function must be type-checkable before instantiation, the following would not be legal: >- >- int bar(int) { ... } >- double bar(double) { ... } >- >- T foo<T>(T value) >- { >- return bar(value); // Error! >- } >- >-The call to `bar` doesn't type check because the compiler cannot know that `foo<T>` will be instantiated with `T = int` or `T = double`. Protocols enable the programmer to tell the compiler what to expect of a type variable: >- >- int bar(int) { ... } >- double bar(double) { ... } >- >- protocol SupportsBar { >- SupportsBar bar(SupportsBar); >- } >- >- T foo<T:SupportsBar>(T value) >- { >- return bar(value); >- } >- >- int x = foo(42); >- double y = foo(4.2); >- >-Protocols have automatic relationships to one another based on what functions they contain: >- >- protocol Foo { >- void foo(Foo); >- } >- protocol Bar { >- void foo(Bar); >- void bar(Bar); >- } >- void fuzz<T:Foo>(T x) { ... } >- void buzz<T:Bar>(T x) >- { >- fuzz(x); // OK, because Bar is more specific than Foo. >- } >- >-Protocols can also mix other protocols in explicitly. Like in the example above, the example below relies on the fact that `Bar` is a more specific protocol than `Foo`. However, this example declares this explicitly (`protocol Bar : Foo`) instead of relying on the language to infer it: >- >- protocol Foo { >- void foo(Foo); >- } >- protocol Bar : Foo { >- void bar(Bar); >- } >- void fuzz<T:Foo>(T x) { ... } >- void buzz<T:Bar>(T x) >- { >- fuzz(x); // OK, because Bar is more specific than Foo. >- } >- >-## Overloading >- >-WSL supports overloading very similarly to how C++ does it. For example: >- >- void foo(int); // 1 >- void foo(double); // 2 >- >- int x; >- foo(x); // calls 1 >- >- double y; >- foo(y); // calls 2 >- >-WSL automatically selects the most specific overload if given multiple choices. For example: >- >- void foo(int); // 1 >- void foo(double); // 2 >- void foo<T>(T); // 3 >- >- foo(1); // calls 1 >- foo(1.); // calls 2 >- foo(1u); // calls 3 >- >-Generic functions like `foo<T>` can be called with or without all of their type arguments supplied. If they are not supplied, the function participates in overload resolution like any other function would. Functions are ranked by how specific they are; function A is more specific than function B if A's parameter types can be used as argument types for a call to B but not vice-versa. If one functions more specific than all others then this function is selected, otherwise a type error is issued. >- >-## Operator Overloading >- >-Many WSL operations desugar to calls to functions. Those functions are called *operator overloads* and are declared using syntax that involves the keyword `operator`. The following operations result in calls to operator overloads: >- >-- Numerical operators (`+`, `-`, `*`, `/`, etc.). >-- Increment and decrement (`++`, `--`). >-- Casting (`type(value)`). >-- Accessing values in arrays (`[]`, `[]=`, `&[]`). >-- Accessing fields (`.field`, `.field=`, `&.field`). >- >-WSL's operator overloading is designed to synthesize many operators for you: >- >-- Read-modify-write operators like `+=` are desugared to a load of the load value, the underlying operator (like `+`), and a store of the new value. It's not possible to override `+=`, `-=`, etc. >-- `x++` and `++x` both call the same operator overload. `operator++` takes the old value and returns a new one; for example the built-in `++` for `int` could be written as: `int operator++(int value) { return value + 1; }`. >-- `operator==` can be overloaded, but `!=` is automatically synthesized and cannot be overloaded. >- >-Some operators and overloads are restricted: >- >-- `!`, `&&`, and `||` are built-in operations on the `bool` type. >-- Self-casts (`T(T)`) are always the identity function. >-- Casts with no arguments (`T()`) always return the default value for that type. Every type has a default value (`0`, `null`, or the equivalent for each field). >- >-Cast overloading allows for supporting conversions between types and for creating constructors for custom types. Here is an example of cast overloading being used to create a constructor: >- >- struct Complex<T> { >- T real; >- T imag; >- } >- operator<T> Complex<T>(T real, T imag) >- { >- Complex<T> result; >- result.real = real; >- result.imag = imag; >- return result; >- } >- >- Complex<float> i = Complex<float>(0, 1); >- >-WSL supports accessor overloading as part of the operator overloading syntax. This gives the programmer broad powers. For example: >- >- struct Foo { >- int x; >- int y; >- } >- int operator.sum(Foo foo) >- { >- return foo.x + foo.y; >- } >- >-It's possible to say `foo.sum` to call the `operator.sum` function. Both getters and setters can be provided: >- >- struct Foo { >- int value; >- } >- double operator.doubleValue(Foo value) >- { >- return double(value.value); >- } >- Foo operator.doubleValue=(Foo value, double doubleValue) >- { >- value.value = int(doubleValue); >- return value; >- } >- >-Providing both getter and setter overloads makes `doubleValue` behave almost as if it was a field of `Foo`. For example, it's possible to say: >- >- Foo foo; >- foo.value = 42; >- foo.doubleValue *= 2; // Now foo.value is 84 >- >-It's also possible to provide an address-getting overload called an *ander*: >- >- struct Foo { >- int value; >- } >- thread int^ operator&.valueAlias(thread Foo^ foo) >- { >- return &foo->value; >- } >- >-Providing just this overload for a pointer type in every address space gives the same power as overloading getters and setters. Additionally, it makes it possible to `&foo.valueAlias`. >- >-The same overloading power is provided for array accesses. For example: >- >- struct Vector<T> { >- T x; >- T y; >- } >- thread T^ operator&[](thread T^ ptr, uint index) >- { >- return index ? &ptr->y : &ptr->x; >- } >- >-Alternatively, it's possible to overload getters and setters (`operator[]` and `operator[]=`). >- >-# Mapping of API concepts >- >-WSL is designed to be useful as both a graphics shading language and as a computation language. However, these two environments have >-slightly different semantics. >- >-When using WSL as a graphics shading language, there is a distinction between *entry-points* and *non-entry-points*. Entry points are top-level functions which have either the `vertex` or `fragment` keyword in front of their declaration. Entry points may not be forward declared. An entry point annotated with the `vertex` keyword may not be used as a fragment shader, and an entry point annotated with the `fragment` keyword may not be used as a vertex shader. No argument nor return value of an entry point may be a pointer. Entry points must not accept type arguments (also known as "generics"). >- >-## Vertex entry points >- >-WebGPU's API passes data to a WSL vertex shader in four ways: >- >-- Attributes >-- Buffered data >-- Texture data >-- Samplers >- >-Each of these API objects is referred to by name from the API. Variables in WSL are not annotated with extra API-visible names (like they are in some other graphics APIs). >- >-Variables are passed to vertex shaders as arguments to a vertex entry point. Each buffer is represented as an argument with an array reference type (using the `[]` syntax). Textures and samplers are represented by arguments with the `texture` and `sampler` types, respectively. All other non-builtin arguments to a vertex entry point are implied to be attributes. >- >-Some arguments are recognized by the compiler from their name and type. These arguments provide built-in functionality inherent in the graphics pipeline. For example, an argument of the form `int wsl_vertexID` refers to the ID of the current vertex, and is not recognized as an attribute. All non-builtin arguments to a vertex entry point must be associated with an API object whenever any draw call using the vertex entry point is invoked. Otherwise, the draw call will fail. >- >-The only way to pass data between successive shader stages within a single draw call is by return value. An entry point must indicate that it returns a collection of values contained within a structure. Every variable inside this structure, recursively, is passed to the next stage in the graphics pipeline. Members of this struct may also be output built-in variables. For example, a vertex entry point may return a struct which contains a member `float4 wsl_Position`, and this variable will represent the rasterized position of the vertex. Buffers (as described by WSL array references), textures, and samplers must not be present in this returned struct. Built-in variables must never appear twice inside the returned structure. >- >-## Fragment entry points >- >-Fragment entry points may accept one argument with the type that the previous shader stage returned. The argument name for this argument must be `stageIn`. In addition to this argument, fragment entry points may accept buffers, textures, and samplers as arguments in the same way that vertex entry points accept them. Fragment entry points also must return a struct, and all members of this struct must be built-in variables. The set of recognized built-in variables which may be accepted or returned from an entry point is different between all types of entry points. >- >-For example, this would be a valid graphics program: >- >- struct VertexInput { >- float2 position; >- float3 color; >- } >- >- struct VertexOutput { >- float4 wsl_Position; >- float3 color; >- } >- >- struct FragmentOutput { >- float4 wsl_Color; >- } >- >- vertex VertexOutput vertexShader(VertexInput vertexInput) { >- VertexOutput result; >- result.wsl_Position = float4(vertexInput.position, 0., 1.); >- result.color = vertexInput.color; >- return result; >- } >- >- fragment FragmentOutput fragmentShader(VertexOutput stageIn) { >- FragmentOutput result; >- result.wsl_Color = float4(stageIn.color, 1.); >- return result; >- } >- >-## Compute entry points >- >-WebGPU's API passes data to a compute shader in three ways: >- >-- Buffered data >-- Texture data >-- Samplers >- >-Compute entry points start with the keyword `compute`. The return type for a compute entry point must be `void`. Each buffer is represented as an argument with an array reference type (using the `[]` syntax). Textures and samplers are represented by arguments with the `texture` and `sampler` types, respectively. Compute entry points may also accept built-in variables as arguments. Arguments of any other type are disallowed. Arguments may not use the `threadgroup` memory space. >- >-# Error handling >- >-Errors may occur during shader processing. For example, the shader may attempt to dereference a `null` array reference. If this occurs, the shader stage immediately completes successfully. The entry point immediately returns a struct with all fields set to 0. After this event, subsequent shader stages will proceed as if there was no problem. >- >-Buffer and texture reads and writes before the error all complete, and have the same semantics as if no error had occurred. Buffer and texture reads and writes after the error do not occur. >- >-# Summary >- >-WSL is a type-safe language based on C syntax. It eliminates some C features, like unions and pointer casts, but adds other modern features in their place, like generics and overloading. >- >-# Additional Limitations >- >-The following additional limitations may be placed on a WSL program: >- >-- `device`, `constant`, and `threadgroup` pointers cannot point to data that may have pointers in it. This safety check is not done as part of the normal type system checks. It's performed only after instantiation. >-- Pointers and array references (collectively, *references*) may be restricted to support compiling to SPIR-V *logical mode*. In this mode, arrays must not transitively hold references. References must be initialized upon declaration and never reassigned. Functions that return references must have one return point. Ternary expressions may not return references. >-- Graphics entry points must transitively never refer to the `threadgroup` memory space. >- >- >diff --git a/Tools/WebGPUShadingLanguageRI/WrapChecker.js b/Tools/WebGPUShadingLanguageRI/WrapChecker.js >index 4cadc7d0d9e6a6dfda555dab89d0271770dbd9a7..cf6e9fb19ef75e7890cd55a9e9abffc18b5c73c8 100644 >--- a/Tools/WebGPUShadingLanguageRI/WrapChecker.js >+++ b/Tools/WebGPUShadingLanguageRI/WrapChecker.js >@@ -52,11 +52,6 @@ class WrapChecker extends Visitor { > throw new Error("Found unwrapped " + node.constructor.name + " at " + originString(node) + ": " + node + "\nWhile visiting " + this._startNode.constructor.name + " at " + originString(this._startNode.origin) + ": " + this._startNode); > } > >- visitConstexprTypeParameter(node) >- { >- this._foundUnwrapped(node); >- } >- > visitFuncParameter(node) > { > this._foundUnwrapped(node); >@@ -77,11 +72,6 @@ class WrapChecker extends Visitor { > this._foundUnwrapped(node); > } > >- visitTypeVariable(node) >- { >- this._foundUnwrapped(node); >- } >- > // NOTE: This does not know how to handle NativeTypeInstance, because this is never called on instantiated > // code. Once code is instantiated, you cannot instantiate it further. > >diff --git a/Tools/WebGPUShadingLanguageRI/index.html b/Tools/WebGPUShadingLanguageRI/index.html >index 8094b193781b4aa9b0c3909e9a91d2815f2b2aba..5af0f4fad7ca194e3fd70118dd9d6de51f6ebbda 100644 >--- a/Tools/WebGPUShadingLanguageRI/index.html >+++ b/Tools/WebGPUShadingLanguageRI/index.html >@@ -36,7 +36,6 @@ > <script src="CloneProgram.js"></script> > <script src="CommaExpression.js"></script> > <script src="ConstexprFolder.js"></script> >-<script src="ConstexprTypeParameter.js"></script> > <script src="Continue.js"></script> > <script src="ConvertPtrToArrayRefExpression.js"></script> > <script src="DoWhileLoop.js"></script> >@@ -55,7 +54,6 @@ > <script src="ExternalOrigin.js"></script> > <script src="Field.js"></script> > <script src="FindHighZombies.js"></script> >-<script src="FlattenProtocolExtends.js"></script> > <script src="FlattenedStructOffsetGatherer.js"></script> > <script src="FloatLiteral.js"></script> > <script src="FloatLiteralType.js"></script> >@@ -73,7 +71,6 @@ > <script src="InferTypesForCall.js"></script> > <script src="Inline.js"></script> > <script src="Inliner.js"></script> >-<script src="InstantiateImmediates.js"></script> > <script src="IntLiteral.js"></script> > <script src="IntLiteralType.js"></script> > <script src="Intrinsics.js"></script> >@@ -103,10 +100,6 @@ > <script src="PropertyResolver.js"></script> > <script src="Program.js"></script> > <script src="ProgramWithUnnecessaryThingsRemoved.js"></script> >-<script src="Protocol.js"></script> >-<script src="ProtocolDecl.js"></script> >-<script src="ProtocolFuncDecl.js"></script> >-<script src="ProtocolRef.js"></script> > <script src="PtrType.js"></script> > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> >@@ -131,10 +124,7 @@ > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeOrVariableRef.js"></script> >-<script src="TypeParameterRewriter.js"></script> > <script src="TypeRef.js"></script> >-<script src="TypeVariable.js"></script> >-<script src="TypeVariableTracker.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script> >@@ -344,7 +334,7 @@ function selectedShadersChanged(fromCompilation = false) { > currentVertexShader = availableVertexShaders[vertexShaderSelect.selectedIndex]; > currentFragmentShader = availableFragmentShaders[fragmentShaderSelect.selectedIndex]; > >- inlinedVertexShader = program.funcInstantiator.getUnique(currentVertexShader, []); >+ inlinedVertexShader = currentVertexShader; > _inlineFunction(program, inlinedVertexShader, new VisitingSet(currentVertexShader)); > > allArgumentInfos = []; >@@ -426,7 +416,7 @@ function runShaders() { > func.parameters[i].ePtr.copyFrom(argumentEPtrs[i].ePtr, argumentEPtrs[i].size); > let result = new Evaluator(program).runFunc(func); > >- inlinedFragmentShader = program.funcInstantiator.getUnique(currentFragmentShader, []); >+ inlinedFragmentShader = currentFragmentShader; > _inlineFunction(program, inlinedFragmentShader, new VisitingSet(currentFragmentShader)); > func = inlinedFragmentShader; >
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 188400
:
346751
|
346752
|
346808
|
346826
|
346839
|
346861
|
346870
|
346880
|
346897
|
346942
|
346954
|
346998