diff --git a/parse.inc.js b/parse.inc.js index 4b818f7b..eef9af5d 100644 --- a/parse.inc.js +++ b/parse.inc.js @@ -294,8 +294,6 @@ function generate (packet) { `) } - // TODO Vivify through a funciton so that `object = vivify()`. - // TOOO Write directly to object, I think, get rid of `$_`? const object = `parsers.inc.${packet.name}` return $(` ${object} = function (${signature.join(', ')}) { diff --git a/serialize.inc.js b/serialize.inc.js index 24da3ae3..1d3ebf80 100644 --- a/serialize.inc.js +++ b/serialize.inc.js @@ -64,9 +64,7 @@ function generate (packet) { // TODO I don't need to push and pop $i. function lengthEncoded (path, packet) { variables.i = true - variables.I = true const i = `$i[${$i}]` - const I = `$I[${$i}]` const again = $step const source = $(` `, dispatch(`${path}[${i}]`, packet.element), ` @@ -75,8 +73,6 @@ function generate (packet) { $step = ${again} continue } - - $i.pop() `) $i-- return source @@ -86,7 +82,7 @@ function generate (packet) { $i++ return $(` `, integer(path + '.length', packet), ` - $i.push(0) + $i[${$i}] = 0 `) } @@ -225,8 +221,7 @@ function generate (packet) { const signatories = { packet: `${packet.name}`, step: '$step = 0', - i: '$i = []', - I: '$I = []' + i: '$i = []' } const signature = Object.keys(signatories) .filter(key => variables[key]) diff --git a/test/generated/length-encoded-fixed.serializer.inc.js b/test/generated/length-encoded-fixed.serializer.inc.js index c3dcd30d..f6804d1d 100644 --- a/test/generated/length-encoded-fixed.serializer.inc.js +++ b/test/generated/length-encoded-fixed.serializer.inc.js @@ -1,5 +1,5 @@ module.exports = function (serializers) { - serializers.inc.object = function (object, $step = 0, $i = [], $I = []) { + serializers.inc.object = function (object, $step = 0, $i = []) { let $bite, $stop, $_ return function serialize ($buffer, $start, $end) { @@ -21,7 +21,7 @@ module.exports = function (serializers) { $bite-- } - $i.push(0) + $i[0] = 0 case 2: @@ -62,8 +62,6 @@ module.exports = function (serializers) { continue } - $i.pop() - $step = 6 case 6: diff --git a/test/generated/length-encoded-variable.serializer.inc.js b/test/generated/length-encoded-variable.serializer.inc.js index b1fd6f99..d9bd2633 100644 --- a/test/generated/length-encoded-variable.serializer.inc.js +++ b/test/generated/length-encoded-variable.serializer.inc.js @@ -1,5 +1,5 @@ module.exports = function (serializers) { - serializers.inc.object = function (object, $step = 0, $i = [], $I = []) { + serializers.inc.object = function (object, $step = 0, $i = []) { let $bite, $stop, $_ return function serialize ($buffer, $start, $end) { @@ -21,7 +21,7 @@ module.exports = function (serializers) { $bite-- } - $i.push(0) + $i[0] = 0 case 2: @@ -39,7 +39,7 @@ module.exports = function (serializers) { $bite-- } - $i.push(0) + $i[1] = 0 case 4: @@ -63,15 +63,11 @@ module.exports = function (serializers) { continue } - $i.pop() - if (++$i[0] != object.array.length) { $step = 2 continue } - $i.pop() - $step = 6 case 6: diff --git a/test/generated/length-encoded-words.serializer.inc.js b/test/generated/length-encoded-words.serializer.inc.js index 3f3046a2..f75433be 100644 --- a/test/generated/length-encoded-words.serializer.inc.js +++ b/test/generated/length-encoded-words.serializer.inc.js @@ -1,5 +1,5 @@ module.exports = function (serializers) { - serializers.inc.object = function (object, $step = 0, $i = [], $I = []) { + serializers.inc.object = function (object, $step = 0, $i = []) { let $bite, $stop, $_ return function serialize ($buffer, $start, $end) { @@ -21,7 +21,7 @@ module.exports = function (serializers) { $bite-- } - $i.push(0) + $i[0] = 0 case 2: @@ -45,8 +45,6 @@ module.exports = function (serializers) { continue } - $i.pop() - $step = 4 case 4: