WebKit Bugzilla
Attachment 346880 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-20180809174815.patch (text/plain), 422.98 KB, created by
Myles C. Maxfield
on 2018-08-09 17:48:16 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-08-09 17:48:16 PDT
Size:
422.98 KB
patch
obsolete
>Subversion Revision: 234728 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 9be88423a28c7de03b5fb733d0e940a8c3b8beb5..50994541ac479edabc176d928737e074bd1b1aed 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,387 @@ >+2018-08-09 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Start making the compiler match the spec >+ https://bugs.webkit.org/show_bug.cgi?id=188400 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebGPUShadingLanguageRI/All.js: >+ * WebGPUShadingLanguageRI/AutoWrapper.js: >+ (AutoWrapper.prototype.visitConstexprTypeParameter): Deleted. >+ (AutoWrapper.prototype.visitTypeVariable): Deleted. >+ * WebGPUShadingLanguageRI/CallExpression.js: >+ (CallExpression): >+ (CallExpression.prototype.get name): >+ (CallExpression.prototype.resolve): >+ (CallExpression.prototype.resolveToOverload): >+ (CallExpression.prototype.becomeCast): >+ (CallExpression.prototype.toString): >+ (CallExpression.prototype.get typeArguments): Deleted. >+ * WebGPUShadingLanguageRI/CallFunction.js: >+ (callFunction): >+ * WebGPUShadingLanguageRI/Checker.js: >+ (Checker.prototype.visitProgram): >+ (Checker.prototype._checkOperatorOverload): >+ (Checker.prototype.visitTypeRef): >+ (Checker.prototype.visitProtocolDecl): Deleted. >+ (Checker.prototype._checkTypeArguments): Deleted. >+ * WebGPUShadingLanguageRI/ConstexprTypeParameter.js: Removed. >+ * WebGPUShadingLanguageRI/CreateLiteralType.js: >+ (createLiteralType.GenericLiteralType): >+ (createLiteralType.GenericLiteralType.prototype.prepareToVerify): >+ * WebGPUShadingLanguageRI/ExpressionFinder.js: >+ (ExpressionFinder.prototype.visitConstexprTypeParameter): Deleted. >+ * WebGPUShadingLanguageRI/FlattenProtocolExtends.js: Removed. >+ * WebGPUShadingLanguageRI/Func.js: >+ (Func): >+ (Func.prototype.get returnType): >+ (Func.prototype.toDeclString): >+ (Func.prototype.get typeParameters): Deleted. >+ (Func.prototype.get typeParametersForCallResolution): Deleted. >+ * WebGPUShadingLanguageRI/FuncDef.js: >+ (FuncDef): >+ (FuncDef.prototype.rewrite): >+ * WebGPUShadingLanguageRI/FuncInstantiator.js: Removed. >+ * WebGPUShadingLanguageRI/InferTypesForCall.js: >+ (inferTypesForCall): >+ * WebGPUShadingLanguageRI/Inline.js: >+ (inline): >+ (resolveInlinedFunction): >+ * WebGPUShadingLanguageRI/Inliner.js: >+ (Inliner.prototype.visitCallExpression): >+ (Inliner): >+ * WebGPUShadingLanguageRI/InstantiateImmediates.js: Removed. >+ * WebGPUShadingLanguageRI/Intrinsics.js: >+ (Intrinsics): >+ * WebGPUShadingLanguageRI/NameContext.js: >+ (NameContext.prototype.resolveFuncOverload): >+ * WebGPUShadingLanguageRI/NameFinder.js: >+ * WebGPUShadingLanguageRI/NameResolver.js: >+ (NameResolver.prototype._resolveTypeArguments): >+ (NameResolver.prototype.visitTypeRef): >+ (NameResolver.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/NativeFunc.js: >+ (NativeFunc): >+ * WebGPUShadingLanguageRI/NativeType.js: >+ (NativeType): >+ (NativeType.prototype.get typeArguments): >+ (NativeType.prototype.get typeParameters): Deleted. >+ (NativeType.prototype.instantiate): Deleted. >+ * WebGPUShadingLanguageRI/Parse.js: >+ (parseConstexpr): >+ (parseTypeDef): >+ (parseLeftOperatorCall): >+ (isCallExpression): >+ (parsePossiblePrefix): >+ (parsePossibleRelationalEquality): >+ (parseLeftLogicalExpression): >+ (parseIfStatement): >+ (parseWhile): >+ (parseFor): >+ (parseDo): >+ (parseFuncDecl): >+ (parseFuncDef): >+ (parseStructType): >+ (parseNativeFunc): >+ (parseNative): >+ (parseEnumType): >+ (parse): >+ (parseProtocolRef): Deleted. >+ (parseTypeParameters): Deleted. >+ (parseProtocolFuncDecl): Deleted. >+ (parseProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/Prepare.js: >+ (let.prepare): >+ * WebGPUShadingLanguageRI/Program.js: >+ (Program): >+ (Program.prototype.get types): >+ (Program.prototype.add): >+ (Program.prototype.get protocols): Deleted. >+ (Program.prototype.get funcInstantiator): Deleted. >+ * WebGPUShadingLanguageRI/Protocol.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolDecl.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolFuncDecl.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolRef.js: Removed. >+ * WebGPUShadingLanguageRI/ResolveNames.js: >+ (resolveNamesInProtocols): Deleted. >+ * WebGPUShadingLanguageRI/ResolveOverloadImpl.js: >+ (resolveOverloadImpl): >+ * WebGPUShadingLanguageRI/ResolveTypeDefs.js: >+ (resolveTypeDefsInProtocols): Deleted. >+ * WebGPUShadingLanguageRI/Rewriter.js: >+ (Rewriter.prototype.visitStructType): >+ (Rewriter.prototype.visitTypeRef): >+ (Rewriter.prototype.processDerivedCallData): >+ (Rewriter.prototype.visitCallExpression): >+ (Rewriter.prototype.visitConstexprTypeParameter): Deleted. >+ (Rewriter.prototype.visitProtocolDecl): Deleted. >+ (Rewriter.prototype.visitTypeVariable): Deleted. >+ (Rewriter.prototype.visitProtocolFuncDecl): Deleted. >+ (Rewriter.prototype.visitProtocolRef): Deleted. >+ * WebGPUShadingLanguageRI/SPIRV.html: >+ * WebGPUShadingLanguageRI/SPIRVCodegen.js: >+ * WebGPUShadingLanguageRI/StandardLibrary.js: >+ (operator.T.Equatable.bool): Deleted. >+ (bool.operator.T.Equatable): Deleted. >+ * WebGPUShadingLanguageRI/StatementCloner.js: >+ (StatementCloner.prototype.visitFuncDef): >+ (StatementCloner.prototype.visitNativeFunc): >+ (StatementCloner.prototype.visitConstexprTypeParameter): Deleted. >+ (StatementCloner.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/StructLayoutBuilder.js: >+ (StructLayoutBuilder.prototype.visitCallExpression): >+ (StructLayoutBuilder): >+ * WebGPUShadingLanguageRI/StructType.js: >+ (StructType): >+ (StructType.prototype.get origin): >+ (StructType.prototype.toString): >+ (StructType.prototype.get typeParameters): Deleted. >+ (StructType.prototype.instantiate): Deleted. >+ * WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js: >+ (synthesizeEnumFunctions): >+ * WebGPUShadingLanguageRI/SynthesizeStructAccessors.js: >+ (synthesizeStructAccessors.setupImplementationData): >+ (synthesizeStructAccessors.createTypeRef): >+ (synthesizeStructAccessors.setupAnder): >+ (synthesizeStructAccessors): >+ (synthesizeStructAccessors.createTypeParameters): Deleted. >+ (synthesizeStructAccessors.): Deleted. >+ * WebGPUShadingLanguageRI/Test.html: >+ * WebGPUShadingLanguageRI/Test.js: >+ * WebGPUShadingLanguageRI/Type.js: >+ (Type.prototype.get typeParameters): Deleted. >+ (Type.prototype.inherits): Deleted. >+ (Type.prototype.get instantiatedType): Deleted. >+ * WebGPUShadingLanguageRI/TypeDef.js: >+ (TypeDef): >+ (TypeDef.prototype.get name): >+ (TypeDef.prototype.toString): >+ (TypeDef.prototype.get typeParameters): Deleted. >+ * WebGPUShadingLanguageRI/TypeDefResolver.js: >+ (TypeDefResolver.prototype.visitTypeRef): >+ (TypeDefResolver): >+ * WebGPUShadingLanguageRI/TypeParameterRewriter.js: Removed. >+ * WebGPUShadingLanguageRI/TypeRef.js: >+ (TypeRef): >+ (TypeRef.wrap): >+ (TypeRef.instantiate): >+ (TypeRef.prototype.get name): >+ (TypeRef.prototype.get unifyNode): >+ (TypeRef.prototype.populateDefaultValue): >+ (TypeRef.prototype.get size): >+ (TypeRef.prototype.get isPrimitive): >+ (TypeRef.prototype.setType): >+ (TypeRef.prototype.unifyImpl): >+ (TypeRef.prototype.toString): >+ (TypeRef.prototype.get typeArguments): Deleted. >+ (TypeRef.prototype.setTypeAndArguments): Deleted. >+ * WebGPUShadingLanguageRI/TypeVariable.js: Removed. >+ * WebGPUShadingLanguageRI/TypeVariableTracker.js: Removed. >+ * WebGPUShadingLanguageRI/Visitor.js: >+ (Visitor.prototype.visitCallExpression): >+ (Visitor.prototype.visitProtocolFuncDecl): Deleted. >+ (Visitor.prototype.visitProtocolRef): Deleted. >+ (Visitor.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/WSL.md: Removed. >+ * WebGPUShadingLanguageRI/WrapChecker.js: >+ (WrapChecker): >+ (WrapChecker.visitConstexprTypeParameter): Deleted. >+ (WrapChecker.prototype.visitFuncParameter): Deleted. >+ (WrapChecker.prototype.visitTypeVariable): Deleted. >+ * WebGPUShadingLanguageRI/index.html: >+ >+2018-08-07 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Start making the compiler match the spec >+ https://bugs.webkit.org/show_bug.cgi?id=188400 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebGPUShadingLanguageRI/All.js: >+ * WebGPUShadingLanguageRI/AutoWrapper.js: >+ (AutoWrapper.prototype.visitConstexprTypeParameter): Deleted. >+ (AutoWrapper.prototype.visitTypeVariable): Deleted. >+ * WebGPUShadingLanguageRI/CallExpression.js: >+ (CallExpression): >+ (CallExpression.prototype.get name): >+ (CallExpression.prototype.resolve): >+ (CallExpression.prototype.resolveToOverload): >+ (CallExpression.prototype.becomeCast): >+ (CallExpression.prototype.toString): >+ (CallExpression.prototype.get typeArguments): Deleted. >+ * WebGPUShadingLanguageRI/CallFunction.js: >+ (callFunction): >+ * WebGPUShadingLanguageRI/Checker.js: >+ (Checker.prototype.visitProgram): >+ (Checker.prototype._checkOperatorOverload): >+ (Checker.prototype.visitTypeRef): >+ (Checker.prototype.visitProtocolDecl): Deleted. >+ (Checker.prototype._checkTypeArguments): Deleted. >+ * WebGPUShadingLanguageRI/ConstexprTypeParameter.js: Removed. >+ * WebGPUShadingLanguageRI/CreateLiteralType.js: >+ (createLiteralType.GenericLiteralType): >+ (createLiteralType.GenericLiteralType.prototype.prepareToVerify): >+ * WebGPUShadingLanguageRI/ExpressionFinder.js: >+ (ExpressionFinder.prototype.visitConstexprTypeParameter): Deleted. >+ * WebGPUShadingLanguageRI/FlattenProtocolExtends.js: Removed. >+ * WebGPUShadingLanguageRI/Func.js: >+ (Func): >+ (Func.prototype.get returnType): >+ (Func.prototype.toDeclString): >+ (Func.prototype.get typeParameters): Deleted. >+ (Func.prototype.get typeParametersForCallResolution): Deleted. >+ * WebGPUShadingLanguageRI/FuncDef.js: >+ (FuncDef): >+ (FuncDef.prototype.rewrite): >+ * WebGPUShadingLanguageRI/FuncInstantiator.js: Removed. >+ * WebGPUShadingLanguageRI/InferTypesForCall.js: >+ (inferTypesForCall): >+ * WebGPUShadingLanguageRI/Inline.js: >+ (inline): >+ (resolveInlinedFunction): >+ * WebGPUShadingLanguageRI/Inliner.js: >+ (Inliner.prototype.visitCallExpression): >+ (Inliner): >+ * WebGPUShadingLanguageRI/InstantiateImmediates.js: Removed. >+ * WebGPUShadingLanguageRI/Intrinsics.js: >+ (Intrinsics): >+ * WebGPUShadingLanguageRI/NameContext.js: >+ (NameContext.prototype.resolveFuncOverload): >+ * WebGPUShadingLanguageRI/NameFinder.js: >+ * WebGPUShadingLanguageRI/NameResolver.js: >+ (NameResolver.prototype._resolveTypeArguments): >+ (NameResolver.prototype.visitTypeRef): >+ (NameResolver.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/NativeFunc.js: >+ (NativeFunc): >+ * WebGPUShadingLanguageRI/NativeType.js: >+ (NativeType): >+ (NativeType.prototype.get typeArguments): >+ (NativeType.prototype.get typeParameters): Deleted. >+ (NativeType.prototype.instantiate): Deleted. >+ * WebGPUShadingLanguageRI/Parse.js: >+ (parseConstexpr): >+ (parseTypeDef): >+ (parseLeftOperatorCall): >+ (isCallExpression): >+ (parsePossiblePrefix): >+ (parsePossibleRelationalEquality): >+ (parseLeftLogicalExpression): >+ (parseIfStatement): >+ (parseWhile): >+ (parseFor): >+ (parseDo): >+ (parseFuncDecl): >+ (parseFuncDef): >+ (parseStructType): >+ (parseNativeFunc): >+ (parseNative): >+ (parseEnumType): >+ (parse): >+ (parseProtocolRef): Deleted. >+ (parseTypeParameters): Deleted. >+ (parseProtocolFuncDecl): Deleted. >+ (parseProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/Prepare.js: >+ (let.prepare): >+ * WebGPUShadingLanguageRI/Program.js: >+ (Program): >+ (Program.prototype.get types): >+ (Program.prototype.add): >+ (Program.prototype.get protocols): Deleted. >+ (Program.prototype.get funcInstantiator): Deleted. >+ * WebGPUShadingLanguageRI/Protocol.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolDecl.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolFuncDecl.js: Removed. >+ * WebGPUShadingLanguageRI/ProtocolRef.js: Removed. >+ * WebGPUShadingLanguageRI/ResolveNames.js: >+ (resolveNamesInProtocols): Deleted. >+ * WebGPUShadingLanguageRI/ResolveOverloadImpl.js: >+ (resolveOverloadImpl): >+ * WebGPUShadingLanguageRI/ResolveTypeDefs.js: >+ (resolveTypeDefsInProtocols): Deleted. >+ * WebGPUShadingLanguageRI/Rewriter.js: >+ (Rewriter.prototype.visitStructType): >+ (Rewriter.prototype.visitTypeRef): >+ (Rewriter.prototype.processDerivedCallData): >+ (Rewriter.prototype.visitCallExpression): >+ (Rewriter.prototype.visitConstexprTypeParameter): Deleted. >+ (Rewriter.prototype.visitProtocolDecl): Deleted. >+ (Rewriter.prototype.visitTypeVariable): Deleted. >+ (Rewriter.prototype.visitProtocolFuncDecl): Deleted. >+ (Rewriter.prototype.visitProtocolRef): Deleted. >+ * WebGPUShadingLanguageRI/SPIRV.html: >+ * WebGPUShadingLanguageRI/SPIRVCodegen.js: >+ * WebGPUShadingLanguageRI/StandardLibrary.js: >+ (operator.T.Equatable.bool): Deleted. >+ (bool.operator.T.Equatable): Deleted. >+ * WebGPUShadingLanguageRI/StatementCloner.js: >+ (StatementCloner.prototype.visitFuncDef): >+ (StatementCloner.prototype.visitNativeFunc): >+ (StatementCloner.prototype.visitConstexprTypeParameter): Deleted. >+ (StatementCloner.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/StructLayoutBuilder.js: >+ (StructLayoutBuilder.prototype.visitCallExpression): >+ (StructLayoutBuilder): >+ * WebGPUShadingLanguageRI/StructType.js: >+ (StructType): >+ (StructType.prototype.get origin): >+ (StructType.prototype.toString): >+ (StructType.prototype.get typeParameters): Deleted. >+ (StructType.prototype.instantiate): Deleted. >+ * WebGPUShadingLanguageRI/SynthesizeEnumFunctions.js: >+ (synthesizeEnumFunctions): >+ * WebGPUShadingLanguageRI/SynthesizeStructAccessors.js: >+ (synthesizeStructAccessors.setupImplementationData): >+ (synthesizeStructAccessors.createTypeRef): >+ (synthesizeStructAccessors.setupAnder): >+ (synthesizeStructAccessors): >+ (synthesizeStructAccessors.createTypeParameters): Deleted. >+ (synthesizeStructAccessors.): Deleted. >+ * WebGPUShadingLanguageRI/Test.html: >+ * WebGPUShadingLanguageRI/Test.js: >+ * WebGPUShadingLanguageRI/Type.js: >+ (Type.prototype.get typeParameters): Deleted. >+ (Type.prototype.inherits): Deleted. >+ (Type.prototype.get instantiatedType): Deleted. >+ * WebGPUShadingLanguageRI/TypeDef.js: >+ (TypeDef): >+ (TypeDef.prototype.get name): >+ (TypeDef.prototype.toString): >+ (TypeDef.prototype.get typeParameters): Deleted. >+ * WebGPUShadingLanguageRI/TypeDefResolver.js: >+ (TypeDefResolver.prototype.visitTypeRef): >+ (TypeDefResolver): >+ * WebGPUShadingLanguageRI/TypeParameterRewriter.js: Removed. >+ * WebGPUShadingLanguageRI/TypeRef.js: >+ (TypeRef): >+ (TypeRef.wrap): >+ (TypeRef.instantiate): >+ (TypeRef.prototype.get name): >+ (TypeRef.prototype.get unifyNode): >+ (TypeRef.prototype.populateDefaultValue): >+ (TypeRef.prototype.get size): >+ (TypeRef.prototype.get isPrimitive): >+ (TypeRef.prototype.setType): >+ (TypeRef.prototype.unifyImpl): >+ (TypeRef.prototype.toString): >+ (TypeRef.prototype.get typeArguments): Deleted. >+ (TypeRef.prototype.setTypeAndArguments): Deleted. >+ * WebGPUShadingLanguageRI/TypeVariable.js: Removed. >+ * WebGPUShadingLanguageRI/TypeVariableTracker.js: Removed. >+ * WebGPUShadingLanguageRI/Visitor.js: >+ (Visitor.prototype.visitCallExpression): >+ (Visitor.prototype.visitProtocolFuncDecl): Deleted. >+ (Visitor.prototype.visitProtocolRef): Deleted. >+ (Visitor.prototype.visitProtocolDecl): Deleted. >+ * WebGPUShadingLanguageRI/WSL.md: Removed. >+ * WebGPUShadingLanguageRI/WrapChecker.js: >+ (WrapChecker): >+ (WrapChecker.visitConstexprTypeParameter): Deleted. >+ (WrapChecker.prototype.visitFuncParameter): Deleted. >+ (WrapChecker.prototype.visitTypeVariable): Deleted. >+ * WebGPUShadingLanguageRI/index.html: >+ > 2018-08-09 Ross Kirsling <ross.kirsling@sony.com> > > Unreviewed follow-up fix for r234720. >diff --git a/Tools/WebGPUShadingLanguageRI/All.js b/Tools/WebGPUShadingLanguageRI/All.js >index 15dd7ccab94692a32acd27b9dac96c8a8f55d658..49a5fb68626c90244e8462ad718ff1e859fd623f 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"); >@@ -85,7 +83,6 @@ load("FoldConstexprs.js"); > load("ForLoop.js"); > load("Func.js"); > load("FuncDef.js"); >-load("FuncInstantiator.js"); > load("FuncParameter.js"); > load("FunctionLikeBlock.js"); > load("HighZombieFinder.js"); >@@ -95,7 +92,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"); >@@ -112,9 +108,7 @@ load("NameContext.js"); > load("NameFinder.js"); > load("NameResolver.js"); > load("NativeFunc.js"); >-load("NativeFuncInstance.js"); > load("NativeType.js"); >-load("NativeTypeInstance.js"); > load("NormalUsePropertyResolver.js"); > load("NullLiteral.js"); > load("NullType.js"); >@@ -125,10 +119,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 +143,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..f066ac320a9dce421d4f8efd36333a24ea762fbe 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,71 +36,41 @@ class CallExpression extends Expression { > } > > get name() { return this._name; } >- get typeArguments() { return this._typeArguments; } > get argumentList() { return this._argumentList; } > get isCast() { return this._isCast; } > get returnType() { return this._returnType; } > >- static resolve(origin, possibleOverloads, typeParametersInScope, name, typeArguments, argumentList, argumentTypes, returnType) >+ static resolve(origin, possibleOverloads, name, argumentList, argumentTypes, returnType) > { >- let call = new CallExpression(origin, name, typeArguments, argumentList); >+ let call = new CallExpression(origin, name, argumentList); > call.argumentTypes = argumentTypes.map(argument => argument.visit(new AutoWrapper())); > call.possibleOverloads = possibleOverloads; > if (returnType) > call.setCastData(returnType); >- return {call, resultType: call.resolve(possibleOverloads, typeParametersInScope, typeArguments)}; >+ return {call, resultType: call.resolve(possibleOverloads)}; > } > >- resolve(possibleOverloads, typeParametersInScope, typeArguments) >+ resolve(possibleOverloads) > { > 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 "; >+ 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]; >- let parameterType = overload.func.parameters[i].type.substituteToUnification( >- overload.func.typeParameters, overload.unificationContext); >+ let parameterType = overload.func.parameters[i].type; > let result = argumentType.equalsWithCommit(parameterType); > if (!result) > throw new Error("At " + this.origin.originString + " argument and parameter types not equal after type argument substitution: argument = " + argumentType + ", parameter = " + parameterType); >@@ -112,10 +81,7 @@ 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); >+ let result = overload.func.returnType; > if (!result) > throw new Error("Null return type"); > result = result.visit(new AutoWrapper()); >@@ -125,11 +91,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 +106,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..5dca460fb96c14839cb89f05f1734d439ce95b5b 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); >@@ -59,8 +57,6 @@ class Checker extends Visitor { > _checkShaderType(node) > { > // FIXME: Relax these checks once we have implemented support for textures and samplers. >- if (node.typeParameters.length != 0) >- throw new WTypeError(node.origin.originString, "Entry point " + node.name + " must not have type arguments."); > let shaderFunc = node; > switch (node.shaderType) { > case "vertex": >@@ -84,15 +80,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,11 +102,10 @@ 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( >- overload.func.typeParameters, overload.unificationContext); >+ let resultType = overload.func.returnType; > if (!resultType.equals(valueType)) > throw new WTypeError(func.origin.originString, "Setter and getter must agree on value type (getter at " + overload.func.origin.originString + " says " + resultType + " while this setter says " + valueType + ")"); > }; >@@ -211,23 +197,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 +247,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) >@@ -426,8 +378,8 @@ class Checker extends Visitor { > > try { > let result = CallExpression.resolve( >- node.origin, node.possibleGetOverloads, this._currentStatement.typeParameters, >- node.getFuncName, [], [node.base, ...extraArgs], [baseType, ...extraArgTypes], null); >+ node.origin, node.possibleGetOverloads, >+ node.getFuncName, [node.base, ...extraArgs], [baseType, ...extraArgTypes], null); > node.callForGet = result.call; > node.resultTypeForGet = result.resultType; > } catch (e) { >@@ -440,8 +392,8 @@ class Checker extends Visitor { > let baseForAnd = baseType.argumentForAndOverload(node.origin, node.base); > > let result = CallExpression.resolve( >- node.origin, node.possibleAndOverloads, this._currentStatement.typeParameters, >- node.andFuncName, [], [baseForAnd, ...extraArgs], [typeForAnd, ...extraArgTypes], >+ node.origin, node.possibleAndOverloads, >+ node.andFuncName, [baseForAnd, ...extraArgs], [typeForAnd, ...extraArgTypes], > null); > node.callForAnd = result.call; > node.resultTypeForAnd = result.resultType.unifyNode.returnTypeFromAndOverload(node.origin); >@@ -465,9 +417,9 @@ class Checker extends Visitor { > throw new WTypeError(node.origin.originString, "Result type resolved by-value (" + node.resultTypeForGet + ") does not match result type resolved by-pointer (" + node.resultTypeForAnd + ")"); > > try { >- let result = CallExpression.resolve( >- node.origin, node.possibleSetOverloads, this._currentStatement.typeParameters, >- node.setFuncName, [], [node.base, ...extraArgs, null], [baseType, ...extraArgTypes, node.resultType], null); >+ let result = CallExpression.resolve( >+ node.origin, node.possibleSetOverloads, >+ node.setFuncName, [node.base, ...extraArgs, null], [baseType, ...extraArgTypes, node.resultType], null); > node.callForSet = result.call; > if (!result.resultType.equals(baseType)) > throw new WTypeError(node.origin.originString, "Result type of setter " + result.call.func + " is not the base type " + baseType); >@@ -675,7 +627,6 @@ class Checker extends Visitor { > > visitCallExpression(node) > { >- let typeArguments = node.typeArguments.map(typeArgument => typeArgument.visit(this)); > let argumentTypes = node.argumentList.map(argument => { > let newArgument = argument.visit(this); > if (!newArgument) >@@ -687,7 +638,7 @@ class Checker extends Visitor { > if (node.returnType) > node.returnType.visit(this); > >- let result = node.resolve(node.possibleOverloads, this._currentStatement.typeParameters, typeArguments); >+ let result = node.resolve(node.possibleOverloads); > return result; > } > } >diff --git a/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js b/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >index 1e5ad6615b39243c06a0c45aef7634f637653750..1fd52311144652ba6f88ecb126b78579cc7b685b 100644 >--- a/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >+++ b/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >@@ -34,7 +34,6 @@ class ConstexprFolder extends Visitor { > super.visitCallExpression(node); > > if (node.name == "operator-" >- && !node.typeArguments.length > && node.argumentList.length == 1 > && node.argumentList[0].unifyNode.isConstexpr > && node.argumentList[0].unifyNode.negConstexpr) { >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..a9d745333ed8ff61ec6efcd2827e08493e6ae4a9 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}; >@@ -77,14 +77,6 @@ function createLiteralType(config) > throw new Error("GenericLiteralType should never be used as a type parameter"); > } > >- conversionCost(unificationContext) >- { >- let realThis = unificationContext.find(this); >- if (realThis.equals(this.preferredType)) >- return 0; >- return 1; >- } >- > commitUnification(unificationContext) > { > this.type = unificationContext.find(this).visit(new AutoWrapper()); >diff --git a/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js b/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >index 30e6b031a6dd66597407f3f6b7fe713ed8fdcc4a..0294782c0e793aa379573f5288c6ee9e8f90069c 100644 >--- a/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >+++ b/Tools/WebGPUShadingLanguageRI/ExpressionFinder.js >@@ -35,8 +35,6 @@ class ExpressionFinder extends Visitor { > visitFunc(node) > { > this._callback(node.returnType); >- for (let typeParameter of node.typeParameters) >- typeParameter.visit(this); > for (let parameter of node.parameters) > parameter.visit(this); > } >@@ -46,11 +44,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/FloatLiteral.js b/Tools/WebGPUShadingLanguageRI/FloatLiteral.js >index e6c5737de16a4a648d85adca1693454b6140727e..d5d1b15230f09c10a0bc125f03cf5ad4ce3dd2f7 100644 >--- a/Tools/WebGPUShadingLanguageRI/FloatLiteral.js >+++ b/Tools/WebGPUShadingLanguageRI/FloatLiteral.js >@@ -30,7 +30,7 @@ let FloatLiteral = createLiteral({ > > negConstexpr(origin) > { >- return new IntLiteral(origin, -this.value); >+ return new FloatLiteral(origin, -this.value); > }, > > createType(origin, value) >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..60491536251d09bce03a14ed677522a02d13a643 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 + ")")}; >- } >+ let unificationContext = new UnificationContext(); > 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..0907469926f8c07d5334bb0307dd35185b8e523c 100644 >--- a/Tools/WebGPUShadingLanguageRI/Inline.js >+++ b/Tools/WebGPUShadingLanguageRI/Inline.js >@@ -28,18 +28,13 @@ 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)); >- } >+ _inlineFunction(program, func, new VisitingSet(func)); > } > } > } > > function _inlineFunction(program, func, visiting) > { >- if (func.typeParameters.length) >- throw new Error("Cannot inline function that has type parameters"); > if (func.inlined || func.isNative) > return; > >@@ -55,14 +50,10 @@ 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); >- _inlineFunction(program, func, new VisitingSet(overload.func)); >- return func; >+ return overload.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..9987b0459bd321935ca2397f651b2cb0a1fec276 100644 >--- a/Tools/WebGPUShadingLanguageRI/Intrinsics.js >+++ b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >@@ -34,14 +34,6 @@ class Intrinsics { > // For example, if a native function is declared using "int" rather than "int32", then we must > // use "int" here, since we don't yet know that they are the same type. > >- this._map.set( >- "native typedef void<>", >- type => { >- this.void = type; >- type.size = 0; >- type.populateDefaultValue = () => { }; >- }); >- > function isBitwiseEquivalent(left, right) > { > let doubleArray = new Float64Array(1); >@@ -55,494 +47,606 @@ class Intrinsics { > } > return true; > } >+ >+ function cast(typedArrayConstructor, number) >+ { >+ var array = new typedArrayConstructor(1); >+ array[0] = number; >+ return array[0]; >+ } > >- this._map.set( >- "native typedef int32<>", >- type => { >- this.int32 = type; >- type.isPrimitive = true; >- type.isInt = true; >- type.isNumber = true; >- type.isSigned = true; >- type.canRepresent = value => isBitwiseEquivalent(value | 0, value); >- type.size = 1; >- type.defaultValue = 0; >- type.createLiteral = (origin, value) => IntLiteral.withType(origin, value | 0, type); >- type.successorValue = value => (value + 1) | 0; >- type.valuesEqual = (a, b) => a === b; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value | 0; >- type.formatValueFromUintLiteral = value => value | 0; >- type.allValues = function*() { >- for (let i = 0; i <= 0xffffffff; ++i) { >- let value = i | 0; >- yield {value: value, name: value}; >- } >- }; >- }); >+ function castToHalf(number) >+ { >+ // FIXME: Make this math obey IEEE 754. >+ if (Number.isNaN(number)) >+ return number >+ if (number > 65504) >+ return Number.POSITIVE_INFINITY; >+ if (number < -65504) >+ return Number.NEGATIVE_INFINITY; >+ if (number > 0 && number < Math.pow(2, -24)) >+ return 0; >+ if (number < 0 && number > -Math.pow(2, -24)) >+ return -0; >+ let doubleArray = new Float64Array(1); >+ let uintArray = new Uint8Array(doubleArray.buffer); >+ doubleArray[0] = number; >+ let sign = uintArray[7] & 0x80; >+ let exponent = ((uintArray[7] & 0x7f) << 4) | ((uintArray[6] & 0xf0) >>> 4); >+ let significand = ((uintArray[6] & 0x0f) << 6) | ((uintArray[5] & 0xfc) >>> 2); > >- this._map.set( >- "native typedef uint32<>", >- type => { >- this.uint32 = type; >- type.isPrimitive = true; >- type.isInt = true; >- type.isNumber = true; >- type.isSigned = false; >- type.canRepresent = value => isBitwiseEquivalent(value >>> 0, value); >- type.size = 1; >- type.defaultValue = 0; >- type.createLiteral = (origin, value) => IntLiteral.withType(origin, value >>> 0, type); >- type.successorValue = value => (value + 1) >>> 0; >- type.valuesEqual = (a, b) => a === b; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value >>> 0; >- type.formatValueFromUintLiteral = value => value >>> 0; >- type.allValues = function*() { >- for (let i = 0; i <= 0xffffffff; ++i) >- yield {value: i, name: i}; >- }; >- }); >+ if ((exponent - 1023) < -14) { >+ exponent = 0; >+ significand = (Math.abs(number) * Math.pow(2, 24)) >>> 0; >+ let value = Math.pow(2, -14) * significand / 1024; >+ if (sign != 0) >+ value *= -1; >+ return value; >+ } > >- this._map.set( >- "native typedef uint8<>", >- type => { >- this.uint8 = type; >- type.isInt = true; >- type.isNumber = true; >- type.isSigned = false; >- type.canRepresent = value => isBitwiseEquivalent(value & 0xff, value); >- type.size = 1; >- type.defaultValue = 0; >- type.createLiteral = (origin, value) => IntLiteral.withType(origin, value & 0xff, type); >- type.successorValue = value => (value + 1) & 0xff; >- type.valuesEqual = (a, b) => a === b; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value & 0xff; >- type.formatValueFromUintLiteral = value => value & 0xff; >- type.allValues = function*() { >- for (let i = 0; i <= 0xff; ++i) >- yield {value: i, name: i}; >- }; >- }); >+ doubleArray[0] = 0; > >+ uintArray[7] |= sign; >+ uintArray[7] |= (exponent >>> 4); >+ uintArray[6] |= ((exponent << 4) & 0xf0); >+ uintArray[6] |= (significand >>> 6); >+ uintArray[5] |= ((significand << 2) & 0xfc); >+ >+ return doubleArray[0]; >+ } >+ > this._map.set( >- "native typedef float32<>", >+ "native typedef void", > type => { >- this.float = type; >- type.isPrimitive = true; >- type.size = 1; >- type.isFloating = true; >- type.isNumber = true; >- type.canRepresent = value => isBitwiseEquivalent(Math.fround(value), value); >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value; >- type.formatValueFromUintLiteral = value => value; >- type.formatValueFromFloatLiteral = value => Math.fround(value); >+ this.void = type; >+ type.size = 0; >+ type.populateDefaultValue = () => { }; > }); >- >+ > this._map.set( >- "native typedef bool<>", >+ "native typedef bool", > type => { > this.bool = type; > type.isPrimitive = true; > type.size = 1; > type.populateDefaultValue = (buffer, offset) => buffer.set(offset, false); > }); >- >- this._map.set( >- "native operator<> int32(uint32)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >- }); >- >- this._map.set( >- "native operator<> int32(uint8)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >- }); >- >+ > this._map.set( >- "native operator<> int32(float)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >- }); >- >+ "native typedef uchar", >+ type => { >+ this.uchar = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = false; >+ type.canRepresent = value => isBitwiseEquivalent(value & 0xff, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value & 0xff, type); >+ type.successorValue = value => (value + 1) & 0xff; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value & 0xff; >+ type.formatValueFromUintLiteral = value => value & 0xff; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xff; ++i) >+ yield {value: i, name: i}; >+ }; >+ }); >+ > this._map.set( >- "native operator<> uint32(int32)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >- }); >- >+ "native typedef ushort", >+ type => { >+ this.ushort = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = false; >+ type.canRepresent = value => isBitwiseEquivalent(value & 0xffff, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value & 0xffff, type); >+ type.successorValue = value => (value + 1) & 0xffff; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value & 0xffff; >+ type.formatValueFromUintLiteral = value => value & 0xffff; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffff; ++i) >+ yield {value: i, name: i}; >+ }; >+ }); >+ > this._map.set( >- "native operator<> uint32(uint8)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >- }); >- >+ "native typedef uint", >+ type => { >+ this.uint = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = false; >+ type.canRepresent = value => isBitwiseEquivalent(value >>> 0, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value >>> 0, type); >+ type.successorValue = value => (value + 1) >>> 0; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value >>> 0; >+ type.formatValueFromUintLiteral = value => value >>> 0; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffffffff; ++i) >+ yield {value: i, name: i}; >+ }; >+ }); >+ > this._map.set( >- "native operator<> uint32(float)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >- }); >- >+ "native typedef char", >+ type => { >+ this.char = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(cast(Int8Array, value), value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, cast(Int8Array, value), type); >+ type.successorValue = value => cast(Int8Array, value + 1); >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => cast(Int8Array, value); >+ type.formatValueFromUintLiteral = value => cast(Int8Array, value); >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xff; ++i) { >+ let value = cast(Int8Array, i); >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ > this._map.set( >- "native operator<> uint8(int32)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >- }); >- >+ "native typedef short", >+ type => { >+ this.short = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(cast(Int16Array, value), value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, cast(Int16Array, value), type); >+ type.successorValue = value => cast(Int16Array, value + 1); >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => cast(Int16Array, value); >+ type.formatValueFromUintLiteral = value => cast(Int16Array, value); >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffff; ++i) { >+ let value = cast(Int16Array, i); >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ > this._map.set( >- "native operator<> uint8(uint32)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >- }); >- >+ "native typedef int", >+ type => { >+ this.int = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(value | 0, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value | 0, type); >+ type.successorValue = value => (value + 1) | 0; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value | 0; >+ type.formatValueFromUintLiteral = value => value | 0; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffffffff; ++i) { >+ let value = i | 0; >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ >+ this._map.set( >+ "native typedef half", >+ type => { >+ this.half = type; >+ type.isPrimitive = true; >+ type.size = 1; >+ type.isFloating = true; >+ type.isNumber = true; >+ type.canRepresent = value => isBitwiseEquivalent(castToHalf(value), value); >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value; >+ type.formatValueFromUintLiteral = value => value; >+ type.formatValueFromFloatLiteral = value => castToHalf(value); >+ }); >+ >+ this._map.set( >+ "native typedef float", >+ type => { >+ this.float = type; >+ type.isPrimitive = true; >+ type.size = 1; >+ type.isFloating = true; >+ type.isNumber = true; >+ type.canRepresent = value => isBitwiseEquivalent(Math.fround(value), value); >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value; >+ type.formatValueFromUintLiteral = value => value; >+ type.formatValueFromFloatLiteral = value => Math.fround(value); >+ }); >+ > this._map.set( >- "native operator<> uint8(float)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >- }); >- >+ "native typedef atomic_int", >+ type => { >+ this.atomic_int = type; >+ // FIXME: Figure out what to put here. >+ }); >+ > this._map.set( >- "native operator<> float(int32)", >- func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >- }); >- >+ "native typedef atomic_uint", >+ type => { >+ this.atomic_uint = type; >+ // FIXME: Figure out what to put here. >+ }); >+ >+ for (let primitiveType of ["bool", "uchar", "ushort", "uint", "char", "short", "int", "half", "float"]) { >+ for (let i = 2; i <= 4; ++i) { >+ this._map.set( >+ `native typedef ${primitiveType}${i}`, >+ type => { >+ this[`${primitiveType}${i}`] = type; >+ // FIXME: Figure out what to put here. >+ }); >+ } >+ } >+ >+ for (let primitiveType of ["half", "float"]) { >+ for (let i = 2; i <= 4; ++i) { >+ for (let j = 2; j <= 4; ++j) { >+ this._map.set( >+ `native typedef ${primitiveType}${i}x${j}`, >+ type => { >+ this[`${primitiveType}${i}x${j}`] = type; >+ // FIXME: Figure out what to put here. >+ }); >+ } >+ } >+ } >+ > this._map.set( >- "native operator<> float(uint32)", >- func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >- }); >- >+ "native typedef sampler", >+ type => { >+ this.sampler = type; >+ // FIXME: Figure out what to put here. >+ }); >+ >+ for (let textureType of ["Texture1D", "RWTexture1D", "Texture1DArray", "RWTexture1DArray", "Texture2D", "RWTexture2D", "Texture2DArray", "RWTexture2DArray", "Texture3D", "RWTexture3D", "TextureCube"]) { >+ for (let typeArgument of ["bool", "uchar", "ushort", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}>`, >+ type => { >+ this[`${textureType}<${typeArgument}>`] = type; >+ // FIXME: Figure out what to put here. >+ }); >+ for (let i = 2; i <= 4; ++i) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}${i}>`, >+ type => { >+ this[`${textureType}<${typeArgument}${i}>`] = type; >+ // FIXME: Figure out what to put here. >+ }); >+ } >+ } >+ } >+ >+ for (let textureType of ["TextureDepth2D", "RWTextureDepth2D", "TextureDepth2DArray", "RWTextureDepth2DArray", "TextureDepthCube"]) { >+ for (let typeArgument of ["float", "half"]) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}>`, >+ type => { >+ this[`${textureType}<${typeArgument}>`] = type; >+ // FIXME: Figure out what to put here. >+ }); >+ } >+ } >+ >+ for (let primitiveType of ["ushort", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator uchar(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator ushort(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xffff); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator uint(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator char(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int8Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "int", "half", "float"]) { >+ this._map.set( >+ `native operator short(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int16Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "half", "float"]) { >+ this._map.set( >+ `native operator int(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int32Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "int", "float"]) { >+ this._map.set( >+ `native operator half(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(castToHalf(value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "int", "half"]) { >+ this._map.set( >+ `native operator float(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ }); >+ } >+ > this._map.set( >- "native operator<> float(uint8)", >+ `native operator int(atomic_int)`, > func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ func.implementation = ([value]) => EPtr.box(value.loadValue()); > }); >- >+ > this._map.set( >- "native int operator+<>(int,int)", >+ `native operator uint(atomic_uint)`, > func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() + right.loadValue()) | 0); >+ func.implementation = ([value]) => EPtr.box(value.loadValue()); > }); >- >+ > this._map.set( >- "native uint operator+<>(uint,uint)", >+ "native bool operator==(bool,bool)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() + right.loadValue()) >>> 0); >+ EPtr.box(left.loadValue() == right.loadValue()); > }); >- >+ >+ >+ for (let primitiveType of ["uint", "int", "float"]) { >+ this._map.set( >+ `native bool operator==(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() == right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator<(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() < right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator<=(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() <= right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator>(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() > right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator>=(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() >= right.loadValue()); >+ }); >+ } >+ > this._map.set( >- "native float operator+<>(float,float)", >+ "native int operator+(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() + right.loadValue())); >+ EPtr.box((left.loadValue() + right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native int operator-<>(int,int)", >+ "native int operator-(int,int)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() - right.loadValue()) | 0); > }); >- >- this._map.set( >- "native uint operator-<>(uint,uint)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() - right.loadValue()) >>> 0); >- }); >- >- this._map.set( >- "native float operator-<>(float,float)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() - right.loadValue())); >- }); >- >+ > this._map.set( >- "native int operator*<>(int,int)", >+ "native int operator*(int,int)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() * right.loadValue()) | 0); > }); >- >- this._map.set( >- "native uint operator*<>(uint,uint)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() * right.loadValue()) >>> 0); >- }); >- >- this._map.set( >- "native float operator*<>(float,float)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() * right.loadValue())); >- }); >- >+ > this._map.set( >- "native int operator/<>(int,int)", >+ "native int operator/(int,int)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() / right.loadValue()) | 0); > }); >- >- this._map.set( >- "native uint operator/<>(uint,uint)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() / right.loadValue()) >>> 0); >- }); >- >- this._map.set( >- "native int operator&<>(int,int)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() & right.loadValue()); >- }); >- >- this._map.set( >- "native uint operator&<>(uint,uint)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() & right.loadValue()) >>> 0); >- }); >- >- this._map.set( >- "native int operator|<>(int,int)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() | right.loadValue()); >- }); >- >+ > this._map.set( >- "native uint operator|<>(uint,uint)", >+ "native uint operator+(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() | right.loadValue()) >>> 0); >+ EPtr.box((left.loadValue() + right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native int operator^<>(int,int)", >+ "native uint operator-(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() ^ right.loadValue()); >+ EPtr.box((left.loadValue() - right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native uint operator^<>(uint,uint)", >+ "native uint operator*(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() ^ right.loadValue()) >>> 0); >+ EPtr.box((left.loadValue() * right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native int operator<<<>(int,uint)", >+ "native uint operator/(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() << right.loadValue()); >+ EPtr.box((left.loadValue() / right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native uint operator<<<>(uint,uint)", >+ "native float operator+(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() << right.loadValue()) >>> 0); >+ EPtr.box(Math.fround(left.loadValue() + right.loadValue())); > }); >- >+ > this._map.set( >- "native int operator>><>(int,uint)", >+ "native float operator-(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >> right.loadValue()); >+ EPtr.box(Math.fround(left.loadValue() - right.loadValue())); > }); >- >+ > this._map.set( >- "native uint operator>><>(uint,uint)", >+ "native float operator*(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >>> right.loadValue()); >- }); >- >- this._map.set( >- "native int operator~<>(int)", >- func => { >- func.implementation = ([value]) => EPtr.box(~value.loadValue()); >- }); >- >- this._map.set( >- "native uint operator~<>(uint)", >- func => { >- func.implementation = ([value]) => EPtr.box((~value.loadValue()) >>> 0); >+ EPtr.box(Math.fround(left.loadValue() * right.loadValue())); > }); >- >+ > this._map.set( >- "native float operator/<>(float,float)", >+ "native float operator/(float,float)", > func => { > func.implementation = ([left, right]) => > EPtr.box(Math.fround(left.loadValue() / right.loadValue())); > }); >- >- this._map.set( >- "native bool operator==<>(int,int)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >- }); >- >- this._map.set( >- "native bool operator==<>(uint,uint)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >- }); >- >- this._map.set( >- "native bool operator==<>(bool,bool)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >- }); >- >- this._map.set( >- "native bool operator==<>(float,float)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >- }); >- >+ > this._map.set( >- "native bool operator<<>(int,int)", >+ "native int operator&(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ EPtr.box((left.loadValue() & right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator<<>(uint,uint)", >+ "native int operator|(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ EPtr.box((left.loadValue() | right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator<<>(float,float)", >+ "native int operator^(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ EPtr.box((left.loadValue() ^ right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator<=<>(int,int)", >+ "native int operator~(int)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ func.implementation = ([value]) => EPtr.box((~value.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator<=<>(uint,uint)", >+ "native int operator<<(int,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ EPtr.box((left.loadValue() << right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator<=<>(float,float)", >+ "native int operator>>(int,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ EPtr.box((left.loadValue() >> right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native bool operator><>(int,int)", >+ "native uint operator&(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ EPtr.box((left.loadValue() & right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native bool operator><>(uint,uint)", >+ "native uint operator|(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ EPtr.box((left.loadValue() | right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native bool operator><>(float,float)", >+ "native uint operator^(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ EPtr.box((left.loadValue() ^ right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native bool operator>=<>(int,int)", >+ "native uint operator~(uint)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ func.implementation = ([value]) => EPtr.box((~value.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native bool operator>=<>(uint,uint)", >+ "native uint operator<<(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ EPtr.box((left.loadValue() << right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native bool operator>=<>(float,float)", >+ "native uint operator>>(uint,uint)", > func => { > 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(), >- func => { >- func.implementation = ([vec], node) => { >- const outputBuffer = new EBuffer(swizzle.outSize); >- const readIndices = { 'x': 0, 'y': 1, 'z': 2, 'w': 3 }; >- for (let i = 0; i < swizzle.outSize; i++) >- outputBuffer.set(i, vec.get(readIndices[swizzle.components[i]])); >- >- >- return new EPtr(outputBuffer, 0); >- }, >- func.implementationData = swizzle; >+ EPtr.box((left.loadValue() >> right.loadValue()) >>> 0); > }); >- console.log(swizzle.toString()); >- } > } > > add(thing) >diff --git a/Tools/WebGPUShadingLanguageRI/Myles.html b/Tools/WebGPUShadingLanguageRI/Myles.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4ed8f13b3082dd6368d14d0d861ef30a2525667e >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/Myles.html >@@ -0,0 +1,151 @@ >+<html> >+<head> >+<title>Myles</title> >+<script src="Node.js"></script> >+<script src="Type.js"></script> >+<script src="ReferenceType.js"></script> >+<script src="Value.js"></script> >+<script src="Expression.js"></script> >+<script src="Rewriter.js"></script> >+<script src="Visitor.js"></script> >+<script src="CreateLiteral.js"></script> >+<script src="CreateLiteralType.js"></script> >+<script src="PropertyAccessExpression.js"></script> >+<script src="SwizzleOp.js"></script> >+ >+<script src="AddressSpace.js"></script> >+<script src="AnonymousVariable.js"></script> >+<script src="ArrayRefType.js"></script> >+<script src="ArrayType.js"></script> >+<script src="Assignment.js"></script> >+<script src="AutoWrapper.js"></script> >+<script src="Block.js"></script> >+<script src="BoolLiteral.js"></script> >+<script src="Break.js"></script> >+<script src="CallExpression.js"></script> >+<script src="CallFunction.js"></script> >+<script src="Check.js"></script> >+<script src="CheckLiteralTypes.js"></script> >+<script src="CheckLoops.js"></script> >+<script src="CheckRecursion.js"></script> >+<script src="CheckRecursiveTypes.js"></script> >+<script src="CheckReturns.js"></script> >+<script src="CheckUnreachableCode.js"></script> >+<script src="CheckWrapped.js"></script> >+<script src="Checker.js"></script> >+<script src="CloneProgram.js"></script> >+<script src="CommaExpression.js"></script> >+<script src="ConstexprFolder.js"></script> >+<script src="Continue.js"></script> >+<script src="ConvertPtrToArrayRefExpression.js"></script> >+<script src="DoWhileLoop.js"></script> >+<script src="DotExpression.js"></script> >+<script src="DereferenceExpression.js"></script> >+<script src="EArrayRef.js"></script> >+<script src="EBuffer.js"></script> >+<script src="EBufferBuilder.js"></script> >+<script src="EPtr.js"></script> >+<script src="EnumLiteral.js"></script> >+<script src="EnumMember.js"></script> >+<script src="EnumType.js"></script> >+<script src="EvaluationCommon.js"></script> >+<script src="Evaluator.js"></script> >+<script src="ExpressionFinder.js"></script> >+<script src="ExternalOrigin.js"></script> >+<script src="Field.js"></script> >+<script src="FindHighZombies.js"></script> >+<script src="FlattenedStructOffsetGatherer.js"></script> >+<script src="FloatLiteral.js"></script> >+<script src="FloatLiteralType.js"></script> >+<script src="FoldConstexprs.js"></script> >+<script src="ForLoop.js"></script> >+<script src="Func.js"></script> >+<script src="FuncDef.js"></script> >+<script src="FuncParameter.js"></script> >+<script src="FunctionLikeBlock.js"></script> >+<script src="HighZombieFinder.js"></script> >+<script src="IdentityExpression.js"></script> >+<script src="IfStatement.js"></script> >+<script src="IndexExpression.js"></script> >+<script src="InferTypesForCall.js"></script> >+<script src="Inline.js"></script> >+<script src="Inliner.js"></script> >+<script src="IntLiteral.js"></script> >+<script src="IntLiteralType.js"></script> >+<script src="Intrinsics.js"></script> >+<script src="LateChecker.js"></script> >+<script src="Lexer.js"></script> >+<script src="LexerToken.js"></script> >+<script src="LiteralTypeChecker.js"></script> >+<script src="LogicalExpression.js"></script> >+<script src="LogicalNot.js"></script> >+<script src="LoopChecker.js"></script> >+<script src="MakeArrayRefExpression.js"></script> >+<script src="MakePtrExpression.js"></script> >+<script src="NameContext.js"></script> >+<script src="NameFinder.js"></script> >+<script src="NameResolver.js"></script> >+<script src="NativeFunc.js"></script> >+<script src="NativeType.js"></script> >+<script src="NormalUsePropertyResolver.js"></script> >+<script src="NullLiteral.js"></script> >+<script src="NullType.js"></script> >+<script src="OriginKind.js"></script> >+<script src="OverloadResolutionFailure.js"></script> >+<script src="Parse.js"></script> >+<script src="Prepare.js"></script> >+<script src="PropertyResolver.js"></script> >+<script src="Program.js"></script> >+<script src="ProgramWithUnnecessaryThingsRemoved.js"></script> >+<script src="PtrType.js"></script> >+<script src="ReadModifyWriteExpression.js"></script> >+<script src="RecursionChecker.js"></script> >+<script src="RecursiveTypeChecker.js"></script> >+<script src="ResolveNames.js"></script> >+<script src="ResolveOverloadImpl.js"></script> >+<script src="ResolveProperties.js"></script> >+<script src="ResolveTypeDefs.js"></script> >+<script src="Return.js"></script> >+<script src="ReturnChecker.js"></script> >+<script src="ReturnException.js"></script> >+<script src="StandardLibrary.js"></script> >+<script src="StatementCloner.js"></script> >+<script src="StructLayoutBuilder.js"></script> >+<script src="StructType.js"></script> >+<script src="Substitution.js"></script> >+<script src="SwitchCase.js"></script> >+<script src="SwitchStatement.js"></script> >+<script src="SynthesizeEnumFunctions.js"></script> >+<script src="SynthesizeStructAccessors.js"></script> >+<script src="TrapStatement.js"></script> >+<script src="TypeDef.js"></script> >+<script src="TypeDefResolver.js"></script> >+<script src="TypeOrVariableRef.js"></script> >+<script src="TypeRef.js"></script> >+<script src="TypedValue.js"></script> >+<script src="UintLiteral.js"></script> >+<script src="UintLiteralType.js"></script> >+<script src="UnificationContext.js"></script> >+<script src="UnreachableCodeChecker.js"></script> >+<script src="VariableDecl.js"></script> >+<script src="VariableRef.js"></script> >+<script src="VisitingSet.js"></script> >+<script src="WSyntaxError.js"></script> >+<script src="WTrapError.js"></script> >+<script src="WTypeError.js"></script> >+<script src="WhileLoop.js"></script> >+<script src="WrapChecker.js"></script> >+ >+<script src="Test.js"></script> >+ >+<script> >+window.addEventListener("load", function() { >+ prepare(); >+}); >+</script> >+ >+</head> >+<body> >+<div id="messages"></div> >+</body> >+</html> >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..69d4f2c1b9ab7dc1c50c36da9cc9ca37e391cc18 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/NameResolver.js >@@ -41,19 +41,14 @@ class NameResolver extends Visitor { > this._nameContext.doStatement(statement, () => statement.visit(this)); > } > >- _visitTypeParametersAndBuildNameContext(node) >+ _buildNameContext() > { >- let nameContext = new NameContext(this._nameContext); >- for (let typeParameter of node.typeParameters) { >- nameContext.add(typeParameter); >- typeParameter.visit(this); >- } >- return nameContext; >+ return new NameContext(this._nameContext); > } > > visitFunc(node) > { >- let checker = new NameResolver(this._visitTypeParametersAndBuildNameContext(node)); >+ let checker = new NameResolver(this._buildNameContext(node)); > node.returnType.visit(checker); > for (let parameter of node.parameters) > parameter.visit(checker); >@@ -61,16 +56,14 @@ class NameResolver extends Visitor { > > visitFuncDef(node) > { >- let contextWithTypeParameters = this._visitTypeParametersAndBuildNameContext(node); >- let checkerWithTypeParameters = new NameResolver(contextWithTypeParameters); >- node.returnType.visit(checkerWithTypeParameters); >- let contextWithParameters = new NameContext(contextWithTypeParameters); >+ let innerContext = this._buildNameContext(); >+ let innerChecker = new NameResolver(innerContext); >+ node.returnType.visit(innerChecker); > for (let parameter of node.parameters) { >- parameter.visit(checkerWithTypeParameters); >- contextWithParameters.add(parameter); >+ parameter.visit(innerChecker); >+ innerContext.add(parameter); > } >- let checkerWithParameters = new NameResolver(contextWithParameters); >- node.body.visit(checkerWithParameters); >+ node.body.visit(innerChecker); > } > > visitBlock(node) >@@ -115,41 +108,9 @@ 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); >- for (let typeParameter of node.typeParameters) { >- typeParameter.visit(this); >- nameContext.add(typeParameter); >- } > let checker = new NameResolver(nameContext); > node.type.visit(checker); > } >@@ -157,15 +118,22 @@ class NameResolver extends Visitor { > visitStructType(node) > { > let nameContext = new NameContext(this._nameContext); >- for (let typeParameter of node.typeParameters) { >- typeParameter.visit(this); >- nameContext.add(typeParameter); >- } > let checker = new NameResolver(nameContext); > for (let field of node.fields) > field.visit(checker); > } > >+ visitTypeRef(node) >+ { >+ let type = node.type; >+ if (!type) { >+ type = this._nameContext.get(Type, node.name); >+ if (!type) >+ throw new WTypeError(node.origin.originString, "Could not find type named " + node.name); >+ node.type = type; >+ } >+ } >+ > _resolveTypeArguments(typeArguments) > { > for (let i = 0; i < typeArguments.length; ++i) { >@@ -181,36 +149,16 @@ class NameResolver extends Visitor { > else > throw new WTypeError(typeArgument.origin.originString, "Type argument resolved to wrong kind of thing: " + thing.kind); > } >- >- if (typeArgument[i] instanceof Value >- && !typeArgument[i].isConstexpr) >+ if (typeArgument[i] instanceof Value && !typeArgument[i].isConstexpr) > throw new WTypeError(typeArgument[i].origin.originString, "Expected constexpr"); > } > } > >- visitTypeRef(node) >+ visitNativeType(node) > { > this._resolveTypeArguments(node.typeArguments); >- >- let type = node.type; >- if (!type) { >- type = this._nameContext.get(Type, node.name); >- if (!type) >- throw new WTypeError(node.origin.originString, "Could not find type named " + node.name); >- node.type = type; >- } >- >- 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) >- throw new WTypeError(node.origin.originString, "Expected value, but got type at argument #" + i); >- } >+ for(let typeArgument of node.typeArguments) >+ typeArgument.visit(this); > } > > visitReferenceType(node) >@@ -279,8 +227,6 @@ class NameResolver extends Visitor { > > visitCallExpression(node) > { >- this._resolveTypeArguments(node.typeArguments); >- > let funcs = this._nameContext.get(Func, node.name); > if (funcs) > node.possibleOverloads = funcs; >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/NativeFuncInstance.js b/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.js >deleted file mode 100644 >index c99b78263535a70d9309626d585035900105d411..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/NativeFuncInstance.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 NativeFuncInstance extends Func { >- constructor(func, returnType, parameters, isCast, shaderType, implementationData) >- { >- super(func.origin, func.name, returnType, [], parameters, isCast, shaderType); >- this._func = func; >- this._implementationData = implementationData; >- } >- >- get func() { return this._func; } >- get isNative() { return true; } >- get implementationData() { return this._implementationData; } >- >- toDeclString() >- { >- return "native " + super.toDeclString(); >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/NativeType.js b/Tools/WebGPUShadingLanguageRI/NativeType.js >index b8b1a47330b5fd51ff021af06586844c2acba8ea..5cc1849389eba1cf2a261eacfd898a325dfb9c15 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); >+ if (!(typeArguments instanceof Array)) >+ throw new Error("type parameters not array: " + typeArguments); > super(); > this._origin = origin; > this._name = name; >- this._typeParameters = typeParameters; >+ this._typeArguments = typeArguments; > this._isNumber = false; > this._isInt = false; > this._isFloating = false; >@@ -40,8 +40,15 @@ class NativeType extends Type { > } > > get origin() { return this._origin; } >- get name() { return this._name; } >- get typeParameters() { return this._typeParameters; } >+ get baseName() { return this._name; } >+ get name() >+ { >+ let result = this._name; >+ if (this.typeArguments.length) >+ result += "<" + this.typeArguments + ">"; >+ return result; >+ } >+ get typeArguments() { return this._typeArguments; } > get isNative() { return true; } > > // We let Intrinsics.js set these as it likes. >@@ -54,18 +61,9 @@ 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 + ">"; >+ return "native typedef " + this.name; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/NativeTypeInstance.js b/Tools/WebGPUShadingLanguageRI/NativeTypeInstance.js >deleted file mode 100644 >index ca39e777870049ed22d7041a52014cc8e69cbc4f..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/NativeTypeInstance.js >+++ /dev/null >@@ -1,58 +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 NativeTypeInstance extends Type { >- constructor(type, typeArguments) >- { >- super(); >- this._type = type; >- this._typeArguments = typeArguments; >- } >- >- get type() { return this._type; } >- get typeArguments() { return this._typeArguments; } >- get isPrimitive() { return this._type.isPrimitive; } >- get isNative() { return true; } >- >- unifyImpl(unificationContext, other) >- { >- if (this.type != 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; >- } >- >- toString() >- { >- return this.type + "<" + this.typeArguments + ">"; >- } >-} >- >diff --git a/Tools/WebGPUShadingLanguageRI/Node.js b/Tools/WebGPUShadingLanguageRI/Node.js >index 881030130773e70ea88e0ab597974cf561f9d5e4..6d211b762b0a258d35551934d608a538ce30379d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Node.js >+++ b/Tools/WebGPUShadingLanguageRI/Node.js >@@ -89,8 +89,6 @@ class Node { > > get isNative() { return false; } > >- conversionCost(unificationContext) { return 0; } >- > equals(other) > { > let unificationContext = new UnificationContext(); >@@ -104,7 +102,6 @@ class Node { > let unificationContext = this.equals(other); > if (!unificationContext) > return false; >- unificationContext.commit(); > return unificationContext; > } > >@@ -115,7 +112,6 @@ class Node { > let result = unificationContext.verify(); > if (!result.result) > throw new WError(node.origin.originString, "Could not infer type: " + result.reason); >- unificationContext.commit(); > return unificationContext.find(this); > } > >@@ -123,11 +119,4 @@ class Node { > { > return this.visit(new Substitution(parameters, argumentList)); > } >- >- substituteToUnification(parameters, unificationContext) >- { >- return this.substitute( >- parameters, >- parameters.map(type => unificationContext.find(type))); >- } > } >diff --git a/Tools/WebGPUShadingLanguageRI/Parse.js b/Tools/WebGPUShadingLanguageRI/Parse.js >index 6d2b431615601ab9dd3d0938fbfb385ee2a4daf1..d83865cd40e34b37568ef5f27ce84a13f5208a26 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 parsedArguments = parseTypeArguments(); > consume(";"); >- return new NativeType(origin, name.text, parameters); >+ return new NativeType(origin, name.text, parsedArguments); > } > 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,10 +945,7 @@ 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..ac72494ee20b8472b588732904ba820034054741 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 >@@ -46,12 +46,6 @@ function resolveOverloadImpl(functions, typeArguments, argumentTypes, returnType > if (!successes.length) > return {failures: failures}; > >- let minimumConversionCost = successes.reduce( >- (result, overload) => Math.min(result, overload.unificationContext.conversionCost), >- Infinity); >- successes = successes.filter( >- overload => overload.unificationContext.conversionCost == minimumConversionCost); >- > // If any of the signatures are restricted then we consider those first. This is an escape mechanism for > // built-in things. > // FIXME: It should be an error to declare a function that is at least as specific as a restricted function. >@@ -74,7 +68,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..1715ad0fab7999b965bb03902254017d17b39b1e 100644 >--- a/Tools/WebGPUShadingLanguageRI/Rewriter.js >+++ b/Tools/WebGPUShadingLanguageRI/Rewriter.js >@@ -53,41 +53,11 @@ class Rewriter { > // that. > visitFuncDef(node) { return node; } > visitNativeFunc(node) { return node; } >- visitNativeFuncInstance(node) { return node; } > 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( >- node.type.visit(this), >- node.typeArguments.map(argument => argument.visit(this))); >- } >- > visitFuncParameter(node) > { > let result = new FuncParameter(node.origin, node.name, node.type.visit(this)); >@@ -125,14 +95,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 +282,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 +299,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..368618f851c9d8e502fc5f9d67b1091034a3967a 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> >@@ -69,7 +67,6 @@ td { > <script src="ForLoop.js"></script> > <script src="Func.js"></script> > <script src="FuncDef.js"></script> >- <script src="FuncInstantiator.js"></script> > <script src="FuncParameter.js"></script> > <script src="FunctionLikeBlock.js"></script> > <script src="HighZombieFinder.js"></script> >@@ -79,7 +76,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> >@@ -96,9 +92,7 @@ td { > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> > <script src="NativeFunc.js"></script> >- <script src="NativeFuncInstance.js"></script> > <script src="NativeType.js"></script> >- <script src="NativeTypeInstance.js"></script> > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >@@ -109,10 +103,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 +131,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..c6dde001a90b047238fa61564f1e68dedaf99429 100644 >--- a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >+++ b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >@@ -29,53 +29,710 @@ let standardLibrary = ` > // This is the WSL standard library. Implementations of all of these things are in > // Intrinsics.js. > >-// Need to bootstrap void first. > native typedef void; >- >-native typedef uint8; >-native typedef int32; >-native typedef uint32; > native typedef bool; >-typedef int = int32; >-typedef uint = uint32; >- >-native typedef float32; >-typedef float = float32; >- >-native operator int32(uint32); >-native operator int32(uint8); >-native operator int32(float); >-native operator uint32(int32); >-native operator uint32(uint8); >-native operator uint32(float); >-native operator uint8(int32); >-native operator uint8(uint32); >-native operator uint8(float); >-native operator float(int32); >-native operator float(uint32); >-native operator float(uint8); >+native typedef uchar; >+native typedef ushort; >+native typedef uint; >+native typedef char; >+native typedef short; >+native typedef int; >+native typedef half; >+native typedef float; >+native typedef atomic_int; >+native typedef atomic_uint; >+struct bool2 { >+ bool x; >+ bool y; >+} >+struct bool3 { >+ bool x; >+ bool y; >+ bool z; >+} >+struct bool4 { >+ bool x; >+ bool y; >+ bool z; >+ bool w; >+} >+struct uchar2 { >+ uchar x; >+ uchar y; >+} >+struct uchar3 { >+ uchar x; >+ uchar y; >+ uchar z; >+} >+struct uchar4 { >+ uchar x; >+ uchar y; >+ uchar z; >+ uchar w; >+} >+struct ushort2 { >+ ushort x; >+ ushort y; >+} >+struct ushort3 { >+ ushort x; >+ ushort y; >+ ushort z; >+} >+struct ushort4 { >+ ushort x; >+ ushort y; >+ ushort z; >+ ushort w; >+} >+struct uint2 { >+ uint x; >+ uint y; >+} >+struct uint3 { >+ uint x; >+ uint y; >+ uint z; >+} >+struct uint4 { >+ uint x; >+ uint y; >+ uint z; >+ uint w; >+} >+struct char2 { >+ char x; >+ char y; >+} >+struct char3 { >+ char x; >+ char y; >+ char z; >+} >+struct char4 { >+ char x; >+ char y; >+ char z; >+ char w; >+} >+struct short2 { >+ short x; >+ short y; >+} >+struct short3 { >+ short x; >+ short y; >+ short z; >+} >+struct short4 { >+ short x; >+ short y; >+ short z; >+ short w; >+} >+struct int2 { >+ int x; >+ int y; >+} >+struct int3 { >+ int x; >+ int y; >+ int z; >+} >+struct int4 { >+ int x; >+ int y; >+ int z; >+ int w; >+} >+struct half2 { >+ half x; >+ half y; >+} >+struct half3 { >+ half x; >+ half y; >+ half z; >+} >+struct half4 { >+ half x; >+ half y; >+ half z; >+ half w; >+} >+struct float2 { >+ float x; >+ float y; >+} >+struct float3 { >+ float x; >+ float y; >+ float z; >+} >+struct float4 { >+ float x; >+ float y; >+ float z; >+ float w; >+} >+native typedef half2x2; >+native typedef half2x3; >+native typedef half2x4; >+native typedef half3x2; >+native typedef half3x3; >+native typedef half3x4; >+native typedef half4x2; >+native typedef half4x3; >+native typedef half4x4; >+native typedef float2x2; >+native typedef float2x3; >+native typedef float2x4; >+native typedef float3x2; >+native typedef float3x3; >+native typedef float3x4; >+native typedef float4x2; >+native typedef float4x3; >+native typedef float4x4; >+native typedef sampler; >+native typedef Texture1D<bool>; >+native typedef Texture1D<bool2>; >+native typedef Texture1D<bool3>; >+native typedef Texture1D<bool4>; >+native typedef Texture1D<uchar>; >+native typedef Texture1D<uchar2>; >+native typedef Texture1D<uchar3>; >+native typedef Texture1D<uchar4>; >+native typedef Texture1D<ushort>; >+native typedef Texture1D<ushort2>; >+native typedef Texture1D<ushort3>; >+native typedef Texture1D<ushort4>; >+native typedef Texture1D<uint>; >+native typedef Texture1D<uint2>; >+native typedef Texture1D<uint3>; >+native typedef Texture1D<uint4>; >+native typedef Texture1D<char>; >+native typedef Texture1D<char2>; >+native typedef Texture1D<char3>; >+native typedef Texture1D<char4>; >+native typedef Texture1D<short>; >+native typedef Texture1D<short2>; >+native typedef Texture1D<short3>; >+native typedef Texture1D<short4>; >+native typedef Texture1D<int>; >+native typedef Texture1D<int2>; >+native typedef Texture1D<int3>; >+native typedef Texture1D<int4>; >+native typedef Texture1D<half>; >+native typedef Texture1D<half2>; >+native typedef Texture1D<half3>; >+native typedef Texture1D<half4>; >+native typedef Texture1D<float>; >+native typedef Texture1D<float2>; >+native typedef Texture1D<float3>; >+native typedef Texture1D<float4>; >+native typedef RWTexture1D<bool>; >+native typedef RWTexture1D<bool2>; >+native typedef RWTexture1D<bool3>; >+native typedef RWTexture1D<bool4>; >+native typedef RWTexture1D<uchar>; >+native typedef RWTexture1D<uchar2>; >+native typedef RWTexture1D<uchar3>; >+native typedef RWTexture1D<uchar4>; >+native typedef RWTexture1D<ushort>; >+native typedef RWTexture1D<ushort2>; >+native typedef RWTexture1D<ushort3>; >+native typedef RWTexture1D<ushort4>; >+native typedef RWTexture1D<uint>; >+native typedef RWTexture1D<uint2>; >+native typedef RWTexture1D<uint3>; >+native typedef RWTexture1D<uint4>; >+native typedef RWTexture1D<char>; >+native typedef RWTexture1D<char2>; >+native typedef RWTexture1D<char3>; >+native typedef RWTexture1D<char4>; >+native typedef RWTexture1D<short>; >+native typedef RWTexture1D<short2>; >+native typedef RWTexture1D<short3>; >+native typedef RWTexture1D<short4>; >+native typedef RWTexture1D<int>; >+native typedef RWTexture1D<int2>; >+native typedef RWTexture1D<int3>; >+native typedef RWTexture1D<int4>; >+native typedef RWTexture1D<half>; >+native typedef RWTexture1D<half2>; >+native typedef RWTexture1D<half3>; >+native typedef RWTexture1D<half4>; >+native typedef RWTexture1D<float>; >+native typedef RWTexture1D<float2>; >+native typedef RWTexture1D<float3>; >+native typedef RWTexture1D<float4>; >+native typedef Texture1DArray<bool>; >+native typedef Texture1DArray<bool2>; >+native typedef Texture1DArray<bool3>; >+native typedef Texture1DArray<bool4>; >+native typedef Texture1DArray<uchar>; >+native typedef Texture1DArray<uchar2>; >+native typedef Texture1DArray<uchar3>; >+native typedef Texture1DArray<uchar4>; >+native typedef Texture1DArray<ushort>; >+native typedef Texture1DArray<ushort2>; >+native typedef Texture1DArray<ushort3>; >+native typedef Texture1DArray<ushort4>; >+native typedef Texture1DArray<uint>; >+native typedef Texture1DArray<uint2>; >+native typedef Texture1DArray<uint3>; >+native typedef Texture1DArray<uint4>; >+native typedef Texture1DArray<char>; >+native typedef Texture1DArray<char2>; >+native typedef Texture1DArray<char3>; >+native typedef Texture1DArray<char4>; >+native typedef Texture1DArray<short>; >+native typedef Texture1DArray<short2>; >+native typedef Texture1DArray<short3>; >+native typedef Texture1DArray<short4>; >+native typedef Texture1DArray<int>; >+native typedef Texture1DArray<int2>; >+native typedef Texture1DArray<int3>; >+native typedef Texture1DArray<int4>; >+native typedef Texture1DArray<half>; >+native typedef Texture1DArray<half2>; >+native typedef Texture1DArray<half3>; >+native typedef Texture1DArray<half4>; >+native typedef Texture1DArray<float>; >+native typedef Texture1DArray<float2>; >+native typedef Texture1DArray<float3>; >+native typedef Texture1DArray<float4>; >+native typedef RWTexture1DArray<bool>; >+native typedef RWTexture1DArray<bool2>; >+native typedef RWTexture1DArray<bool3>; >+native typedef RWTexture1DArray<bool4>; >+native typedef RWTexture1DArray<uchar>; >+native typedef RWTexture1DArray<uchar2>; >+native typedef RWTexture1DArray<uchar3>; >+native typedef RWTexture1DArray<uchar4>; >+native typedef RWTexture1DArray<ushort>; >+native typedef RWTexture1DArray<ushort2>; >+native typedef RWTexture1DArray<ushort3>; >+native typedef RWTexture1DArray<ushort4>; >+native typedef RWTexture1DArray<uint>; >+native typedef RWTexture1DArray<uint2>; >+native typedef RWTexture1DArray<uint3>; >+native typedef RWTexture1DArray<uint4>; >+native typedef RWTexture1DArray<char>; >+native typedef RWTexture1DArray<char2>; >+native typedef RWTexture1DArray<char3>; >+native typedef RWTexture1DArray<char4>; >+native typedef RWTexture1DArray<short>; >+native typedef RWTexture1DArray<short2>; >+native typedef RWTexture1DArray<short3>; >+native typedef RWTexture1DArray<short4>; >+native typedef RWTexture1DArray<int>; >+native typedef RWTexture1DArray<int2>; >+native typedef RWTexture1DArray<int3>; >+native typedef RWTexture1DArray<int4>; >+native typedef RWTexture1DArray<half>; >+native typedef RWTexture1DArray<half2>; >+native typedef RWTexture1DArray<half3>; >+native typedef RWTexture1DArray<half4>; >+native typedef RWTexture1DArray<float>; >+native typedef RWTexture1DArray<float2>; >+native typedef RWTexture1DArray<float3>; >+native typedef RWTexture1DArray<float4>; >+native typedef Texture2D<bool>; >+native typedef Texture2D<bool2>; >+native typedef Texture2D<bool3>; >+native typedef Texture2D<bool4>; >+native typedef Texture2D<uchar>; >+native typedef Texture2D<uchar2>; >+native typedef Texture2D<uchar3>; >+native typedef Texture2D<uchar4>; >+native typedef Texture2D<ushort>; >+native typedef Texture2D<ushort2>; >+native typedef Texture2D<ushort3>; >+native typedef Texture2D<ushort4>; >+native typedef Texture2D<uint>; >+native typedef Texture2D<uint2>; >+native typedef Texture2D<uint3>; >+native typedef Texture2D<uint4>; >+native typedef Texture2D<char>; >+native typedef Texture2D<char2>; >+native typedef Texture2D<char3>; >+native typedef Texture2D<char4>; >+native typedef Texture2D<short>; >+native typedef Texture2D<short2>; >+native typedef Texture2D<short3>; >+native typedef Texture2D<short4>; >+native typedef Texture2D<int>; >+native typedef Texture2D<int2>; >+native typedef Texture2D<int3>; >+native typedef Texture2D<int4>; >+native typedef Texture2D<half>; >+native typedef Texture2D<half2>; >+native typedef Texture2D<half3>; >+native typedef Texture2D<half4>; >+native typedef Texture2D<float>; >+native typedef Texture2D<float2>; >+native typedef Texture2D<float3>; >+native typedef Texture2D<float4>; >+native typedef RWTexture2D<bool>; >+native typedef RWTexture2D<bool2>; >+native typedef RWTexture2D<bool3>; >+native typedef RWTexture2D<bool4>; >+native typedef RWTexture2D<uchar>; >+native typedef RWTexture2D<uchar2>; >+native typedef RWTexture2D<uchar3>; >+native typedef RWTexture2D<uchar4>; >+native typedef RWTexture2D<ushort>; >+native typedef RWTexture2D<ushort2>; >+native typedef RWTexture2D<ushort3>; >+native typedef RWTexture2D<ushort4>; >+native typedef RWTexture2D<uint>; >+native typedef RWTexture2D<uint2>; >+native typedef RWTexture2D<uint3>; >+native typedef RWTexture2D<uint4>; >+native typedef RWTexture2D<char>; >+native typedef RWTexture2D<char2>; >+native typedef RWTexture2D<char3>; >+native typedef RWTexture2D<char4>; >+native typedef RWTexture2D<short>; >+native typedef RWTexture2D<short2>; >+native typedef RWTexture2D<short3>; >+native typedef RWTexture2D<short4>; >+native typedef RWTexture2D<int>; >+native typedef RWTexture2D<int2>; >+native typedef RWTexture2D<int3>; >+native typedef RWTexture2D<int4>; >+native typedef RWTexture2D<half>; >+native typedef RWTexture2D<half2>; >+native typedef RWTexture2D<half3>; >+native typedef RWTexture2D<half4>; >+native typedef RWTexture2D<float>; >+native typedef RWTexture2D<float2>; >+native typedef RWTexture2D<float3>; >+native typedef RWTexture2D<float4>; >+native typedef Texture2DArray<bool>; >+native typedef Texture2DArray<bool2>; >+native typedef Texture2DArray<bool3>; >+native typedef Texture2DArray<bool4>; >+native typedef Texture2DArray<uchar>; >+native typedef Texture2DArray<uchar2>; >+native typedef Texture2DArray<uchar3>; >+native typedef Texture2DArray<uchar4>; >+native typedef Texture2DArray<ushort>; >+native typedef Texture2DArray<ushort2>; >+native typedef Texture2DArray<ushort3>; >+native typedef Texture2DArray<ushort4>; >+native typedef Texture2DArray<uint>; >+native typedef Texture2DArray<uint2>; >+native typedef Texture2DArray<uint3>; >+native typedef Texture2DArray<uint4>; >+native typedef Texture2DArray<char>; >+native typedef Texture2DArray<char2>; >+native typedef Texture2DArray<char3>; >+native typedef Texture2DArray<char4>; >+native typedef Texture2DArray<short>; >+native typedef Texture2DArray<short2>; >+native typedef Texture2DArray<short3>; >+native typedef Texture2DArray<short4>; >+native typedef Texture2DArray<int>; >+native typedef Texture2DArray<int2>; >+native typedef Texture2DArray<int3>; >+native typedef Texture2DArray<int4>; >+native typedef Texture2DArray<half>; >+native typedef Texture2DArray<half2>; >+native typedef Texture2DArray<half3>; >+native typedef Texture2DArray<half4>; >+native typedef Texture2DArray<float>; >+native typedef Texture2DArray<float2>; >+native typedef Texture2DArray<float3>; >+native typedef Texture2DArray<float4>; >+native typedef RWTexture2DArray<bool>; >+native typedef RWTexture2DArray<bool2>; >+native typedef RWTexture2DArray<bool3>; >+native typedef RWTexture2DArray<bool4>; >+native typedef RWTexture2DArray<uchar>; >+native typedef RWTexture2DArray<uchar2>; >+native typedef RWTexture2DArray<uchar3>; >+native typedef RWTexture2DArray<uchar4>; >+native typedef RWTexture2DArray<ushort>; >+native typedef RWTexture2DArray<ushort2>; >+native typedef RWTexture2DArray<ushort3>; >+native typedef RWTexture2DArray<ushort4>; >+native typedef RWTexture2DArray<uint>; >+native typedef RWTexture2DArray<uint2>; >+native typedef RWTexture2DArray<uint3>; >+native typedef RWTexture2DArray<uint4>; >+native typedef RWTexture2DArray<char>; >+native typedef RWTexture2DArray<char2>; >+native typedef RWTexture2DArray<char3>; >+native typedef RWTexture2DArray<char4>; >+native typedef RWTexture2DArray<short>; >+native typedef RWTexture2DArray<short2>; >+native typedef RWTexture2DArray<short3>; >+native typedef RWTexture2DArray<short4>; >+native typedef RWTexture2DArray<int>; >+native typedef RWTexture2DArray<int2>; >+native typedef RWTexture2DArray<int3>; >+native typedef RWTexture2DArray<int4>; >+native typedef RWTexture2DArray<half>; >+native typedef RWTexture2DArray<half2>; >+native typedef RWTexture2DArray<half3>; >+native typedef RWTexture2DArray<half4>; >+native typedef RWTexture2DArray<float>; >+native typedef RWTexture2DArray<float2>; >+native typedef RWTexture2DArray<float3>; >+native typedef RWTexture2DArray<float4>; >+native typedef Texture3D<bool>; >+native typedef Texture3D<bool2>; >+native typedef Texture3D<bool3>; >+native typedef Texture3D<bool4>; >+native typedef Texture3D<uchar>; >+native typedef Texture3D<uchar2>; >+native typedef Texture3D<uchar3>; >+native typedef Texture3D<uchar4>; >+native typedef Texture3D<ushort>; >+native typedef Texture3D<ushort2>; >+native typedef Texture3D<ushort3>; >+native typedef Texture3D<ushort4>; >+native typedef Texture3D<uint>; >+native typedef Texture3D<uint2>; >+native typedef Texture3D<uint3>; >+native typedef Texture3D<uint4>; >+native typedef Texture3D<char>; >+native typedef Texture3D<char2>; >+native typedef Texture3D<char3>; >+native typedef Texture3D<char4>; >+native typedef Texture3D<short>; >+native typedef Texture3D<short2>; >+native typedef Texture3D<short3>; >+native typedef Texture3D<short4>; >+native typedef Texture3D<int>; >+native typedef Texture3D<int2>; >+native typedef Texture3D<int3>; >+native typedef Texture3D<int4>; >+native typedef Texture3D<half>; >+native typedef Texture3D<half2>; >+native typedef Texture3D<half3>; >+native typedef Texture3D<half4>; >+native typedef Texture3D<float>; >+native typedef Texture3D<float2>; >+native typedef Texture3D<float3>; >+native typedef Texture3D<float4>; >+native typedef RWTexture3D<bool>; >+native typedef RWTexture3D<bool2>; >+native typedef RWTexture3D<bool3>; >+native typedef RWTexture3D<bool4>; >+native typedef RWTexture3D<uchar>; >+native typedef RWTexture3D<uchar2>; >+native typedef RWTexture3D<uchar3>; >+native typedef RWTexture3D<uchar4>; >+native typedef RWTexture3D<ushort>; >+native typedef RWTexture3D<ushort2>; >+native typedef RWTexture3D<ushort3>; >+native typedef RWTexture3D<ushort4>; >+native typedef RWTexture3D<uint>; >+native typedef RWTexture3D<uint2>; >+native typedef RWTexture3D<uint3>; >+native typedef RWTexture3D<uint4>; >+native typedef RWTexture3D<char>; >+native typedef RWTexture3D<char2>; >+native typedef RWTexture3D<char3>; >+native typedef RWTexture3D<char4>; >+native typedef RWTexture3D<short>; >+native typedef RWTexture3D<short2>; >+native typedef RWTexture3D<short3>; >+native typedef RWTexture3D<short4>; >+native typedef RWTexture3D<int>; >+native typedef RWTexture3D<int2>; >+native typedef RWTexture3D<int3>; >+native typedef RWTexture3D<int4>; >+native typedef RWTexture3D<half>; >+native typedef RWTexture3D<half2>; >+native typedef RWTexture3D<half3>; >+native typedef RWTexture3D<half4>; >+native typedef RWTexture3D<float>; >+native typedef RWTexture3D<float2>; >+native typedef RWTexture3D<float3>; >+native typedef RWTexture3D<float4>; >+native typedef TextureCube<bool>; >+native typedef TextureCube<bool2>; >+native typedef TextureCube<bool3>; >+native typedef TextureCube<bool4>; >+native typedef TextureCube<uchar>; >+native typedef TextureCube<uchar2>; >+native typedef TextureCube<uchar3>; >+native typedef TextureCube<uchar4>; >+native typedef TextureCube<ushort>; >+native typedef TextureCube<ushort2>; >+native typedef TextureCube<ushort3>; >+native typedef TextureCube<ushort4>; >+native typedef TextureCube<uint>; >+native typedef TextureCube<uint2>; >+native typedef TextureCube<uint3>; >+native typedef TextureCube<uint4>; >+native typedef TextureCube<char>; >+native typedef TextureCube<char2>; >+native typedef TextureCube<char3>; >+native typedef TextureCube<char4>; >+native typedef TextureCube<short>; >+native typedef TextureCube<short2>; >+native typedef TextureCube<short3>; >+native typedef TextureCube<short4>; >+native typedef TextureCube<int>; >+native typedef TextureCube<int2>; >+native typedef TextureCube<int3>; >+native typedef TextureCube<int4>; >+native typedef TextureCube<half>; >+native typedef TextureCube<half2>; >+native typedef TextureCube<half3>; >+native typedef TextureCube<half4>; >+native typedef TextureCube<float>; >+native typedef TextureCube<float2>; >+native typedef TextureCube<float3>; >+native typedef TextureCube<float4>; >+native typedef TextureDepth2D<float>; >+native typedef TextureDepth2D<half>; >+native typedef RWTextureDepth2D<float>; >+native typedef RWTextureDepth2D<half>; >+native typedef TextureDepth2DArray<float>; >+native typedef TextureDepth2DArray<half>; >+native typedef RWTextureDepth2DArray<float>; >+native typedef RWTextureDepth2DArray<half>; >+native typedef TextureDepthCube<float>; >+native typedef TextureDepthCube<half>; > >+operator uchar(uchar x) { >+ return x; >+} >+native operator uchar(ushort); >+native operator uchar(uint); >+native operator uchar(char); >+native operator uchar(short); >+native operator uchar(int); >+native operator uchar(half); >+native operator uchar(float); >+native operator ushort(uchar); >+operator ushort(ushort x) { >+ return x; >+} >+native operator ushort(uint); >+native operator ushort(char); >+native operator ushort(short); >+native operator ushort(int); >+native operator ushort(half); >+native operator ushort(float); >+native operator uint(uchar); >+native operator uint(ushort); >+operator uint(uint x) { >+ return x; >+} >+native operator uint(char); >+native operator uint(short); >+native operator uint(int); >+native operator uint(half); >+native operator uint(float); >+native operator char(uchar); >+native operator char(ushort); >+native operator char(uint); >+operator char(char x) { >+ return x; >+} >+native operator char(short); >+native operator char(int); >+native operator char(half); >+native operator char(float); >+native operator short(uchar); >+native operator short(ushort); >+native operator short(uint); >+native operator short(char); >+operator short(short x) { >+ return x; >+} >+native operator short(int); >+native operator short(half); >+native operator short(float); >+native operator int(uchar); >+native operator int(ushort); >+native operator int(uint); >+native operator int(char); >+native operator int(short); >+operator int(int x) { >+ return x; >+} >+native operator int(half); >+native operator int(float); >+native operator half(uchar); >+native operator half(ushort); >+native operator half(uint); >+native operator half(char); >+native operator half(short); >+native operator half(int); >+operator half(half x) { >+ return x; >+} >+native operator half(float); >+native operator float(uchar); >+native operator float(ushort); >+native operator float(uint); >+native operator float(char); >+native operator float(short); >+native operator float(int); >+native operator float(half); >+operator float(float x) { >+ return x; >+} >+operator bool(bool x) { >+ return x; >+} >+native operator int(atomic_int); >+native operator uint(atomic_uint); >+native bool operator==(bool, bool); >+bool operator&(bool a, bool b) >+{ >+ return a && b; >+} >+bool operator|(bool a, bool b) >+{ >+ return a || b; >+} >+bool operator^(bool a, bool b) >+{ >+ if (a) >+ return !b; >+ return b; >+} >+bool operator~(bool value) >+{ >+ return !value; >+} > native int operator+(int, int); >-native uint operator+(uint, uint); >-uint8 operator+(uint8 a, uint8 b) { return uint8(uint(a) + uint(b)); } >-native float operator+(float, float); >-int operator++(int value) { return value + 1; } >-uint operator++(uint value) { return value + 1; } >-uint8 operator++(uint8 value) { return value + 1; } > native int operator-(int, int); >-native uint operator-(uint, uint); >-uint8 operator-(uint8 a, uint8 b) { return uint8(uint(a) - uint(b)); } >-native float operator-(float, float); >-int operator--(int value) { return value - 1; } >-uint operator--(uint value) { return value - 1; } >-uint8 operator--(uint8 value) { return value - 1; } > native int operator*(int, int); >-native uint operator*(uint, uint); >-uint8 operator*(uint8 a, uint8 b) { return uint8(uint(a) * uint(b)); } >-native float operator*(float, float); > native int operator/(int, int); >+native bool operator==(int, int); >+native bool operator<(int, int); >+native bool operator<=(int, int); >+native bool operator>(int, int); >+native bool operator>=(int, int); >+native uint operator+(uint, uint); >+native uint operator-(uint, uint); >+native uint operator*(uint, uint); > native uint operator/(uint, uint); >-uint8 operator/(uint8 a, uint8 b) { return uint8(uint(a) / uint(b)); } >+native bool operator==(uint, uint); >+native bool operator<(uint, uint); >+native bool operator<=(uint, uint); >+native bool operator>(uint, uint); >+native bool operator>=(uint, uint); >+native float operator+(float, float); >+native float operator-(float, float); >+native float operator*(float, float); >+native float operator/(float, float); >+native bool operator==(float, float); >+native bool operator<(float, float); >+native bool operator<=(float, float); >+native bool operator>(float, float); >+native bool operator>=(float, float); > native int operator&(int, int); > native int operator|(int, int); > native int operator^(int, int); >@@ -88,302 +745,1097 @@ native uint operator^(uint, uint); > native uint operator~(uint); > native uint operator<<(uint, uint); > native uint operator>>(uint, uint); >-uint8 operator&(uint8 a, uint8 b) { return uint8(uint(a) & uint(b)); } >-uint8 operator|(uint8 a, uint8 b) { return uint8(uint(a) | uint(b)); } >-uint8 operator^(uint8 a, uint8 b) { return uint8(uint(a) ^ uint(b)); } >-uint8 operator~(uint8 value) { return uint8(~uint(value)); } >-uint8 operator<<(uint8 a, uint b) { return uint8(uint(a) << (b & 7)); } >-uint8 operator>>(uint8 a, uint b) { return uint8(uint(a) >> (b & 7)); } >-native float operator/(float, float); >-native bool operator==(int, int); >-native bool operator==(uint, uint); >-bool operator==(uint8 a, uint8 b) { return uint(a) == uint(b); } >-native bool operator==(bool, bool); >-native bool operator==(float, float); >-native bool operator<(int, int); >-native bool operator<(uint, uint); >-bool operator<(uint8 a, uint8 b) { return uint(a) < uint(b); } >-native bool operator<(float, float); >-native bool operator<=(int, int); >-native bool operator<=(uint, uint); >-bool operator<=(uint8 a, uint8 b) { return uint(a) <= uint(b); } >-native bool operator<=(float, float); >-native bool operator>(int, int); >-native bool operator>(uint, uint); >-bool operator>(uint8 a, uint8 b) { return uint(a) > uint(b); } >-native bool operator>(float, float); >-native bool operator>=(int, int); >-native bool operator>=(uint, uint); >-bool operator>=(uint8 a, uint8 b) { return uint(a) >= uint(b); } >-native bool operator>=(float, float); >- >-bool operator&(bool a, bool b) >-{ >- if (a) >- return b; >- return false; >+uchar operator+(uchar a, uchar b) { >+ return uchar(uint(a) + uint(b)); > } >- >-bool operator|(bool a, bool b) >-{ >- if (a) >- return true; >- if (b) >- return true; >- return false; >+uchar operator-(uchar a, uchar b) { >+ return uchar(uint(a) - uint(b)); > } >- >-bool operator^(bool a, bool b) >-{ >- if (a) >- return !b; >- return b; >+uchar operator*(uchar a, uchar b) { >+ return uchar(uint(a) * uint(b)); > } >- >-bool operator~(bool value) >-{ >- return !value; >+uchar operator/(uchar a, uchar b) { >+ return uchar(uint(a) / uint(b)); > } >- >-protocol Addable { >- Addable operator+(Addable, Addable); >+uchar operator&(uchar a, uchar b) { >+ return uchar(uint(a) & uint(b)); > } >- >-protocol Equatable { >- bool operator==(Equatable, Equatable); >+uchar operator|(uchar a, uchar b) { >+ return uchar(uint(a) | uint(b)); > } >- >-restricted operator<T> T() >-{ >- T defaultValue; >- return defaultValue; >+uchar operator^(uchar a, uchar b) { >+ return uchar(uint(a) ^ uint(b)); > } >- >-restricted operator<T> T(T x) >-{ >- return x; >+uchar operator~(uchar a) { >+ return uchar(~uint(a)); > } >- >-operator<T:Equatable> bool(T x) >-{ >- return x != T(); >+bool operator==(uchar a, uchar b) { >+ return uint(a) == uint(b); > } >- >-struct vec2<T> { >- T x; >- T y; >+bool operator<(uchar a, uchar b) { >+ return uint(a) < uint(b); > } >- >-typedef int2 = vec2<int>; >-typedef uint2 = vec2<uint>; >-typedef float2 = vec2<float>; >- >-operator<T> vec2<T>(T x, T y) >-{ >- vec2<T> result; >- result.x = x; >- result.y = y; >- return result; >+bool operator<=(uchar a, uchar b) { >+ return uint(a) <= uint(b); > } >- >-bool operator==<T:Equatable>(vec2<T> a, vec2<T> b) >-{ >- return a.x == b.x && a.y == b.y; >+bool operator>(uchar a, uchar b) { >+ return uint(a) > uint(b); > } >- >-thread T* operator&[]<T>(thread vec2<T>* foo, uint index) >-{ >- if (index == 0) >- return &foo->x; >- if (index == 1) >- return &foo->y; >- trap; >+bool operator>=(uchar a, uchar b) { >+ return uint(a) >= uint(b); > } >- >-struct vec3<T> { >- T x; >- T y; >- T z; >+ushort operator+(ushort a, ushort b) { >+ return ushort(uint(a) + uint(b)); >+} >+ushort operator-(ushort a, ushort b) { >+ return ushort(uint(a) - uint(b)); >+} >+ushort operator*(ushort a, ushort b) { >+ return ushort(uint(a) * uint(b)); >+} >+ushort operator/(ushort a, ushort b) { >+ return ushort(uint(a) / uint(b)); >+} >+ushort operator&(ushort a, ushort b) { >+ return ushort(uint(a) & uint(b)); >+} >+ushort operator|(ushort a, ushort b) { >+ return ushort(uint(a) | uint(b)); >+} >+ushort operator^(ushort a, ushort b) { >+ return ushort(uint(a) ^ uint(b)); >+} >+ushort operator~(ushort a) { >+ return ushort(~uint(a)); >+} >+bool operator==(ushort a, ushort b) { >+ return uint(a) == uint(b); >+} >+bool operator<(ushort a, ushort b) { >+ return uint(a) < uint(b); >+} >+bool operator<=(ushort a, ushort b) { >+ return uint(a) <= uint(b); >+} >+bool operator>(ushort a, ushort b) { >+ return uint(a) > uint(b); >+} >+bool operator>=(ushort a, ushort b) { >+ return uint(a) >= uint(b); >+} >+uchar operator<<(uchar a, uint b) { >+ return uchar(uint(a) << (b & 255)); >+} >+ushort operator<<(ushort a, uint b) { >+ return ushort(uint(a) << (b & 65535)); >+} >+uchar operator>>(uchar a, uint b) { >+ return uchar(uint(a) >> (b & 255)); >+} >+ushort operator>>(ushort a, uint b) { >+ return ushort(uint(a) >> (b & 65535)); >+} >+char operator+(char a, char b) { >+ return char(int(a) + int(b)); >+} >+char operator-(char a, char b) { >+ return char(int(a) - int(b)); >+} >+char operator*(char a, char b) { >+ return char(int(a) * int(b)); >+} >+char operator/(char a, char b) { >+ return char(int(a) / int(b)); >+} >+char operator&(char a, char b) { >+ return char(int(a) & int(b)); >+} >+char operator|(char a, char b) { >+ return char(int(a) | int(b)); >+} >+char operator^(char a, char b) { >+ return char(int(a) ^ int(b)); >+} >+char operator~(char a) { >+ return char(~int(a)); >+} >+bool operator==(char a, char b) { >+ return int(a) == int(b); >+} >+bool operator>(char a, char b) { >+ return int(a) > int(b); >+} >+bool operator>=(char a, char b) { >+ return int(a) >= int(b); >+} >+bool operator<(char a, char b) { >+ return int(a) < int(b); >+} >+bool operator<=(char a, char b) { >+ return int(a) <= int(b); >+} >+short operator+(short a, short b) { >+ return short(int(a) + int(b)); >+} >+short operator-(short a, short b) { >+ return short(int(a) - int(b)); >+} >+short operator*(short a, short b) { >+ return short(int(a) * int(b)); >+} >+short operator/(short a, short b) { >+ return short(int(a) / int(b)); >+} >+short operator&(short a, short b) { >+ return short(int(a) & int(b)); >+} >+short operator|(short a, short b) { >+ return short(int(a) | int(b)); >+} >+short operator^(short a, short b) { >+ return short(int(a) ^ int(b)); >+} >+short operator~(short a) { >+ return short(~int(a)); >+} >+bool operator==(short a, short b) { >+ return int(a) == int(b); >+} >+bool operator>(short a, short b) { >+ return int(a) > int(b); >+} >+bool operator>=(short a, short b) { >+ return int(a) >= int(b); >+} >+bool operator<(short a, short b) { >+ return int(a) < int(b); >+} >+bool operator<=(short a, short b) { >+ return int(a) <= int(b); >+} >+char operator<<(char a, uint b) { >+ return char(int(a) << (b & 255)); >+} >+short operator<<(short a, uint b) { >+ return short(int(a) << (b & 65535)); >+} >+char operator>>(char a, uint b) { >+ return char(int(a) >> (b & 255)); >+} >+short operator>>(short a, uint b) { >+ return short(int(a) >> (b & 65535)); >+} >+uchar operator++(uchar value) { >+ return value + 1; >+} >+uchar operator--(uchar value) { >+ return value - 1; >+} >+ushort operator++(ushort value) { >+ return value + 1; >+} >+ushort operator--(ushort value) { >+ return value - 1; >+} >+uint operator++(uint value) { >+ return value + 1; >+} >+uint operator--(uint value) { >+ return value - 1; >+} >+char operator++(char value) { >+ return value + 1; >+} >+char operator--(char value) { >+ return value - 1; >+} >+short operator++(short value) { >+ return value + 1; >+} >+short operator--(short value) { >+ return value - 1; >+} >+int operator++(int value) { >+ return value + 1; >+} >+int operator--(int value) { >+ return value - 1; >+} >+half operator++(half value) { >+ return value + 1; >+} >+half operator--(half value) { >+ return value - 1; >+} >+float operator++(float value) { >+ return value + 1; >+} >+float operator--(float value) { >+ return value - 1; >+} >+half operator+(half a, half b) { >+ return half(float(a) + float(b)); >+} >+half operator-(half a, half b) { >+ return half(float(a) - float(b)); >+} >+half operator*(half a, half b) { >+ return half(float(a) * float(b)); >+} >+half operator/(half a, half b) { >+ return half(float(a) / float(b)); >+} >+bool operator==(half a, half b) { >+ return float(a) == float(b); >+} >+bool operator<(half a, half b) { >+ return float(a) < float(b); >+} >+bool operator<=(half a, half b) { >+ return float(a) <= float(b); >+} >+bool operator<(half a, half b) { >+ return float(a) < float(b); >+} >+bool operator<=(half a, half b) { >+ return float(a) <= float(b); > } > >-typedef int3 = vec3<int>; >-typedef uint3 = vec3<uint>; >-typedef float3 = vec3<float>; >- >-operator<T> vec3<T>(T x, T y, T z) >-{ >- vec3<T> result; >+operator bool2(bool x, bool y) { >+ bool2 result; > result.x = x; > result.y = y; >- result.z = z; > return result; > } >- >-operator<T> vec3<T>(vec2<T> v2, T z) >-{ >- vec3<T> result; >- result.x = v2.x; >- result.y = v2.y; >+operator bool3(bool x, bool y, bool z) { >+ bool3 result; >+ result.x = x; >+ result.y = y; > result.z = z; > return result; > } >- >-operator<T> vec3<T>(T x, vec2<T> v2) >-{ >- vec3<T> result; >- result.x = x; >- result.y = v2.x; >- result.z = v2.y; >+operator bool3(bool2 x, bool y) { >+ bool3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; > 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) >- return &foo->x; >- if (index == 1) >- return &foo->y; >- if (index == 2) >- return &foo->z; >- trap; >-} >- >-struct vec4<T> { >- T x; >- T y; >- T z; >- T w; >+operator bool3(bool x, bool2 y) { >+ bool3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; > } >- >-typedef int4 = vec4<int>; >-typedef uint4 = vec4<uint>; >-typedef float4 = vec4<float>; >- >-operator<T> vec4<T>(T x, T y, T z, T w) >-{ >- vec4<T> result; >+operator bool4(bool x, bool y, bool z, bool w) { >+ bool4 result; > result.x = x; > result.y = y; > result.z = z; > result.w = w; > return result; > } >- >-operator<T> vec4<T>(vec2<T> v2, T z, T w) >-{ >- vec4<T> result; >- result.x = v2.x; >- result.y = v2.y; >- result.z = z; >- result.w = w; >+operator bool4(bool2 x, bool y, bool z) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; > return result; > } >- >-operator<T> vec4<T>(T x, vec2<T> v2, T w) >-{ >- vec4<T> result; >+operator bool4(bool x, bool2 y, bool z) { >+ bool4 result; > result.x = x; >- result.y = v2.x; >- result.z = v2.y; >- result.w = w; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; > return result; > } >- >-operator<T> vec4<T>(T x, T y, vec2<T> v2) >-{ >- vec4<T> result; >+operator bool4(bool x, bool y, bool2 z) { >+ bool4 result; > result.x = x; > result.y = y; >- result.z = v2.x; >- result.w = v2.y; >+ result.z = z.x; >+ result.w = z.y; > return result; > } >- >-operator<T> vec4<T>(vec2<T> v2a, vec2<T> v2b) >-{ >- vec4<T> result; >- result.x = v2a.x; >- result.y = v2a.y; >- result.z = v2b.x; >- result.w = v2b.y; >+operator bool4(bool2 x, bool2 y) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; > return result; > } >- >-operator<T> vec4<T>(vec3<T> v3, T w) >-{ >- vec4<T> result; >- result.x = v3.x; >- result.y = v3.y; >- result.z = v3.z; >+operator bool4(bool3 x, bool y) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator bool4(bool x, bool3 y) { >+ bool4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(bool2) { >+ return 2; >+} >+uint operator.length(bool3) { >+ return 3; >+} >+uint operator.length(bool4) { >+ return 4; >+} >+operator uchar2(uchar x, uchar y) { >+ uchar2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator uchar3(uchar x, uchar y, uchar z) { >+ uchar3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator uchar3(uchar2 x, uchar y) { >+ uchar3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator uchar3(uchar x, uchar2 y) { >+ uchar3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator uchar4(uchar x, uchar y, uchar z, uchar w) { >+ uchar4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; > result.w = w; > return result; > } >- >-operator<T> vec4<T>(T x, vec3<T> v3) >-{ >- vec4<T> result; >+operator uchar4(uchar2 x, uchar y, uchar z) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator uchar4(uchar x, uchar2 y, uchar z) { >+ uchar4 result; > result.x = x; >- result.y = v3.x; >- result.z = v3.y; >- result.w = v3.z; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; > 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; >+operator uchar4(uchar x, uchar y, uchar2 z) { >+ uchar4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; > } >- >-thread T* operator&[]<T>(thread vec4<T>* foo, uint index) >-{ >- if (index == 0) >- return &foo->x; >- if (index == 1) >- return &foo->y; >- if (index == 2) >- return &foo->z; >- if (index == 3) >- return &foo->w; >- trap; >+operator uchar4(uchar2 x, uchar2 y) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; > } >- >-native thread T* operator&[]<T>(thread T[], uint); >-native threadgroup T* operator&[]<T>(threadgroup T[], uint); >-native device T* operator&[]<T>(device T[], uint); >-native constant T* operator&[]<T>(constant T[], uint); >- >-native uint operator.length<T>(thread T[]); >-native uint operator.length<T>(threadgroup T[]); >-native uint operator.length<T>(device T[]); >-native uint operator.length<T>(constant T[]); >- >-uint operator.length<T, uint length>(T[length]) >-{ >- return length; >+operator uchar4(uchar3 x, uchar y) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; > } >-`; >- >-function intToString(x) >-{ >- switch (x) { >- case 0: >- return "x"; >- case 1: >- return "y"; >- case 2: >- return "z"; >- case 3: >- return "w"; >- default: >- throw new Error("Could not generate standard library."); >- } >+operator uchar4(uchar x, uchar3 y) { >+ uchar4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; > } >- >-// 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 >+uint operator.length(uchar2) { >+ return 2; >+} >+uint operator.length(uchar3) { >+ return 3; >+} >+uint operator.length(uchar4) { >+ return 4; >+} >+operator ushort2(ushort x, ushort y) { >+ ushort2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator ushort3(ushort x, ushort y, ushort z) { >+ ushort3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator ushort3(ushort2 x, ushort y) { >+ ushort3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator ushort3(ushort x, ushort2 y) { >+ ushort3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator ushort4(ushort x, ushort y, ushort z, ushort w) { >+ ushort4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator ushort4(ushort2 x, ushort y, ushort z) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator ushort4(ushort x, ushort2 y, ushort z) { >+ ushort4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator ushort4(ushort x, ushort y, ushort2 z) { >+ ushort4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator ushort4(ushort2 x, ushort2 y) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator ushort4(ushort3 x, ushort y) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator ushort4(ushort x, ushort3 y) { >+ ushort4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(ushort2) { >+ return 2; >+} >+uint operator.length(ushort3) { >+ return 3; >+} >+uint operator.length(ushort4) { >+ return 4; >+} >+operator uint2(uint x, uint y) { >+ uint2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator uint3(uint x, uint y, uint z) { >+ uint3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator uint3(uint2 x, uint y) { >+ uint3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator uint3(uint x, uint2 y) { >+ uint3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator uint4(uint x, uint y, uint z, uint w) { >+ uint4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator uint4(uint2 x, uint y, uint z) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator uint4(uint x, uint2 y, uint z) { >+ uint4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator uint4(uint x, uint y, uint2 z) { >+ uint4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator uint4(uint2 x, uint2 y) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator uint4(uint3 x, uint y) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator uint4(uint x, uint3 y) { >+ uint4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(uint2) { >+ return 2; >+} >+uint operator.length(uint3) { >+ return 3; >+} >+uint operator.length(uint4) { >+ return 4; >+} >+operator char2(char x, char y) { >+ char2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator char3(char x, char y, char z) { >+ char3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator char3(char2 x, char y) { >+ char3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator char3(char x, char2 y) { >+ char3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator char4(char x, char y, char z, char w) { >+ char4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator char4(char2 x, char y, char z) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator char4(char x, char2 y, char z) { >+ char4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator char4(char x, char y, char2 z) { >+ char4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator char4(char2 x, char2 y) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator char4(char3 x, char y) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator char4(char x, char3 y) { >+ char4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(char2) { >+ return 2; >+} >+uint operator.length(char3) { >+ return 3; >+} >+uint operator.length(char4) { >+ return 4; >+} >+operator short2(short x, short y) { >+ short2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator short3(short x, short y, short z) { >+ short3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator short3(short2 x, short y) { >+ short3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator short3(short x, short2 y) { >+ short3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator short4(short x, short y, short z, short w) { >+ short4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator short4(short2 x, short y, short z) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator short4(short x, short2 y, short z) { >+ short4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator short4(short x, short y, short2 z) { >+ short4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator short4(short2 x, short2 y) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator short4(short3 x, short y) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator short4(short x, short3 y) { >+ short4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(short2) { >+ return 2; >+} >+uint operator.length(short3) { >+ return 3; >+} >+uint operator.length(short4) { >+ return 4; >+} >+operator int2(int x, int y) { >+ int2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator int3(int x, int y, int z) { >+ int3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator int3(int2 x, int y) { >+ int3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator int3(int x, int2 y) { >+ int3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator int4(int x, int y, int z, int w) { >+ int4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator int4(int2 x, int y, int z) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator int4(int x, int2 y, int z) { >+ int4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator int4(int x, int y, int2 z) { >+ int4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator int4(int2 x, int2 y) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator int4(int3 x, int y) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator int4(int x, int3 y) { >+ int4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(int2) { >+ return 2; >+} >+uint operator.length(int3) { >+ return 3; >+} >+uint operator.length(int4) { >+ return 4; >+} >+operator half2(half x, half y) { >+ half2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator half3(half x, half y, half z) { >+ half3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator half3(half2 x, half y) { >+ half3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator half3(half x, half2 y) { >+ half3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator half4(half x, half y, half z, half w) { >+ half4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator half4(half2 x, half y, half z) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator half4(half x, half2 y, half z) { >+ half4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator half4(half x, half y, half2 z) { >+ half4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator half4(half2 x, half2 y) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator half4(half3 x, half y) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator half4(half x, half3 y) { >+ half4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(half2) { >+ return 2; >+} >+uint operator.length(half3) { >+ return 3; >+} >+uint operator.length(half4) { >+ return 4; >+} >+operator float2(float x, float y) { >+ float2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator float3(float x, float y, float z) { >+ float3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator float3(float2 x, float y) { >+ float3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator float3(float x, float2 y) { >+ float3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator float4(float x, float y, float z, float w) { >+ float4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator float4(float2 x, float y, float z) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator float4(float x, float2 y, float z) { >+ float4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator float4(float x, float y, float2 z) { >+ float4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator float4(float2 x, float2 y) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator float4(float3 x, float y) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator float4(float x, float3 y) { >+ float4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(float2) { >+ return 2; >+} >+uint operator.length(float3) { >+ return 3; >+} >+uint operator.length(float4) { >+ return 4; >+} >+bool operator==(bool2 a, bool2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(bool3 a, bool3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(bool4 a, bool4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+`; >diff --git a/Tools/WebGPUShadingLanguageRI/StatementCloner.js b/Tools/WebGPUShadingLanguageRI/StatementCloner.js >index c9479a285ba0e13535dea37f7fc1a63bc71cf316..3b84888a7055760d60ea68321c54381d6bf44768 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; >@@ -54,52 +51,24 @@ class StatementCloner extends Rewriter { > visitNativeType(node) > { > return new NativeType( >- node.origin, node.name, node.typeParameters.map(typeParameter => typeParameter.visit(this))); >+ node.origin, node.baseName, node.typeArguments.map(typeArgument => typeArgument.visit(this))); > } > > visitTypeDef(node) > { > return new TypeDef( > node.origin, node.name, >- node.typeParameters.map(typeParameter => typeParameter.visit(this)), > node.type.visit(this)); > } > > visitStructType(node) > { >- let result = new StructType( >- node.origin, node.name, >- node.typeParameters.map(typeParameter => typeParameter.visit(this))); >+ let result = new StructType(node.origin, node.name); > for (let field of node.fields) > result.add(field.visit(this)); > 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..7441deeed43d062db1303676490f368ceb6d83d8 100644 >--- a/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js >+++ b/Tools/WebGPUShadingLanguageRI/StructLayoutBuilder.js >@@ -39,8 +39,6 @@ class StructLayoutBuilder extends Visitor { > { > if (node.size != null) > return; >- if (node.typeParameters.length) >- throw new Error("Cannot do layout for generic type: " + node); > let oldOffset = this._offset; > this._offset = 0; > super.visitStructType(node); >@@ -60,12 +58,6 @@ class StructLayoutBuilder extends Visitor { > this._offset += size; > } > >- visitNativeFuncInstance(node) >- { >- super.visitNativeFuncInstance(node); >- node.func.didLayoutStructsInImplementationData(node.implementationData); >- } >- > visitTypeRef(node) > { > super.visitTypeRef(node); >@@ -76,13 +68,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/Substitution.js b/Tools/WebGPUShadingLanguageRI/Substitution.js >index 6a223f6794a856c64308df40ab918aca2086fb29..4acdffcecc561a23342033e1b8dd31bae33566b8 100644 >--- a/Tools/WebGPUShadingLanguageRI/Substitution.js >+++ b/Tools/WebGPUShadingLanguageRI/Substitution.js >@@ -40,12 +40,8 @@ class Substitution extends Rewriter { > visitTypeRef(node) > { > let replacement = this._map.get(node.type); >- if (replacement) { >- if (node.typeArguments.length) >- throw new Error("Unexpected type arguments on type variable"); >- let result = replacement.visit(new AutoWrapper()); >- return result; >- } >+ if (replacement) >+ return replacement.visit(new AutoWrapper()); > > let result = super.visitTypeRef(node); > return result; >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..0aa7560ea53feabc9779d208bc4ade69b19c8842 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. >@@ -89,23 +69,21 @@ function synthesizeStructAccessors(program) > > function createFieldType() > { >- return field.type.visit(new Substitution(type.typeParameters, typeParameters)); >+ return field.type.visit(new Rewriter()); > } > > function createTypeRef() > { >- return TypeRef.instantiate(type, createTypeArguments()); >+ return TypeRef.instantiate(type); > } > > let isCast = false; > let shaderType; >- let typeParameters; > 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 +93,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 +111,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..7ad4ad7b450565e4c56db590a6209f8e712e2d0b 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> >@@ -63,7 +61,6 @@ > <script src="ForLoop.js"></script> > <script src="Func.js"></script> > <script src="FuncDef.js"></script> >-<script src="FuncInstantiator.js"></script> > <script src="FuncParameter.js"></script> > <script src="FunctionLikeBlock.js"></script> > <script src="HighZombieFinder.js"></script> >@@ -73,7 +70,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> >@@ -90,9 +86,7 @@ > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> > <script src="NativeFunc.js"></script> >-<script src="NativeFuncInstance.js"></script> > <script src="NativeType.js"></script> >-<script src="NativeTypeInstance.js"></script> > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >@@ -103,10 +97,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 +121,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..091b843542aca591dff22d0a65a3549b8cce01e2 100644 >--- a/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/TypeDefResolver.js >@@ -34,21 +34,9 @@ class TypeDefResolver extends Visitor { > visitTypeRef(node) > { > this._visiting.doVisit(node, () => { >- for (let typeArgument of node.typeArguments) >- typeArgument.visit(this); > if (node.type instanceof TypeDef) { >- let unificationContext = new UnificationContext(node.type.typeParameters); >- if (node.typeArguments.length != node.type.typeParameters.length) >- throw new Error("argument/parameter mismatch (should have been caught earlier)"); >- for (let i = 0; i < node.typeArguments.length; ++i) >- node.typeArguments[i].unify(unificationContext, node.type.typeParameters[i]); >- let verificationResult = unificationContext.verify(); >- if (!verificationResult.result) >- throw new WTypeError(node.origin.originString, "Type reference to a type definition violates protocol constraints: " + verificationResult.reason); >- >- let newType = node.type.type.substituteToUnification(node.type.typeParameters, unificationContext); >- newType.visit(this); >- node.setTypeAndArguments(newType, []); >+ node.type.visit(this); >+ node.setType(node.type.type); > } > }); > } >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/UnificationContext.js b/Tools/WebGPUShadingLanguageRI/UnificationContext.js >index 0a13de43d5326e1357c87f8859d9d6015e0cad47..fec535145963862c5be042c8dfbe43f495e42b81 100644 >--- a/Tools/WebGPUShadingLanguageRI/UnificationContext.js >+++ b/Tools/WebGPUShadingLanguageRI/UnificationContext.js >@@ -25,9 +25,8 @@ > "use strict"; > > class UnificationContext { >- constructor(typeParameters) >+ constructor() > { >- this._typeParameters = new Set(typeParameters); > this._nextMap = new Map(); > this._extraNodes = new Set(); > } >@@ -45,10 +44,6 @@ class UnificationContext { > throw new Error("Cannot unify non-unifiable things " + a + " and " + b); > } > >- // Make sure that type parameters don't end up being roots. >- if (a.isUnifiable && b.isUnifiable && this._typeParameters.has(b)) >- [a, b] = [b, a]; >- > this._nextMap.set(a, b); > } > >@@ -85,18 +80,6 @@ class UnificationContext { > return result; > } > >- typeParameters() { return this._typeParameters; } >- *typeArguments() >- { >- for (let typeArgument of this.nodes) { >- if (!typeArgument.isUnifiable) >- continue; >- if (this._typeParameters.has(typeArgument)) >- continue; >- yield typeArgument; >- } >- } >- > verify() > { > // We do a two-phase pre-verification. This gives literals a chance to select a more specific type. >@@ -111,40 +94,7 @@ class UnificationContext { > if (!result.result) > return result; > } >- >- for (let typeParameter of this._typeParameters) { >- let result = typeParameter.verifyAsParameter(this); >- if (!result.result) >- return result; >- } >- let numTypeVariableArguments = 0; >- let argumentSet = new Set(); >- for (let typeArgument of this.typeArguments()) { >- let result = typeArgument.verifyAsArgument(this); >- if (!result.result) >- return result; >- if (typeArgument.isLiteral) >- continue; >- argumentSet.add(this.find(typeArgument)); >- numTypeVariableArguments++; >- } >- if (argumentSet.size == numTypeVariableArguments) >- return {result: true}; >- return {result: false, reason: "Type variables used as arguments got unified with each other"}; >- } >- >- get conversionCost() >- { >- let result = 0; >- for (let typeArgument of this.typeArguments()) >- result += typeArgument.conversionCost(this); >- return result; >- } >- >- commit() >- { >- for (let typeArgument of this.typeArguments()) >- typeArgument.commitUnification(this); >+ return {result: true}; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/Visitor.js b/Tools/WebGPUShadingLanguageRI/Visitor.js >index 4bf05313e2857d71efe513ee1e35f050def5336d..466ee77055dddbeb12767500870fa36b74428396 100644 >--- a/Tools/WebGPUShadingLanguageRI/Visitor.js >+++ b/Tools/WebGPUShadingLanguageRI/Visitor.js >@@ -34,17 +34,10 @@ class Visitor { > visitFunc(node) > { > node.returnType.visit(this); >- for (let typeParameter of node.typeParameters) >- typeParameter.visit(this); > for (let parameter of node.parameters) > parameter.visit(this); > } > >- visitProtocolFuncDecl(node) >- { >- this.visitFunc(node); >- } >- > visitFuncParameter(node) > { > node.type.visit(this); >@@ -61,12 +54,6 @@ class Visitor { > this.visitFunc(node); > } > >- visitNativeFuncInstance(node) >- { >- this.visitFunc(node); >- node.func.visitImplementationData(node.implementationData, this); >- } >- > visitBlock(node) > { > for (let statement of node.statements) >@@ -79,62 +66,27 @@ 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) >- typeArgument.visit(this); > } > > visitNativeType(node) > { >- for (let typeParameter of node.typeParameters) >- typeParameter.visit(this); >- } >- >- visitNativeTypeInstance(node) >- { >- node.type.visit(this); > for (let typeArgument of node.typeArguments) > typeArgument.visit(this); > } > > visitTypeDef(node) > { >- for (let typeParameter of node.typeParameters) >- typeParameter.visit(this); > node.type.visit(this); > } > > visitStructType(node) > { >- for (let typeParameter of node.typeParameters) >- typeParameter.visit(this); > for (let field of node.fields) > field.visit(this); > } > >- visitTypeVariable(node) >- { >- Node.visit(node.protocol, this); >- } >- >- visitConstexprTypeParameter(node) >- { >- node.type.visit(this); >- } >- > visitField(node) > { > node.type.visit(this); >@@ -336,18 +288,8 @@ class Visitor { > > visitCallExpression(node) > { >- for (let typeArgument of node.typeArguments) >- 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..0eb4e81ec2fc3639970d9c63a3fbcce996cb410a 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); >@@ -76,14 +71,4 @@ 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. >- >- // NOTE: This needs to be kept in sync with AutoWrapper. > } >diff --git a/Tools/WebGPUShadingLanguageRI/index.html b/Tools/WebGPUShadingLanguageRI/index.html >index 8094b193781b4aa9b0c3909e9a91d2815f2b2aba..0dd04ef2d141018cde4d3095dc8b70f19f017321 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> >@@ -63,7 +61,6 @@ > <script src="ForLoop.js"></script> > <script src="Func.js"></script> > <script src="FuncDef.js"></script> >-<script src="FuncInstantiator.js"></script> > <script src="FuncParameter.js"></script> > <script src="FunctionLikeBlock.js"></script> > <script src="HighZombieFinder.js"></script> >@@ -73,7 +70,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> >@@ -90,9 +86,7 @@ > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> > <script src="NativeFunc.js"></script> >-<script src="NativeFuncInstance.js"></script> > <script src="NativeType.js"></script> >-<script src="NativeTypeInstance.js"></script> > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >@@ -103,10 +97,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 +121,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 +331,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 +413,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