Comparing version 0.10.0-next.3 to 0.10.0-next.4
@@ -196,5 +196,7 @@ import { hexToBin } from '@bitauth/libauth'; | ||
this.emit(compileTimeOp(node.timeOp), { location: node.location, positionHint: PositionHint.END }); | ||
// add debug require message | ||
// TODO: Same comment as in require | ||
if (node.message) { | ||
this.requireMessages.push({ | ||
// We're removing 1 from the IP because the error message needs to match the OP_XXX_VERIFY, not the OP_DROP that | ||
// is emitted directly after | ||
ip: this.getCurrentInstructionPointer() - 1, | ||
@@ -211,6 +213,8 @@ line: node.location.start.line, | ||
this.emit(Op.OP_VERIFY, { location: node.location, positionHint: PositionHint.END }); | ||
// add debug require message | ||
// TODO: Add *all* require messages to the artifact, so we can report on line number for the failed require(), | ||
// even if there is no message in the require() call | ||
// TODO: We don't even have to display the Libauth message if we just say "this and this require failed" | ||
if (node.message) { | ||
this.requireMessages.push({ | ||
ip: this.getCurrentInstructionPointer() - 1, | ||
ip: this.getCurrentInstructionPointer(), | ||
line: node.location.start.line, | ||
@@ -226,11 +230,3 @@ message: node.message, | ||
const { line } = node.location.start; | ||
// TODO: refactor to use a map instead of array (also in the artifact and other places where console logs and | ||
// require statements are used) | ||
// check if log entry exists for the instruction pointer, create if not | ||
// TODO: Do we really want to merge different console logs at the same instruction pointer? | ||
let index = this.consoleLogs.findIndex((entry) => entry.ip === ip); | ||
if (index === -1) { | ||
index = this.consoleLogs.push({ ip, line, data: [] }) - 1; | ||
} | ||
node.parameters.forEach((parameter) => { | ||
const data = node.parameters.map((parameter) => { | ||
if (parameter instanceof IdentifierNode) { | ||
@@ -240,8 +236,7 @@ const symbol = parameter.definition; | ||
const type = typeof symbol.type === 'string' ? symbol.type : symbol.toString(); | ||
this.consoleLogs[index].data.push({ stackIndex, type }); | ||
return { stackIndex, type }; | ||
} | ||
else { | ||
this.consoleLogs[index].data.push(parameter.toString()); | ||
} | ||
return parameter.toString(); | ||
}); | ||
this.consoleLogs.push({ ip, line, data }); | ||
return node; | ||
@@ -256,3 +251,3 @@ } | ||
node.ifBlock = this.visit(node.ifBlock); | ||
this.removeScopedVariables(stackDepth, node); | ||
this.removeScopedVariables(stackDepth, node.ifBlock); | ||
if (node.elseBlock) { | ||
@@ -262,3 +257,3 @@ this.emit(Op.OP_ELSE, { location: node.elseBlock.location }); | ||
node.elseBlock = this.visit(node.elseBlock); | ||
this.removeScopedVariables(stackDepth, node); | ||
this.removeScopedVariables(stackDepth, node.elseBlock); | ||
} | ||
@@ -276,3 +271,3 @@ const endLocationData = { | ||
for (let i = 0; i < dropCount; i += 1) { | ||
this.emit(Op.OP_DROP, { location: node.location }); | ||
this.emit(Op.OP_DROP, { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(); | ||
@@ -279,0 +274,0 @@ } |
export * from './Errors.js'; | ||
export * as utils from '@cashscript/utils'; | ||
export { compileFile, compileString } from './compiler.js'; | ||
export declare const version = "0.10.0-next.3"; | ||
export declare const version = "0.10.0-next.4"; |
export * from './Errors.js'; | ||
export * as utils from '@cashscript/utils'; | ||
export { compileFile, compileString } from './compiler.js'; | ||
export const version = '0.10.0-next.3'; | ||
export const version = '0.10.0-next.4'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "cashc", | ||
"version": "0.10.0-next.3", | ||
"version": "0.10.0-next.4", | ||
"description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
"@bitauth/libauth": "^2.0.0", | ||
"@cashscript/utils": "^0.10.0-next.3", | ||
"@cashscript/utils": "^0.10.0-next.4", | ||
"antlr4": "^4.13.1-patch-1", | ||
@@ -69,3 +69,3 @@ "commander": "^7.1.0", | ||
}, | ||
"gitHead": "1b66bdb92f972d311d968667290e96085d7fcdc7" | ||
"gitHead": "9105dbcd300aa6a96f8f5297147572a9a79af6c4" | ||
} |
321158
7561