File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -814,6 +814,8 @@ public JSONObject toJson() {
814814 jsonObject .put ("basic_blocks_pc" , _basicBlocks != null ? BasicBlock .basicBlocksToLongArrayToString (
815815 BasicBlock .basicBlocksToLongArray (_basicBlocks )) : new JSONArray ());
816816
817+ jsonObject .put ("last_pc" , this ._cfg .getLastOpcodePc ());
818+
817819 jsonObject .put ("execution_time" , _executionTime );
818820
819821 return jsonObject ;
Original file line number Diff line number Diff line change @@ -114,6 +114,29 @@ public Set<Statement> getExternalData() {
114114 return this .externalData ;
115115 }
116116
117+ /**
118+ * Yields the program counter of the last opcode in the CFG.
119+ * This method iterates over all basic blocks and their statements to find
120+ * the highest program counter value, which corresponds to the last instruction
121+ * in the bytecode.
122+ *
123+ * @return the maximum program counter found among all statements
124+ */
125+ public int getLastOpcodePc () {
126+ int maxPc = 0 ;
127+ Set <BasicBlock > bbs = getAllBasicBlocks ();
128+ for (BasicBlock bb : bbs ) {
129+ int max = 0 ;
130+ for (Statement st : bb .getStatements ())
131+ if (((ProgramCounterLocation ) st .getLocation ()).getPc () > max )
132+ max = ((ProgramCounterLocation ) st .getLocation ()).getPc ();
133+ if (max > maxPc )
134+ maxPc = max ;
135+ }
136+
137+ return maxPc ;
138+ }
139+
117140 /**
118141 * Returns a set of all the SSTORE statements in the CFG.
119142 *
You can’t perform that action at this time.
0 commit comments