Skip to content

Commit 9cc0fcd

Browse files
committed
Initial ArrayBuffer implementation; Conditional allocation within constructors; Explicit constructor return values
1 parent 8cfc479 commit 9cc0fcd

18 files changed

+6282
-173
lines changed

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/builtins.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,44 +2462,46 @@ const allocateInternalName = "allocate_memory";
24622462
/** Compiles a memory allocation for an instance of the specified class. */
24632463
export function compileAllocate(
24642464
compiler: Compiler,
2465-
cls: Class,
2465+
classInstance: Class,
24662466
reportNode: Node
24672467
): ExpressionRef {
24682468
var program = compiler.program;
2469-
assert(cls.program == program);
2469+
assert(classInstance.program == program);
24702470
var module = compiler.module;
24712471
var options = compiler.options;
24722472

2473-
var prototype = program.elementsLookup.get(allocateInternalName);
2474-
if (!prototype) {
2473+
var allocatePrototype = program.elementsLookup.get(allocateInternalName);
2474+
if (!allocatePrototype) {
24752475
program.error(
24762476
DiagnosticCode.Cannot_find_name_0,
24772477
reportNode.range, allocateInternalName
24782478
);
24792479
return module.createUnreachable();
24802480
}
2481-
if (prototype.kind != ElementKind.FUNCTION_PROTOTYPE) {
2481+
if (allocatePrototype.kind != ElementKind.FUNCTION_PROTOTYPE) {
24822482
program.error(
24832483
DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,
2484-
reportNode.range, prototype.internalName
2484+
reportNode.range, allocatePrototype.internalName
24852485
);
24862486
return module.createUnreachable();
24872487
}
24882488

2489-
var instance = (<FunctionPrototype>prototype).resolve(); // reports
2490-
if (!(instance && compiler.compileFunction(instance))) return module.createUnreachable();
2489+
var allocateInstance = (<FunctionPrototype>allocatePrototype).resolve(); // reports
2490+
if (!(allocateInstance && compiler.compileFunction(allocateInstance))) return module.createUnreachable();
24912491

2492-
compiler.currentType = cls.type;
2492+
compiler.currentType = classInstance.type;
24932493
return module.createCall(
2494-
instance.internalName, [
2494+
allocateInstance.internalName, [
24952495
options.isWasm64
2496-
? module.createI64(cls.currentMemoryOffset)
2497-
: module.createI32(cls.currentMemoryOffset)
2496+
? module.createI64(classInstance.currentMemoryOffset)
2497+
: module.createI32(classInstance.currentMemoryOffset)
24982498
],
24992499
options.nativeSizeType
25002500
);
25012501
}
25022502

2503+
const abortInternalName = "abort";
2504+
25032505
/** Compiles an abort wired to the conditionally imported 'abort' function. */
25042506
export function compileAbort(
25052507
compiler: Compiler,
@@ -2512,7 +2514,7 @@ export function compileAbort(
25122514
var stringType = program.typesLookup.get("string"); // might be intended
25132515
if (!stringType) return module.createUnreachable();
25142516

2515-
var abortPrototype = program.elementsLookup.get("abort"); // might be intended
2517+
var abortPrototype = program.elementsLookup.get(abortInternalName); // might be intended
25162518
if (!abortPrototype || abortPrototype.kind != ElementKind.FUNCTION_PROTOTYPE) return module.createUnreachable();
25172519

25182520
var abortInstance = (<FunctionPrototype>abortPrototype).resolve(); // reports

0 commit comments

Comments
 (0)