mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 23:12:19 +00:00
Use the element type annotated on the setter when doing indexed sets
This commit is contained in:
parent
78a3dcfaf0
commit
88b00c1689
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -4,9 +4,11 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate",
|
||||
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -a build/optimized.asm.js -O3 --validate --noDebug --noAssert",
|
||||
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
|
||||
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -O3 --validate --noDebug --noAssert",
|
||||
"asbuild:asmjs": "asc assembly/index.ts -a build/index.asm.js -O3 --validate --noDebug --noAssert",
|
||||
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized && npm run asbuild:asmjs",
|
||||
"tsbuild": "tsc -p assembly -t ES2017 -m commonjs --outDir build",
|
||||
"build": "npm run asbuild && npm run tsbuild",
|
||||
"server": "http-server . -o -c-1",
|
||||
"test": "node tests"
|
||||
},
|
||||
|
@ -4,7 +4,7 @@ const fs = require("fs");
|
||||
const nbodyWASM = require("../index.js");
|
||||
|
||||
// Load ASMJS version
|
||||
src = fs.readFileSync(__dirname + "/../build/optimized.asm.js", "utf8");
|
||||
src = fs.readFileSync(__dirname + "/../build/index.asm.js", "utf8");
|
||||
if (src.indexOf("var Math_sqrt =") < 0) { // currently missing in asm.js output
|
||||
let p = src.indexOf(" var abort = env.abort;");
|
||||
src = src.substring(0, p) + " var Math_sqrt = global.Math.sqrt;\n " + src.substring(p);
|
||||
|
@ -4281,15 +4281,24 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
case ElementKind.CLASS: {
|
||||
if (program.resolvedElementExpression) { // indexed access
|
||||
let indexedSet = (<Class>target).lookupOverload(OperatorKind.INDEXED_SET);
|
||||
if (!indexedSet) {
|
||||
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET);
|
||||
if (!indexedGet) {
|
||||
this.error(
|
||||
DiagnosticCode.Index_signature_is_missing_in_type_0,
|
||||
expression.range, (<Class>target).internalName
|
||||
);
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Index_signature_in_type_0_only_permits_reading,
|
||||
expression.range, (<Class>target).internalName
|
||||
);
|
||||
}
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
elementType = indexedGet.signature.returnType;
|
||||
assert(indexedSet.signature.parameterTypes.length == 2); // parser must guarantee this
|
||||
elementType = indexedSet.signature.parameterTypes[1]; // 2nd parameter is the element
|
||||
break;
|
||||
}
|
||||
// fall-through
|
||||
|
Loading…
x
Reference in New Issue
Block a user