From 2f5d37c2205081a1eca853915674126df3425b27 Mon Sep 17 00:00:00 2001 From: benStre Date: Tue, 7 Nov 2023 19:34:07 +0100 Subject: [PATCH] side branch#git --- runtime/pointers.ts | 18 +++++++++--------- runtime/runtime.ts | 2 +- types/scope.ts | 2 +- utils/interface-generator.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/pointers.ts b/runtime/pointers.ts index 55844c91..6028632c 100644 --- a/runtime/pointers.ts +++ b/runtime/pointers.ts @@ -478,7 +478,7 @@ export class PointerProperty extends Ref { private constructor(public pointer: Pointer, public key: any, leak_js_properties = false) { super(); this.#leak_js_properties = leak_js_properties; - pointer.is_persistant = true; // TODO: make unpersistant when pointer property deleted + pointer.is_persistent = true; // TODO: make unpersistant when pointer property deleted PointerProperty.synced_pairs.get(pointer)!.set(key, this); // save in map } @@ -1626,7 +1626,7 @@ export class Pointer extends Ref { get is_js_primitive(){return this.#is_js_primitive} // true if js primitive (number, boolean, ...) or 'single instance' class (Type, Endpoint) that cannot be directly addressed by reference get is_anonymous(){return this.#is_anonymous} get origin(){return this.#origin} - get is_persistant() { return this.#is_persistent;} + get is_persistent() { return this.#is_persistent;} get labels(){return this.#labels} get pointer_type(){return this.#pointer_type} @@ -1654,7 +1654,7 @@ export class Pointer extends Ref { } // change the persistant state of this pointer - set is_persistant(persistant:boolean) { + set is_persistent(persistant:boolean) { if (persistant && !this.#is_persistent) { super.val = this.current_val; this.#is_persistent = true; @@ -1717,7 +1717,7 @@ export class Pointer extends Ref { public addLabel(label: string|number){ if (Pointer.pointer_label_map.has(label)) throw new PointerError("Label " + Runtime.formatVariableName(label, '$') + " is already assigned to a pointer"); this.#labels.add(label); - this.is_persistant = true; // make pointer persistant + this.is_persistent = true; // make pointer persistant Pointer.pointer_label_map.set(label, this) // add to globalThis @@ -1894,7 +1894,7 @@ export class Pointer extends Ref { if (!this.value_initialized && (Object(v) !== v || v instanceof ArrayBuffer)) { Pointer.pointers.delete(this.id); // force remove previous non-primitive pointer (assume it has not yet been used) Pointer.primitive_pointers.delete(this.id) - return Pointer.create(this.id, v, this.sealed, this.origin, this.is_persistant, this.is_anonymous, false, this.allowed_access, this.datex_timeout) + return Pointer.create(this.id, v, this.sealed, this.origin, this.is_persistent, this.is_anonymous, false, this.allowed_access, this.datex_timeout) } //placeholder replacement if (Pointer.pointer_value_map.has(v)) { @@ -1918,7 +1918,7 @@ export class Pointer extends Ref { throw new PointerError("Cannot get value of uninitialized pointer") } // deref and check if not garbage collected - if (!this.is_persistant && !this.is_js_primitive && super.val instanceof WeakRef) { + if (!this.is_persistent && !this.is_js_primitive && super.val instanceof WeakRef) { const val = super.val.deref(); // seems to be garbage collected if (val === undefined && this.#loaded && !this.#is_js_primitive) { @@ -1946,7 +1946,7 @@ export class Pointer extends Ref { throw new PointerError("Cannot get value of uninitialized pointer") } // deref and check if not garbage collected - if (!this.is_persistant && !this.is_js_primitive && super.current_val instanceof WeakRef) { + if (!this.is_persistent && !this.is_js_primitive && super.current_val instanceof WeakRef) { const val = super.current_val.deref(); // seems to be garbage collected if (val === undefined && this.#loaded && !this.#is_js_primitive) { @@ -2336,7 +2336,7 @@ export class Pointer extends Ref { } - // enable / disable garbage collection based on subscribers & is_persistant + // enable / disable garbage collection based on subscribers & is_persistent updateGarbageCollection(){ // primitive value cannot be garbage collected @@ -2345,7 +2345,7 @@ export class Pointer extends Ref { } // remove WeakRef (keep value) if persistant, or has subscribers - else if (this.is_persistant || this.subscribers?.size != 0 || this.is_js_primitive) { + else if (this.is_persistent || this.subscribers?.size != 0 || this.is_js_primitive) { //logger.warn("blocking " + this + " from beeing garbage collected") this.#garbage_collectable = false; if (super.val instanceof WeakRef) super.setVal(super.val.deref(), false); diff --git a/runtime/runtime.ts b/runtime/runtime.ts index 8228eda2..4f5a0d3a 100644 --- a/runtime/runtime.ts +++ b/runtime/runtime.ts @@ -6518,7 +6518,7 @@ export class Runtime { const only_load_local = true; //pointer.is_origin || SCOPE.sender?.equals(pointer.origin); pointer = await Pointer.load(id, SCOPE, only_load_local, knows_pointer?true:false); // console.log("has $" + Pointer.normalizePointerId(id), jmp_index, buffer2hex(SCOPE.buffer_views.uint8.slice(jmp_index), " ")); - // pointer.is_persistant = true; + // pointer.is_persistent = true; SCOPE.current_index += init_block_size; // jump to end of init block } // does not exist - init diff --git a/types/scope.ts b/types/scope.ts index c74f8c6a..466d900e 100644 --- a/types/scope.ts +++ b/types/scope.ts @@ -27,7 +27,7 @@ export class Scope { // make internal vars persistent even if currently not loaded in JS (TODO: how to handle this case in the future?) for (const internal_var of this.internal_vars) { if (internal_var instanceof Pointer) { - internal_var.is_persistant = true; + internal_var.is_persistent = true; } } diff --git a/utils/interface-generator.ts b/utils/interface-generator.ts index 19a7f3aa..2bed3fea 100644 --- a/utils/interface-generator.ts +++ b/utils/interface-generator.ts @@ -187,7 +187,7 @@ function getValueTSCode(module_name:string, name:string, value: any, no_pointer // disable garbage collection const ptr = Datex.Pointer.getByValue(value); - if (ptr) ptr.is_persistant = true; + if (ptr) ptr.is_persistent = true; const loader = value?.[DX_SOURCE] ? `await datex.get('${value[DX_SOURCE]}')` : `await datex('${Datex.Runtime.valueToDatexStringExperimental(value)}')` code += `${name =='default' ? 'export default' : 'export const ' + name + ' ='} ${loader}${types ? ` as ${getValueTSType(value)}` : ''};\n`;