import BitArray from '../../common/BitArray' ; import Token from './Token' ; import Integer from '../../util/Integer' ; import { short , int } from '../../../customTypings' ; export default class SimpleToken extends Token { private value : short ; private bitCount : short ; constructor ( previous , value , bitCount ) { super ( previous ) ; this . value = < short > value ; this . bitCount = < short > bitCount ; } Override appendTo ( bitArray , text ) { bitArray . appendBits ( this . value , this . bitCount ) ; } public add ( value , bitCount ) { return new SimpleToken ( this , value , bitCount ) ; } public addBinaryShift ( start , byteCount ) { console . warn ( 'addBinaryShift on SimpleToken, this simply returns a copy of this token' ) ; return new SimpleToken ( this , start , byteCount ) ; } Override public toString ( ) { let value = this . value & ( ( 1 << this . bitCount ) - 1 ) ; value |= 1 << this . bitCount ; return '<' + Integer . toBinaryString ( value | ( 1 << this . bitCount ) ) . substring ( 1 ) + '>' ; } }