Skip to content

Commit

Permalink
$mol_view_tre2_to_dts fix idempotency, this? fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Nov 14, 2024
1 parent 733b4ed commit 43b7c87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions view/tree2/to/dts/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ namespace $ {
]
}

function type_enforce(this: $, name: $mol_tree2, a: readonly $mol_tree2[], b: readonly $mol_tree2[]) {
function type_enforce(this: $, name: $mol_tree2, type_suffix: number, a: readonly $mol_tree2[], b: readonly $mol_tree2[]) {
return name.struct('line', [
name.data(`type ${ name.value.replace(/<.*>/g, '') }__${ this.$mol_guid() } = $mol_type_enforce<` ),
name.data(`type ${ name.value.replace(/<.*>/g, '') }__${ type_suffix } = $mol_type_enforce<` ),
name.struct( 'indent', [
a[0].struct('line', a),
a[0].data(','),
Expand All @@ -102,6 +102,7 @@ namespace $ {
const descr = $mol_view_tree2_classes( tree )

const types = [] as $mol_tree2[]
let assert_count = 0

for( const klass of descr.kids ) {

Expand Down Expand Up @@ -177,6 +178,7 @@ namespace $ {
types.push( type_enforce.call(
this,
method,
++assert_count,
parameters.call(this, main, prop, 0),
parameters.call(this, second_main, second_key, 0),
) )
Expand All @@ -186,6 +188,7 @@ namespace $ {
types.push( type_enforce.call(
this,
method,
++assert_count,
parameters.call(this, main, prop, prop_parts.key ? 1 : 0),
parameters.call(this, second_main, second_key, (left_parts.next ? left_parts : right_parts).key ? 1 : 0),
) )
Expand Down Expand Up @@ -280,6 +283,7 @@ namespace $ {
type_enforce.call(
this,
input.data(`${ klass.type }_${prop.type.replace(/[\?\*]*/g, '')}`),
++assert_count,
result,
array_type
)
Expand All @@ -304,6 +308,7 @@ namespace $ {
type_enforce.call(
this,
first.data(input.type),
++assert_count,
[
first.data('[ '),
...args,
Expand All @@ -328,6 +333,7 @@ namespace $ {
type_enforce.call(
this,
over.data(`${ input.type }__${ name.value }`),
++assert_count,
over.hack( belt ),
return_type.call(
this,
Expand Down
12 changes: 6 additions & 6 deletions view/tree2/to/js/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace $ {

}

function call_method_name(this: $, child: $mol_tree2) {
return child.struct( '?.[]', [
function call_method_name(this: $, child: $mol_tree2, optional: boolean) {
return child.struct( optional ? '?.[]' : '[]', [
child.data( name_of.call( this, child ) )
] )
}
Expand All @@ -51,7 +51,7 @@ namespace $ {

for (const child of bind.kids) {
chain.push(
call_method_name.call(this, child),
call_method_name.call(this, child, chain.length > 1),
args_of.call(this, child, bidi),
)
}
Expand Down Expand Up @@ -133,11 +133,11 @@ namespace $ {

'=': bind => [ bind.struct( '()', [
bind.struct( 'this' ),
... bind.hack({ '': ( method, belt )=> [
call_method_name.call( this, method ),
... bind.hack({ '': ( method, belt, ctx )=> [
call_method_name.call( this, method, (ctx.item_index++) > 0 ),
args_of.call( this, method ),
... method.hack( belt ),
] }),
] }, { item_index: 0 }),
] ) ],

'': ( input, belt, context )=> {
Expand Down

0 comments on commit 43b7c87

Please sign in to comment.