MCPcopy Create free account
hub / github.com/argotorg/solidity / magicVariableToID

Function magicVariableToID

libsolidity/analysis/GlobalContext.cpp:40–72  ·  view source on GitHub ↗

Magic variables get negative ids for easy differentiation

Source from the content-addressed store, hash-verified

38
39/// Magic variables get negative ids for easy differentiation
40int magicVariableToID(std::string const& _name)
41{
42 static std::unordered_map<std::string, int> const magicVariables = {
43 {"abi", -1},
44 {"addmod", -2},
45 {"assert", -3},
46 {"block", -4},
47 {"blockhash", -5},
48 {"ecrecover", -6},
49 {"gasleft", -7},
50 {"keccak256", -8},
51 {"msg", -15},
52 {"mulmod", -16},
53 {"now", -17},
54 {"require", -18},
55 {"revert", -19},
56 {"ripemd160", -20},
57 {"selfdestruct", -21},
58 {"sha256", -22},
59 {"sha3", -23},
60 {"suicide", -24},
61 {"super", -25},
62 {"tx", -26},
63 {"type", -27},
64 {"this", -28},
65 {"blobhash", -29},
66 {"erc7201", -30}
67 };
68
69 if (auto id = magicVariables.find(_name); id != magicVariables.end())
70 return id->second;
71 solAssert(false, "Unknown magic variable: \"" + _name + "\".");
72}
73
74inline std::vector<std::shared_ptr<MagicVariableDeclaration const>> constructMagicVariables(langutil::EVMVersion _evmVersion)
75{

Callers 3

constructMagicVariablesFunction · 0.85
currentThisMethod · 0.85
currentSuperMethod · 0.85

Calls 2

findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected