sevm
Version:
A Symbolic Ethereum Virtual Machine (EVM) bytecode decompiler & analyzer library & CLI
94 lines • 2.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SLoad = exports.MappingLoad = exports.SStore = exports.MappingStore = exports.Variable = void 0;
const _1 = require(".");
/**
*
*/
class Variable {
constructor(label, types, index) {
this.label = label;
this.types = types;
this.index = index;
}
}
exports.Variable = Variable;
class MappingStore {
constructor(slot, mappings, location, items, data, structlocation) {
this.slot = slot;
this.mappings = mappings;
this.location = location;
this.items = items;
this.data = data;
this.structlocation = structlocation;
this.name = 'MappingStore';
const loc = location;
if (!(loc in mappings)) {
mappings[loc] = { name: undefined, structs: [], keys: [], values: [] };
}
mappings[loc].keys.push(items);
if (structlocation === undefined) {
mappings[loc].values.push(data);
}
}
eval() {
return new MappingStore(this.slot, this.mappings, this.location, this.items, this.data.eval(), this.structlocation);
}
}
exports.MappingStore = MappingStore;
class SStore {
constructor(slot, data, variable) {
this.slot = slot;
this.data = data;
this.variable = variable;
this.name = 'SStore';
}
eval() {
const data = this.data.eval();
if (this.variable !== undefined) {
const i = this.variable.types.indexOf(this.data);
if (i === -1)
throw new Error('error in eval sstore');
this.variable.types[i] = data;
}
return new SStore(this.slot.eval(), data, this.variable);
}
}
exports.SStore = SStore;
class MappingLoad extends _1.Tag {
constructor(slot, mappings, location, items, structlocation) {
super(Math.max(slot.depth, ...items.map(e => e.depth)) + 1, slot.count + items.reduce((accum, curr) => accum + curr.count, 0) + 1);
this.slot = slot;
this.mappings = mappings;
this.location = location;
this.items = items;
this.structlocation = structlocation;
this.tag = 'MappingLoad';
if (!(location in mappings)) {
mappings[location] = {
name: undefined,
structs: [],
keys: [],
values: [],
};
}
mappings[location].keys.push(items);
}
eval() {
return this;
}
}
exports.MappingLoad = MappingLoad;
class SLoad extends _1.Tag {
constructor(slot, variable) {
super(slot.depth + 1, slot.count + 1);
this.slot = slot;
this.variable = variable;
this.tag = 'SLoad';
}
eval() {
return new SLoad(this.slot.eval(), this.variable);
}
}
exports.SLoad = SLoad;
//# sourceMappingURL=storage.js.map