export {
convertTargetName,
isPureRhs,
literalIndex,
resolvePackedValue,
stripOuterParens,
wrapExpression,
} from "./high-level-utils.js";
const SIMPLE_IDENT_OR_LITERAL_RE = /^(?:-?\d+|0x[0-9A-Fa-f]+|true|false|null|"(?:[^"\\]|\\.)*"|[A-Za-z_][A-Za-z0-9_]*)$/u;
export function materialiseStackTopForDup(state, value, slot = state.stack.length - 1) {
if (SIMPLE_IDENT_OR_LITERAL_RE.test(value)) {
return value;
}
const temp = `t${state.nextTempId}`;
state.nextTempId += 1;
state.statements.push(`let ${temp} = ${value};`);
state.stack[slot] = temp;
return temp;
}