Skip to content

Commit 5149a2d

Browse files
committed
Merge remote-tracking branch 'origin/master' into release
2 parents 191776d + b942d61 commit 5149a2d

20 files changed

+4185
-703
lines changed

package-lock.json

+32-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"assemblyscript",
99
"wasm"
1010
],
11-
"version": "0.9.1",
11+
"version": "0.9.2",
1212
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
1313
"contributors": [],
1414
"license": "Apache-2.0",
@@ -21,13 +21,13 @@
2121
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
2222
},
2323
"dependencies": {
24-
"binaryen": "90.0.0-nightly.20200208",
24+
"binaryen": "90.0.0-nightly.20200214",
2525
"long": "^4.0.0",
2626
"source-map-support": "^0.5.16",
2727
"ts-node": "^6.2.0"
2828
},
2929
"devDependencies": {
30-
"@types/node": "^13.5.1",
30+
"@types/node": "^13.7.1",
3131
"browser-process-hrtime": "^1.0.0",
3232
"diff": "^4.0.2",
3333
"glob": "^7.1.6",
@@ -37,8 +37,8 @@
3737
"ts-node": "^6.2.0",
3838
"tslint": "^5.20.1",
3939
"typescript": "^3.7.5",
40-
"webpack": "^4.41.5",
41-
"webpack-cli": "^3.3.10"
40+
"webpack": "^4.41.6",
41+
"webpack-cli": "^3.3.11"
4242
},
4343
"main": "index.js",
4444
"types": "index.d.ts",

src/ast.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,11 @@ export class NamedTypeNode extends TypeNode {
10941094
name: TypeName;
10951095
/** Type argument references. */
10961096
typeArguments: TypeNode[] | null;
1097+
1098+
get hasTypeArguments(): bool {
1099+
var typeArguments = this.typeArguments;
1100+
return typeArguments !== null && typeArguments.length > 0;
1101+
}
10971102
}
10981103

10991104
/** Represents a function type. */

src/builtins.ts

+53-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import {
6464
Global,
6565
DecoratorFlags,
6666
Element,
67-
Class
67+
ClassPrototype
6868
} from "./program";
6969

7070
import {
@@ -4971,6 +4971,58 @@ export function compileRTTI(compiler: Compiler): void {
49714971
}
49724972
}
49734973

4974+
/** Compiles a class-specific instanceof helper, checking a ref against all concrete instances. */
4975+
export function compileClassInstanceOf(compiler: Compiler, prototype: ClassPrototype): void {
4976+
var module = compiler.module;
4977+
var nativeSizeType = compiler.options.nativeSizeType;
4978+
var instanceofInstance = assert(prototype.program.instanceofInstance);
4979+
compiler.compileFunction(instanceofInstance);
4980+
4981+
var stmts = new Array<ExpressionRef>();
4982+
4983+
// if (!ref) return false
4984+
stmts.push(
4985+
module.if(
4986+
module.unary(
4987+
nativeSizeType == NativeType.I64
4988+
? UnaryOp.EqzI64
4989+
: UnaryOp.EqzI32,
4990+
module.local_get(0, nativeSizeType)
4991+
),
4992+
module.return(
4993+
module.i32(0)
4994+
)
4995+
)
4996+
);
4997+
4998+
// if (__instanceof(ref, ID[i])) return true
4999+
var instances = prototype.instances;
5000+
if (instances !== null && instances.size) {
5001+
for (let instance of instances.values()) {
5002+
stmts.push(
5003+
module.if(
5004+
module.call(instanceofInstance.internalName, [
5005+
module.local_get(0, nativeSizeType),
5006+
module.i32(instance.id)
5007+
], NativeType.I32),
5008+
module.return(
5009+
module.i32(1)
5010+
)
5011+
)
5012+
);
5013+
}
5014+
}
5015+
5016+
// return false
5017+
stmts.push(
5018+
module.return(
5019+
module.i32(0)
5020+
)
5021+
);
5022+
5023+
module.addFunction(prototype.internalName + "~instanceof", nativeSizeType, NativeType.I32, null, module.flatten(stmts));
5024+
}
5025+
49745026
// Helpers
49755027

49765028
/** Evaluates the constant type of a type argument *or* expression. */

0 commit comments

Comments
 (0)