Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Func({ node }) {
const funcHasThisIntr =
node.body.find(n => n === newNode) !== undefined;
// Update func's body size if needed
if (funcHasThisIntr === true) {
// These are the old functions locations informations
assertHasLoc(node);
const oldNodeSize = encodeNode(oldNode).length;
const bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize;
if (bodySizeDeltaBytes !== 0) {
const newValue = node.metadata.bodySize + bodySizeDeltaBytes;
const newByteArray = encodeU32(newValue);
// function body size byte
// FIXME(sven): only handles one byte u32
const start = node.loc.start.column;
const end = start + 1;
uint8Buffer = overrideBytesInBuffer(
uint8Buffer,
start,
end,
newByteArray
);
}
}
}
});
Func: function Func(_ref3) {
var node = _ref3.node;
var funcHasThisIntr = node.body.find(function (n) {
return n === newNode;
}) !== undefined; // Update func's body size if needed
if (funcHasThisIntr === true) {
// These are the old functions locations informations
assertHasLoc(node);
var oldNodeSize = encodeNode(oldNode).length;
var bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize;
if (bodySizeDeltaBytes !== 0) {
var newValue = node.metadata.bodySize + bodySizeDeltaBytes;
var newByteArray = encodeU32(newValue); // function body size byte
// FIXME(sven): only handles one byte u32
var start = node.loc.start.column;
var end = start + 1;
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newByteArray);
}
}
}
});
Func: function Func(_ref3) {
var node = _ref3.node;
var funcHasThisIntr = node.body.find(function (n) {
return n === newNode;
}) !== undefined; // Update func's body size if needed
if (funcHasThisIntr === true) {
// These are the old functions locations informations
assertHasLoc(node);
var oldNodeSize = encodeNode(oldNode).length;
var bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize;
if (bodySizeDeltaBytes !== 0) {
var newValue = node.metadata.bodySize + bodySizeDeltaBytes;
var newByteArray = encodeU32(newValue); // function body size byte
// FIXME(sven): only handles one byte u32
var start = node.loc.start.column;
var end = start + 1;
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newByteArray);
}
}
}
});
Func({ node }) {
const funcHasThisIntr =
node.body.find(n => n === newNode) !== undefined;
// Update func's body size if needed
if (funcHasThisIntr === true) {
// These are the old functions locations informations
assertHasLoc(node);
const oldNodeSize = encodeNode(oldNode).length;
const bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize;
if (bodySizeDeltaBytes !== 0) {
const newValue = node.metadata.bodySize + bodySizeDeltaBytes;
const newByteArray = encodeU32(newValue);
debug("resize func body newValue=%d", newValue);
// function body size byte
// FIXME(sven): only handles one byte u32
const start = node.loc.start.column;
const end = start + 1;
uint8Buffer = overrideBytesInBuffer(
uint8Buffer,
start,
end,
newByteArray
);
}
}
SectionMetadata({ node }) {
/**
* Section size
*/
{
const newu32Encoded = encodeU32(node.size.value);
const newu32EncodedLen = newu32Encoded.length;
const start = node.size.loc.start.column;
const end = node.size.loc.end.column;
const oldu32EncodedLen = end - start;
if (newu32EncodedLen !== oldu32EncodedLen) {
const deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen;
debug(
"found LEB128 encoding size delta section=%s detla=%s",
node.section,
deltaInSizeEncoding
);
SectionMetadata: function SectionMetadata(_ref2) {
var node = _ref2.node;
/**
* Section size
*/
{
var newu32Encoded = encodeU32(node.size.value);
var newu32EncodedLen = newu32Encoded.length;
var start = node.size.loc.start.column;
var end = node.size.loc.end.column;
var oldu32EncodedLen = end - start;
if (newu32EncodedLen !== oldu32EncodedLen) {
var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen;
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newu32Encoded);
shiftFollowingSections(ast, node, -deltaInSizeEncoding);
}
}
}
});