Skip to content

Commit

Permalink
$mol_view_tree2 unique class property and check defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Nov 4, 2023
1 parent fb84d48 commit c4e5312
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 13 additions & 5 deletions view/tree2/class/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ namespace $ {
})
)

const props_inner = [] as $mol_tree2[]
const props_inner = {} as Record<string, $mol_tree2>

const add_inner = ( prop: $mol_tree2 ) => {
const prev = props_inner[prop.type]
if (prev && prev.kids[0]?.type !== prop.kids[0]?.type) {
this.$mol_fail(err`Different kids ${prev.span} vs ${prop.span}`)
}
props_inner[prop.type] = prop
}

const props_root = props.hack({

Expand All @@ -27,7 +35,7 @@ namespace $ {
const prop = this.$mol_view_tree2_child( operator )

const defs = prop.hack( belt )
if( defs.length ) props_inner.push( prop.clone( defs ) )
if( defs.length ) add_inner( prop.clone( defs ) )

return [ operator.clone([ prop.clone([]) ]) ]
},
Expand All @@ -37,7 +45,7 @@ namespace $ {
const prop = this.$mol_view_tree2_child( operator )

const defs = prop.hack( belt )
if( defs.length ) props_inner.push( prop.clone( defs ) )
if( defs.length ) add_inner( prop.clone( defs ) )

return [ operator.clone([ prop.clone([]) ]) ]
},
Expand All @@ -46,14 +54,14 @@ namespace $ {
if (operator.kids.length === 0) return [ operator ]
const prop = this.$mol_view_tree2_child( operator )
const defs = prop.hack( belt )
if( defs.length ) props_inner.push( prop.clone( defs ) )
if( defs.length ) add_inner( prop.clone( defs ) )

return [ operator.clone([ prop.clone([]) ]) ]
}

})

return [ ... props_root , ... props_inner ]
return [ ... props_root , ... Object.values(props_inner) ]
}

}
3 changes: 0 additions & 3 deletions view/tree2/to/dts/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace $ {

for( const klass of descr.kids ) {

const methods = new Set<string>()
const parent = klass.kids[0]
const props = this.$mol_view_tree2_class_props(klass)
const aliases = [] as $mol_tree2[]
Expand All @@ -48,9 +47,7 @@ namespace $ {
... props.map( prop => {

const name = name_of.call(this, prop)
if (methods.has(name)) return undefined

methods.add(name)
const bind_res = ( bind: $mol_tree2 )=> [
bind.data( 'ReturnType< ' ),
klass.data( klass.type ),
Expand Down
9 changes: 2 additions & 7 deletions view/tree2/to/js/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ namespace $ {
klass: $mol_tree2
addons: $mol_tree2[]
members: $mol_tree2[]
methods: Map<string, $mol_tree2>
},
prop: $mol_tree2
) {
const { klass, members, addons, methods } = acc
const { klass, members, addons } = acc
const { name, key, next } = this.$mol_view_tree2_prop_parts(prop)

if (methods.has(name)) return acc

methods.set(name, prop)

const decorate = ()=> {
return prop.struct( '()', [
prop.struct( key ? '$mol_mem_key' : '$mol_mem' ),
Expand Down Expand Up @@ -288,7 +283,7 @@ namespace $ {
const props = this.$mol_view_tree2_class_props( klass )
const addons = [] as $mol_tree2[]
const members = [] as $mol_tree2[]
const acc = { klass, addons, members, methods: new Map<string, $mol_tree2>() }
const acc = { klass, addons, members }

for( const prop of props ) {
try {
Expand Down

0 comments on commit c4e5312

Please sign in to comment.