Skip to content

Commit

Permalink
esgen v0.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
surol committed Aug 12, 2023
1 parent 3ed5dc2 commit fd956e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"sideEffects": false,
"peerDependencies": {
"esgen": "^0.2.4"
"esgen": "^0.2.10"
},
"peerDependenciesMeta": {
"esgen": {
Expand All @@ -85,7 +85,7 @@
"@swc/jest": "^0.2.28",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"esgen": "^0.2.9",
"esgen": "^0.2.10",
"eslint": "^8.47.0",
"eslint-plugin-jest": "^27.2.3",
"expect": "^29.6.2",
Expand Down
22 changes: 7 additions & 15 deletions src/compiler/deserialization/list.ucrx.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
EsArg,
EsField,
EsFieldHandle,
EsMemberVisibility,
EsMethod,
EsMethodHandle,
EsProperty,
Expand Down Expand Up @@ -97,15 +96,13 @@ export class ListUcrxClass<
this.#isMatrix = isMatrix;
this.#single = single;

this.#items = new EsField('items', { visibility: EsMemberVisibility.Private }).declareIn(this, {
this.#items = new EsField('#items').declareIn(this, {
initializer: () => '[]',
});
this.#addItem = this.#declareAddItem();
this.#listCreated = new EsField('listCreated', {
visibility: EsMemberVisibility.Private,
}).declareIn(this, { initializer: () => '0' });
this.#listCreated = new EsField('#listCreated').declareIn(this, { initializer: () => '0' });
this.#isNull = this.#isNullableList
? new EsField('isNull', { visibility: EsMemberVisibility.Private }).declareIn(this, {
? new EsField('#isNull').declareIn(this, {
initializer: () => '0',
})
: undefined;
Expand All @@ -131,9 +128,8 @@ export class ListUcrxClass<
}

#declareAddItem(): EsMethodHandle<{ item: EsArg }> {
return new EsMethod('addItem', {
return new EsMethod('#addItem', {
args: { item: {} },
visibility: EsMemberVisibility.Private,
}).declareIn(this, {
body: ({
member: {
Expand All @@ -148,9 +144,7 @@ export class ListUcrxClass<
return [`this.set`];
}

const setList = new EsField('setList', { visibility: EsMemberVisibility.Private }).declareIn(
this,
);
const setList = new EsField('#setList').declareIn(this);

return [setList.get('this'), setList];
}
Expand All @@ -160,11 +154,9 @@ export class ListUcrxClass<
return;
}

const itemRxState = new EsField('_itemRx', {
visibility: EsMemberVisibility.Private,
}).declareIn(this);
const itemRxState = new EsField('#_itemRx').declareIn(this);

return new EsProperty('itemRx', { visibility: EsMemberVisibility.Private }).declareIn(this, {
return new EsProperty('#itemRx').declareIn(this, {
get: () => esline`return ${itemRxState.get('this')} ??= ${this.itemClass.instantiate({
set: esline`item => ${this.#addItem.call('this', { item: 'item' })}`,
})};`,
Expand Down
15 changes: 5 additions & 10 deletions src/compiler/deserialization/map.ucrx.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
EsCode,
EsField,
EsFieldHandle,
EsMemberVisibility,
EsMethod,
EsSnippet,
EsSymbol,
Expand Down Expand Up @@ -75,7 +74,7 @@ export class MapUcrxClass<
this.#extra = this.#declareExtra();
this.#collector = this.#declareCollector(variant);
this.#store = this.allocateStore();
this.#slot = new EsField('slot', { visibility: EsMemberVisibility.Private }).declareIn(this);
this.#slot = new EsField('#slot').declareIn(this);

this.#declareConstructor();
this.#declareFor();
Expand Down Expand Up @@ -141,7 +140,7 @@ export class MapUcrxClass<
case 'reject':
return { assigned: this.#declareAssigned(), counter, noDuplicates: true };
case 'collect':
return { rxs: this.#declareAssigned('rxs'), counter };
return { rxs: this.#declareAssigned('#rxs'), counter };
}
}

Expand All @@ -152,9 +151,7 @@ export class MapUcrxClass<
return;
}

const missingCount = new EsField('missingCount', {
visibility: EsMemberVisibility.Private,
}).declareIn(this, {
const missingCount = new EsField('#missingCount').declareIn(this, {
initializer: () => `${requiredCount}`,
});

Expand All @@ -176,10 +173,8 @@ export class MapUcrxClass<
return requiredCount;
}

#declareAssigned(name: 'assigned' | 'rxs' = 'assigned'): EsFieldHandle {
return new EsField(name, {
visibility: EsMemberVisibility.Private,
}).declareIn(this, {
#declareAssigned(name: '#assigned' | '#rxs' = '#assigned'): EsFieldHandle {
return new EsField(name).declareIn(this, {
initializer: () => '{}',
});
}
Expand Down
10 changes: 3 additions & 7 deletions src/compiler/deserialization/unknown.ucrx.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
EsArg,
EsField,
EsFieldHandle,
EsMemberVisibility,
EsMethod,
EsMethodHandle,
EsSignature,
Expand Down Expand Up @@ -60,10 +59,8 @@ export class UnknownUcrxClass extends UcrxClass {
args: UcrxSignature,
},
});
this.#listRx = new EsField('listRx', { visibility: EsMemberVisibility.Private }).declareIn(
this,
);
this.#mapRx = new EsField('mapRx', { visibility: EsMemberVisibility.Private }).declareIn(this);
this.#listRx = new EsField('#listRx').declareIn(this);
this.#mapRx = new EsField('#mapRx').declareIn(this);
this.#setMap = this.#declareSetMap();

this.#listClass = lazyValue(() => {
Expand Down Expand Up @@ -108,8 +105,7 @@ export class UnknownUcrxClass extends UcrxClass {
}

#declareSetMap(): EsMethodHandle<{ map: EsArg; cx: EsArg }> {
return new EsMethod('setMap', {
visibility: EsMemberVisibility.Private,
return new EsMethod('#setMap', {
args: { map: {}, cx: {} },
}).declareIn(this, {
body:
Expand Down

0 comments on commit fd956e3

Please sign in to comment.