"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Encoder = exports.Interpreter = void 0;
exports.isOperator = isOperator;
exports.operand = operand;
exports.operator = operator;
function isOperator(ir) {
    return ir.opCode !== undefined;
}
function operand(x) {
    return { t: x };
}
function operator(x, flags) {
    return { opCode: x, flags };
}
class Interpreter {
    operand(...xs) {
        for (const x of xs)
            this.doOperand(x);
        return this;
    }
    operator(opCode, flags) {
        this.doOperator(opCode, flags);
        return this;
    }
    next(ir) {
        if (isOperator(ir)) {
            this.doOperator(ir.opCode, ir.flags);
        }
        else {
            this.doOperand(ir.t);
        }
    }
}
exports.Interpreter = Interpreter;
class Encoder {
    push(ir) {
        if (isOperator(ir)) {
            this.operator(ir.opCode, ir.flags);
        }
        else {
            this.operand(ir.t);
        }
    }
}
exports.Encoder = Encoder;
//# sourceMappingURL=ir.js.map