Skip to content
This repository was archived by the owner on Aug 20, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/evmv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const kast = require("./kast.js");
const {
getContractFromCallId,
} = require("../lib/srchandler.js");
const {
buildDisplayInfo
} = require("../lib/clean-evm-node.js");
Expand Down Expand Up @@ -38,8 +41,7 @@ module.exports = function (state) {
} = node;

// console.log(bin_runtime);
let contract_o = state.config.implementations[state.config.v2n[call_id]];
let contract = state.config.contracts[contract_o.name];
let contract = getContractFromCallId(state, call_id);
// TODO - use var to contractname map to get the contractname
// and use it to get the right contract here

Expand Down
4 changes: 2 additions & 2 deletions lib/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { genBehaviour } = require("./behavior.js");
const evmv = require("./evmv.js");
const fs = require("fs");
const {
getContractFromCallId,
getCodeStringFromPc,
} = require("../lib/srchandler.js");
const {
Expand Down Expand Up @@ -69,8 +70,7 @@ const view = {
pc,
call_id
} = buildDisplayInfo(k);
let contract_o = state.config.implementations[state.config.v2n[call_id]];
let contract = state.config.contracts[contract_o.name];
let contract = getContractFromCallId(state, call_id);
let src = getCodeStringFromPc(state.config.srcs, contract, parseInt(pc), true);
return src;
},
Expand Down
12 changes: 12 additions & 0 deletions lib/srchandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ const get_pc_to_inst_map = bin_string => {
};
}

const getContractFromCallId = (state, call_id) => {
const contract_look_up = call_id == 'CALLER_ID' ? 'ACCT_ID' : call_id;
let contract_o = state.config.implementations[state.config.v2n[contract_look_up]];
if (!contract_o) {
console.log('impl', state.config.implementations, 'v2n', state.config.v2n, 'lookup', contract_look_up);
throw new Error('contract not found');
} else {
return state.config.contracts[contract_o.name];
}
}

// EXPORT
// This mess deals with displaying the highlighted compact
// source code with lines.
Expand Down Expand Up @@ -206,6 +217,7 @@ let functionNameToPcRange = (sig, srcmapArr, ast, bin_runtime, inst_to_pc) => {
}

module.exports = {
getContractFromCallId,
getCodeStringFromPc,
get_pc_to_inst_map,
genSrcmapArr,
Expand Down