mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 04:01:46 +00:00
integrate
This commit is contained in:
@ -474,6 +474,9 @@ export namespace BuiltinSymbols {
|
||||
export const memory_fill = "~lib/memory/memory.fill";
|
||||
// std/gc.ts
|
||||
export const iterateRoots = "~lib/gc/iterateRoots";
|
||||
// internals
|
||||
export const rt_classid = "~lib/builtins/__rt_classid";
|
||||
export const rt_iterateroots = "~lib/builtins/__rt_iterateroots";
|
||||
}
|
||||
|
||||
/** Compiles a call to a built-in function. */
|
||||
@ -3591,9 +3594,17 @@ export function compileCall(
|
||||
return module.createUnary(op, arg0);
|
||||
}
|
||||
|
||||
// === GC integration =========================================================================
|
||||
// === Internal runtime =======================================================================
|
||||
|
||||
case BuiltinSymbols.iterateRoots: {
|
||||
case BuiltinSymbols.rt_classid: {
|
||||
let type = evaluateConstantType(compiler, typeArguments, operands, reportNode);
|
||||
compiler.currentType = Type.u32;
|
||||
if (!type) return module.createUnreachable();
|
||||
let classReference = type.classReference;
|
||||
if (!classReference) return module.createUnreachable();
|
||||
return module.createI32(classReference.prototype.classId);
|
||||
}
|
||||
case BuiltinSymbols.rt_iterateroots: {
|
||||
if (
|
||||
checkTypeAbsent(typeArguments, reportNode, prototype) |
|
||||
checkArgsRequired(operands, 1, reportNode, compiler)
|
||||
|
@ -344,6 +344,9 @@ export class Program extends DiagnosticEmitter {
|
||||
/** Memory allocation function. */
|
||||
memoryAllocateInstance: Function | null = null;
|
||||
|
||||
/** Next class id. */
|
||||
nextClassId: u32 = 1;
|
||||
|
||||
// gc integration
|
||||
|
||||
/** Whether a garbage collector is present or not. */
|
||||
@ -2355,7 +2358,7 @@ export class FunctionPrototype extends DeclaredElement {
|
||||
|
||||
/** Constructs a new function prototype. */
|
||||
constructor(
|
||||
/** Simple na,e */
|
||||
/** Simple name */
|
||||
name: string,
|
||||
/** Parent element, usually a file, namespace or class (if a method). */
|
||||
parent: Element,
|
||||
@ -2792,6 +2795,8 @@ export class ClassPrototype extends DeclaredElement {
|
||||
overloadPrototypes: Map<OperatorKind, FunctionPrototype> = new Map();
|
||||
/** Already resolved instances. */
|
||||
instances: Map<string,Class> | null = null;
|
||||
/** Unique class id. */
|
||||
classId: u32 = 0;
|
||||
|
||||
constructor(
|
||||
/** Simple name. */
|
||||
@ -2813,6 +2818,8 @@ export class ClassPrototype extends DeclaredElement {
|
||||
declaration
|
||||
);
|
||||
this.decoratorFlags = decoratorFlags;
|
||||
this.classId = u32(this.program.nextClassId++);
|
||||
assert(this.classId); // must not wrap around to 0
|
||||
}
|
||||
|
||||
/** Gets the associated type parameter nodes. */
|
||||
|
Reference in New Issue
Block a user