|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
-
- var utils = require("../bbhverse-pb-wip/utils")
- var js = utils.js;
-
- function asyncDynamicTaskStream(opts){
-
- const design = {
- create(){
- var conceptspace = 0;
- var next = 1;
- var all = 0;
- var segments = [];
- var __concepts = {};
- var __entagledRefs = new WeakMap();
-
- function assert(concept, multi){ return __concepts[concept].spin ? !(concept.id & multi) : (concept.id & multi) }
-
- function define_exclusions(exclusions, tangle){
-
- if(exclusions.length < 2) throw 'Why would we call define_exclusions on a single or no item ? At the least 2 items are needed for mutual exclusion.'
- var results = [];
-
- var entanglement = { unsync : 0 };
- var entaglements = [];
- var maskForSet = 0;
- __entagledRefs.set(entanglement, entaglements);
- var __entangledFn = (exclusion)=>{
- entanglement.unsync |= exclusion.entanglement.unsync | exclusion.id ;
- var collapsibles = __entagledRefs.get(exclusion.entanglement);
- if(collapsibles) { collapsibles.forEach(collapsible => { collapsible.entanglement = entanglement; }) }
- __entagledRefs.delete(exclusion.entanglement);
- exclusion.entanglement = entanglement;
- entaglements.push(exclusion);
- }
- var entangledFn = (exclusion)=>{
- exclusion.entanglement.unsync |= entanglement.unsync | exclusion.id ;
- var collapsibles = __entagledRefs.get(entanglement);
- if(collapsibles){ collapsibles.forEach(collapsible => { collapsible.entanglement = exclusion.entanglement; }) }
- __entagledRefs.delete(entanglement);
- entanglement = exclusion.entanglement;
- entaglements = __entagledRefs.get(entanglement);
- entangledFn = __entangledFn;
- }
- var __tangle = Object.assign({}, tangle);
-
-
- for(var i = 0; i < exclusions.length; i++) {
- var innerexclusions = __concepts[exclusions[i]] ? __concepts[exclusions[i]] : define(exclusions[i], __tangle);
- __tangle.unsync |= innerexclusions.results[0].id
- innerexclusions.results.forEach(exclusion=>{
- (exclusion.entanglement) ? entangledFn(exclusion)
- : (()=>{
- entanglement.unsync |= exclusion.id;
- exclusion.entanglement = entanglement;
- entaglements.push(exclusion)
- })()
- results.push(exclusion)
- maskForSet |= exclusion.id;
- });
- }
- return { results : results, maskForSet : maskForSet} ;
- }
- function define_string(concept, tangle) {
- all |= next;
- __concepts[concept] = { id : next, entanglement : Object.assign({}, tangle) };
- __entagledRefs.set(__concepts[concept].entanglement, [__concepts[concept]] )
- next = next << 1;
- return { results : [__concepts[concept]], maskForSet : __concepts[concept].id };
- }
- function define_array(concepts, tangle) {
- if(concepts.length > 1) return define_exclusions(concepts, tangle);
- else return define(concepts[0], tangle)
- }
- function define_object(concepts, tangle){
- var results = [];
- var maskForSet = 0;
- tangle = tangle || {};
- Object.keys(concepts).forEach(concept => {
- var __concept = define(concept, tangle);
- results.push.apply(results, __concept.results)
- var __tangle = Object.assign({}, __concept.results[0].entanglement);
- __tangle.insync |= __concept.results[0].id | tangle.insync;
- __tangle.unsync |= tangle.unsync;
- var isconcept = define( concepts[concept][0], __tangle )
-
- __tangle = Object.assign({}, __concept.results[0].entanglement);
- __tangle.unsync |= tangle.unsync | __concept.results[0].id;
-
- var notconcept = define( concepts[concept][1], __tangle )
- if(notconcept && notconcept.results) {
- __concept.results[0].entanglement.unsync |= notconcept.maskForSet;
- maskForSet |= __concept.maskForSet | notconcept.maskForSet ;
- }
- if(isconcept && isconcept.results) {
- __concept.results[0].entanglement.insync |= isconcept.maskForSet;
- maskForSet |= __concept.maskForSet | isconcept.maskForSet ;
- }
- });
- results[0].entanglement.insync = maskForSet;
- return { results : results, maskForSet : maskForSet };
- }
-
- const conceptvariants = Object.assign(utils.__TPL__typeHandlers, {
- '[object String]' : define_string
- , '[object Array]' : define_array
- , '[object Object]' : define_object
- , '[object Undefined]' : ()=>{}
- })
- function define(concept, tangle){
- return conceptvariants[Object.prototype.toString.call(concept)](concept, tangle);
- }
- function reveal(){ console.dir(__concepts) }
-
- return { define, reveal }
- }
- }
-
- const coexstates = {
- create(){
- var conceptspace = 0;
- var next = 1;
- var all = 0;
- var segments = [];
- var __concepts = {};
- var __entagledRefs = new WeakMap();
- var __tango = {
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
- var t = { 0b00100000 : [
-
- [
-
- 0b00100110
-
-
- , [ 0b00101001 ]
-
-
-
-
-
-
-
- , 0b00110000
-
- ]
-
-
- ,
- [
- 0
-
-
- , [0]
-
-
-
- , 0b11000000
- ]
- ]
- }
- (()=>{
- var cannotCoexist = 0;
- for(var i = 1; i < t[0b00100000][0].length; i++) { cannotCoexist |= t[0b00100000][0][i] }
- t[0b00100000][1][0] |= cannotCoexist;
- })()
- (()=>{
- var cannotCoexist = 0;
- for(var i = 1; i < t[0b00100000][1].length; i++) { cannotCoexist |= t[0b00100000][1][i] }
- t[0b00100000][0][0] |= cannotCoexist;
- })()
- t[0b00100000][1][1] |= t[0b00100000][0][0]
-
- function define_exclusions(exclusions, tangle){
-
- if(exclusions.length < 2) throw 'Why would we call define_exclusions on a single or no item ? At the least 2 items are needed for mutual exclusion.'
- var results = [];
-
- var entanglement = { unsync : 0 };
- var entaglements = [];
- var maskForSet = 0;
- __entagledRefs.set(entanglement, entaglements);
- var __entangledFn = (exclusion)=>{
- entanglement.unsync |= exclusion.entanglement.unsync | exclusion.id ;
- var collapsibles = __entagledRefs.get(exclusion.entanglement);
- if(collapsibles) { collapsibles.forEach(collapsible => { collapsible.entanglement = entanglement; }) }
- __entagledRefs.delete(exclusion.entanglement);
- exclusion.entanglement = entanglement;
- entaglements.push(exclusion);
- }
- var entangledFn = (exclusion)=>{
- exclusion.entanglement.unsync |= entanglement.unsync | exclusion.id ;
- var collapsibles = __entagledRefs.get(entanglement);
- if(collapsibles){ collapsibles.forEach(collapsible => { collapsible.entanglement = exclusion.entanglement; }) }
- __entagledRefs.delete(entanglement);
- entanglement = exclusion.entanglement;
- entaglements = __entagledRefs.get(entanglement);
- entangledFn = __entangledFn;
- }
- var __tangle = Object.assign({}, tangle);
-
-
- for(var i = 0; i < exclusions.length; i++) {
- var innerexclusions = __concepts[exclusions[i]] ? __concepts[exclusions[i]] : define(exclusions[i], __tangle);
- __tangle.unsync |= innerexclusions.results[0].id
- innerexclusions.results.forEach(exclusion=>{
- (exclusion.entanglement) ? entangledFn(exclusion)
- : (()=>{
- entanglement.unsync |= exclusion.id;
- exclusion.entanglement = entanglement;
- entaglements.push(exclusion)
- })()
- results.push(exclusion)
- maskForSet |= exclusion.id;
- });
- }
- return { results : results, maskForSet : maskForSet} ;
- }
- function define_string(concept, containing) {
- all |= next;
- __concepts[concept] = { id : next, ex : 0, in : 0, entanglement : Object.assign({}, tangle) };
- next = next << 1;
- return { results : [__concepts[concept]], maskForSet : __concepts[concept].id };
- }
- function define_array(concepts, tangle) {
- if(concepts.length > 1) return define_exclusions(concepts, tangle);
- else return define(concepts[0], tangle)
- }
- function define_object(concepts, tangle){
- var results = [];
- var maskForSet = 0;
- tangle = tangle || {};
- Object.keys(concepts).forEach(concept => {
- var __concept = define(concept, tangle);
- results.push.apply(results, __concept.results)
- var __tangle = Object.assign({}, __concept.results[0].entanglement);
- __tangle.insync |= __concept.results[0].id | tangle.insync;
- __tangle.unsync |= tangle.unsync;
- var isconcept = define( concepts[concept][0], __tangle )
-
- __tangle = Object.assign({}, __concept.results[0].entanglement);
- __tangle.unsync |= tangle.unsync | __concept.results[0].id;
-
- var notconcept = define( concepts[concept][1], __tangle )
- if(notconcept && notconcept.results) {
- __concept.results[0].entanglement.unsync |= notconcept.maskForSet;
- maskForSet |= __concept.maskForSet | notconcept.maskForSet ;
- }
- if(isconcept && isconcept.results) {
- __concept.results[0].entanglement.insync |= isconcept.maskForSet;
- maskForSet |= __concept.maskForSet | isconcept.maskForSet ;
- }
- });
- results[0].entanglement.insync = maskForSet;
- return { results : results, maskForSet : maskForSet };
- }
-
- const conceptvariants = Object.assign(utils.__TPL__typeHandlers, {
- '[object String]' : define_string
- , '[object Array]' : define_array
- , '[object Object]' : define_object
- , '[object Undefined]' : ()=>{}
- })
- function define(concept, tangle){
- return conceptvariants[Object.prototype.toString.call(concept)](concept, tangle);
- }
- function reveal(){ console.dir(__concepts) }
-
- return { define, reveal }
- }
- }
-
-
- var states = {
- 'running' : [
- [ ]
- , [ {
- 'unstarted' : [[ ]
- , [
- 'paused'
-
-
-
- , { 'stopped' : [[
- 'succeded'
- , 'failed'
- , 'aborted'
-
- ], [] ]}
- ]
- ]} ]
- ]
-
- }
-
- var stateFactory = design.create();
- var x = stateFactory.define(states);
- stateFactory.reveal();
-
-
- }
-
-
- module.exports = asyncDynamicTaskStream;
- asyncDynamicTaskStream();
|