Proper treatment of annotations through dataspaces
This commit is contained in:
parent
4b5eccad24
commit
6d904d276e
|
@ -1,7 +1,7 @@
|
||||||
/// SPDX-License-Identifier: GPL-3.0-or-later
|
/// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/// SPDX-FileCopyrightText: Copyright © 2016-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
/// SPDX-FileCopyrightText: Copyright © 2016-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
|
|
||||||
import { IdentityMap, KeyedDictionary, stringify } from '@preserves/core';
|
import { IdentityMap, KeyedDictionary, stringify, strip } from '@preserves/core';
|
||||||
import { Index, IndexObserver } from './skeleton.js';
|
import { Index, IndexObserver } from './skeleton.js';
|
||||||
import { Actor, AnyValue, Assertion, DetailedAction, Entity, Facet, Handle, LocalAction, Ref, Turn } from './actor.js';
|
import { Actor, AnyValue, Assertion, DetailedAction, Entity, Facet, Handle, LocalAction, Ref, Turn } from './actor.js';
|
||||||
import { Observe, toObserve } from '../gen/dataspace.js';
|
import { Observe, toObserve } from '../gen/dataspace.js';
|
||||||
|
@ -90,7 +90,7 @@ export class Dataspace implements Partial<Entity> {
|
||||||
const is_new = this.index.addAssertion(v, Turn.active);
|
const is_new = this.index.addAssertion(v, Turn.active);
|
||||||
this.options.tracer?.('+', v, this, is_new);
|
this.options.tracer?.('+', v, this, is_new);
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
const o = toObserve(v);
|
const o = toObserve(strip(v));
|
||||||
if (o !== void 0) {
|
if (o !== void 0) {
|
||||||
const target = o.observer;
|
const target = o.observer;
|
||||||
const observer = new DataspaceObserver(target);
|
const observer = new DataspaceObserver(target);
|
||||||
|
@ -109,7 +109,7 @@ export class Dataspace implements Partial<Entity> {
|
||||||
const is_last = this.index.removeAssertion(v, Turn.active);
|
const is_last = this.index.removeAssertion(v, Turn.active);
|
||||||
this.options.tracer?.('-', v, this, is_last);
|
this.options.tracer?.('-', v, this, is_last);
|
||||||
if (is_last) {
|
if (is_last) {
|
||||||
const o = toObserve(v);
|
const o = toObserve(strip(v));
|
||||||
if (o !== void 0) {
|
if (o !== void 0) {
|
||||||
const io = this.observerMap.get(o.observer);
|
const io = this.observerMap.get(o.observer);
|
||||||
if (io !== void 0) {
|
if (io !== void 0) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// SPDX-License-Identifier: GPL-3.0-or-later
|
/// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/// SPDX-FileCopyrightText: Copyright © 2016-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
/// SPDX-FileCopyrightText: Copyright © 2016-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
|
|
||||||
import { canonicalString, KeyedDictionary, is, Record, RecordConstructorInfo, Value, _iterMap, DictionaryMap, Dictionary, EncodableDictionary } from '@preserves/core';
|
import { canonicalString, KeyedDictionary, is, Record, RecordConstructorInfo, Value, _iterMap, DictionaryMap, Dictionary, EncodableDictionary, unannotate } from '@preserves/core';
|
||||||
import { AnyValue, Ref } from './actor.js';
|
import { AnyValue, Ref } from './actor.js';
|
||||||
import * as P from '../gen/dataspacePatterns.js';
|
import * as P from '../gen/dataspacePatterns.js';
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ export type Path = Array<AnyValue>;
|
||||||
export type Shape = string;
|
export type Shape = string;
|
||||||
|
|
||||||
export function classOfValue(v: any): Shape | null {
|
export function classOfValue(v: any): Shape | null {
|
||||||
|
v = unannotate(v);
|
||||||
if (Record.isRecord(v)) {
|
if (Record.isRecord(v)) {
|
||||||
return constructorInfoSignature(Record.constructorInfo(v));
|
return constructorInfoSignature(Record.constructorInfo(v));
|
||||||
} else if (Array.isArray(v)) {
|
} else if (Array.isArray(v)) {
|
||||||
|
@ -38,6 +39,7 @@ export function constructorInfoSignature(ci: RecordConstructorInfo<Value>): stri
|
||||||
}
|
}
|
||||||
|
|
||||||
export function step(v: AnyValue, index: AnyValue): AnyValue | undefined {
|
export function step(v: AnyValue, index: AnyValue): AnyValue | undefined {
|
||||||
|
v = unannotate(v);
|
||||||
const vMap = Dictionary.asMap<Ref>(v);
|
const vMap = Dictionary.asMap<Ref>(v);
|
||||||
if (vMap) {
|
if (vMap) {
|
||||||
return vMap.get(index);
|
return vMap.get(index);
|
||||||
|
|
Loading…
Reference in New Issue