"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Primitive_1 = require("../../../../Primitive");
const _ids_1 = require("../../../_ids");
class Memory extends Primitive_1.Primitive {
    constructor(system) {
        super({ i: ['a'], o: ['a'] }, {}, system, _ids_1.ID_MEMORY);
        this._current = undefined;
        this.addListener('reset', () => {
            this._current = undefined;
        });
    }
    onDataInputData(name, data) {
        this._current = data;
        this._forward_if_ready();
    }
    _forward_if_ready() {
        while (!this._forwarding &&
            !this._backwarding &&
            this._current !== undefined) {
            this._forward('a', this._current);
            this._current = undefined;
            this._backward_all();
        }
    }
    onDataOutputDrop(name) {
        this._current = undefined;
    }
    onDataInputInvalid(name) {
        this._invalidate();
    }
}
exports.default = Memory;
//# sourceMappingURL=index.js.map