Skip to content

Commit

Permalink
fix: remove deprecated ibid support
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Apr 16, 2021
1 parent 646b621 commit 0f5fc94
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 459 deletions.
2 changes: 0 additions & 2 deletions packages/SwingSet/src/kernel/kdebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export function legibilizeValue(val, slots) {
return `@${slots[val.index]}`;
case 'error':
return `new ${val.name}('${val.message}')`;
case 'ibid':
return `ibid(${val.index})`;
default:
assert.fail(X`unknown qClass ${qClass} in legibilizeValue`);
}
Expand Down
5 changes: 0 additions & 5 deletions packages/SwingSet/test/test-marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ test('serialize exports', t => {
'[{"@qclass":"slot","iface":"Alleged: o1","index":0},{"@qclass":"slot","index":0}]',
slots: ['o+1'],
});
t.deepEqual(ser(harden([o1, o1]), 'forbidCycles'), {
body:
'[{"@qclass":"slot","iface":"Alleged: o1","index":0},{"@qclass":"ibid","index":1}]',
slots: ['o+1'],
});
t.deepEqual(ser(harden([o2, o1])), {
body:
'[{"@qclass":"slot","iface":"Alleged: o2","index":0},{"@qclass":"slot","iface":"Alleged: o1","index":1}]',
Expand Down
163 changes: 0 additions & 163 deletions packages/marshal/src/ibidTables.js

This file was deleted.

45 changes: 6 additions & 39 deletions packages/marshal/src/marshal-justin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Nat } from '@agoric/nat';
import { assert, details as X, q } from '@agoric/assert';
import { getErrorConstructor } from './passStyleOf';
import { QCLASS } from './marshal';
import { makeReviverIbidTable } from './ibidTables';

import './types';

Expand Down Expand Up @@ -119,18 +118,15 @@ const identPattern = /^[a-zA-Z]\w*$/;
* @returns {string}
*/
const decodeToJustin = (encoding, shouldIndent = false) => {
// TODO How do I avoid these imports in types?
/** @type {import('./ibidTables').ReviverIbidTable<Encoding>} */
const ibidTable = makeReviverIbidTable('forbidCycles');
const ibidMap = new Map();

/**
* The first pass populates ibidMap for use by `decode`.
* Since this is the first pass, it should do all input validation.
* The first pass does some input validation.
* Its control flow should mirror `recur` as closely as possible
* and the two should be maintained together. They must visit everything
* in the same order.
*
* TODO now that ibids are gone, we should fold this back together into
* one validating pass.
*
* @param {Encoding} rawTree
* @returns {void}
*/
Expand Down Expand Up @@ -168,15 +164,7 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
case '@@asyncIterator': {
return;
}
case 'ibid': {
const { index } = rawTree;
// ibidTable's `get` does some input validation.
const rawNode = ibidTable.get(index);
ibidMap.set(rawNode, index);
return;
}
case 'error': {
ibidTable.leaf(rawTree);
const { name, message } = rawTree;
assert.typeof(
name,
Expand All @@ -195,15 +183,13 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
return;
}
case 'slot': {
ibidTable.leaf(rawTree);
const { index, iface } = rawTree;
assert.typeof(index, 'number');
Nat(index);
assert.typeof(iface, 'string');
return;
}
case 'hilbert': {
ibidTable.start(rawTree);
const { original, rest } = rawTree;
assert(
'original' in rawTree,
Expand All @@ -225,7 +211,6 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
!(QCLASS in rest),
X`Rest encoding ${rest} must not contain ${q(QCLASS)}`,
);
ibidTable.start(rest);
const names = ownKeys(rest);
for (const name of names) {
assert.typeof(
Expand All @@ -235,9 +220,7 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
);
prepare(rest[name]);
}
ibidTable.finish(rest);
}
ibidTable.finish(rawTree);
return;
}

Expand All @@ -246,14 +229,11 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
}
}
} else if (Array.isArray(rawTree)) {
ibidTable.start(rawTree);
const { length } = rawTree;
for (let i = 0; i < length; i += 1) {
prepare(rawTree[i]);
}
ibidTable.finish(rawTree);
} else {
ibidTable.start(rawTree);
const names = ownKeys(rawTree);
for (const name of names) {
assert.typeof(
Expand All @@ -263,7 +243,6 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
);
prepare(rawTree[name]);
}
ibidTable.finish(rawTree);
}
};

Expand All @@ -272,20 +251,13 @@ const decodeToJustin = (encoding, shouldIndent = false) => {

/**
* This is the second pass recursion after the first pass `prepare`.
* The first pass initialized `ibidMap` and did input validation so
* here we can safely assume everything it validated.
* The first pass did some input validation so
* here we can safely assume everything those things are validated.
*
* @param {Encoding} rawTree
* @returns {number}
*/
const decode = rawTree => {
if (ibidMap.has(rawTree)) {
const index = ibidMap.get(rawTree);
out.next(`initIbid(${index},`);
// eslint-disable-next-line no-use-before-define
recur(rawTree);
return out.next(')');
}
// eslint-disable-next-line no-use-before-define
return recur(rawTree);
};
Expand Down Expand Up @@ -345,11 +317,6 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
return out.next('Symbol.asyncIterator');
}

case 'ibid': {
const { index } = rawTree;
return out.next(`getIbid(${index})`);
}

case 'error': {
const { name, message } = rawTree;
return out.next(`${name}(${quote(message)})`);
Expand Down
Loading

0 comments on commit 0f5fc94

Please sign in to comment.