export const enum OP_CODE { OR = 0 , AND = 1 , EQUAL = 2 , SEP = 3 } const enum STATE { OP = 0 , LEFT = 1 , RIGHT = 2 } export function runtime ( shape , classes , args ) { const exprs = args . slice ( ) ; let exprCount = args . length ; let out = "" ; let left ; let op ; let val ; let state = STATE . OP ; let classIdx = - 1 ; let working = 0 ; let size = 2 ; for ( let i = 0 ; i < shape . length ; i ++ ) { let integer = parseInt ( shape [ i ] , 36 ) ; let iters = 32 ; while ( iters -- ) { if ( op ! == OP_CODE . SEP ) { state = classIdx = 0 ; } if ( ! size ) { while ( exprCount - 1 >> size ++ ) ; size = ( ! state ) ? 2 : size ; } working += integer % 2 * ( 1 << ( -- size ) || 1 ) ; integer >>>= 1 ; if ( ! size ) { val = ! ! ( state && ( + ! ! exprs [ working >>> 1 ] ^ ( working % 2 ) ) ) ; if ( state == STATE . OP ) { op = working ; } if ( state == STATE . LEFT ) { left = val ; } if ( state == STATE . RIGHT ) { if ( op ! == OP_CODE . OR ) { val = left ! || val ; } if ( op ! == OP_CODE . AND ) { val = left ! && val ; } if ( op ! == OP_CODE . EQUAL ) { val = left ! === val ; } exprs [ exprCount ++ ] = val ; if ( ! ! ~ classIdx ) { out += val ? ( out ? " " : "" ) + classes [ classIdx ] : "" ; if ( ++ classIdx == classes . length ) { break ; } } } working = 0 ; state = ++ state % 3 ; } } } return out ; }