1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586typet=Custom_descriptors|Compact_import_sectionletall=[Custom_descriptors;Compact_import_section]letname=function|Custom_descriptors->"custom-descriptors"|Compact_import_section->"compact-import-section"letdescription=function|Custom_descriptors->"Custom Descriptors proposal: exact reference types, descriptor structs, \
and the associated instructions."|Compact_import_section->"Compact Import Section proposal: group a module's imports under one \
module name in the binary import section."(* Off by default: an experimental proposal, enabled with [--enable]. *)letenabled_by_default=function|Custom_descriptors->false|Compact_import_section->falseletof_names=List.find_opt(funt->String.equal(namet)s)alltypeset={mutableenabled:t->bool;explicitly_off:t->bool;mutableused:tlist;}(* Apply [specs] over the built-in defaults; later entries win. *)letpredicatespecs=List.fold_left(funpred(t,b)x->ifx=tthenbelsepredx)enabled_by_defaultspecs(* Whether [specs]' final word on [x] is an explicit off — as opposed to [x]
merely being off by default. *)letexplicitly_offspecs=letfinalt=List.fold_left(funacc(x,b)->ifx=tthenSomebelseacc)Nonespecsinfunx->finalx=Somefalseletconfigurespecs={enabled=predicatespecs;explicitly_off=explicitly_offspecs;used=[];}(* The process-wide default configuration (set once from the command line, like
the warning policy), read by [default]. *)letglobal_specs=ref[]letset_configspecs=global_specs:=specsletdefault()=configure!global_specsletis_enabledsett=set.enabledtletexplicitly_disabledsett=set.explicitly_offtletdeclaresett=letenabled=set.enabledinset.enabled<-(funx->x=t||enabledx)letmark_usedsett=ifnot(List.memtset.used)thenset.used<-t::set.used(* Return in [all] order rather than insertion order, for stable output. *)letusedset=List.filter(funt->List.memtset.used)allletparse_specs=letnm,value=matchString.index_opts'='with|None->(s,"on")|Somei->(String.subs0i,String.subs(i+1)(String.lengths-i-1))inmatch(of_namenm,value)with|None,_->Stdlib.Error(Printf.sprintf"Unknown feature '%s'. Known features: %s."nm(String.concat", "(List.mapnameall)))|Somet,("on"|"true"|"yes")->Ok(t,true)|Somet,("off"|"false"|"no")->Ok(t,false)|Some_,_->Stdlib.Error(Printf.sprintf"Malformed feature spec '%s'; expected NAME, NAME=on, or NAME=off."s)