sevm
Version:
A Symbolic Ethereum Virtual Machine (EVM) bytecode decompiler & analyzer library & CLI
95 lines • 2.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SigCase = exports.Sig = exports.JumpDest = exports.Jumpi = exports.Jump = exports.Branch = void 0;
const _1 = require(".");
/**
* Represents a jump from one `State` to another from the given `pc`.
*/
class Branch {
constructor(pc, state) {
this.pc = pc;
this.state = state;
}
static make(pc, state) {
return new Branch(pc, state.clone());
}
}
exports.Branch = Branch;
class Jump {
constructor(offset, destBranch, pushStateId) {
this.offset = offset;
this.destBranch = destBranch;
this.pushStateId = pushStateId;
this.name = 'Jump';
}
eval() {
return this;
}
next() {
return [this.destBranch];
}
}
exports.Jump = Jump;
class Jumpi {
constructor(cond, offset, fallBranch, destBranch, pushStateId) {
this.cond = cond;
this.offset = offset;
this.fallBranch = fallBranch;
this.destBranch = destBranch;
this.pushStateId = pushStateId;
this.name = 'Jumpi';
this.evalCond = cond.eval();
}
eval() {
return new Jumpi(this.cond.eval(), this.offset, this.fallBranch, this.destBranch, this.pushStateId);
}
next() {
return this.evalCond.isVal()
? this.evalCond.val === 0n
? [this.fallBranch]
: [this.destBranch]
: [this.destBranch, this.fallBranch];
}
}
exports.Jumpi = Jumpi;
class JumpDest {
constructor(fallBranch) {
this.fallBranch = fallBranch;
this.name = 'JumpDest';
}
eval() {
return this;
}
next() {
return [this.fallBranch];
}
}
exports.JumpDest = JumpDest;
class Sig extends _1.Tag {
constructor(selector, positive = true) {
super(0, 1);
this.selector = selector;
this.positive = positive;
this.tag = 'Sig';
}
eval() {
return this;
}
}
exports.Sig = Sig;
class SigCase {
constructor(condition, offset, fallBranch) {
this.condition = condition;
this.offset = offset;
this.fallBranch = fallBranch;
this.name = 'SigCase';
}
eval() {
return this;
}
next() {
return [this.fallBranch];
}
}
exports.SigCase = SigCase;
//# sourceMappingURL=flow.js.map