mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11902 from ethereum/addHelperForContext
Refactor: Add helper for context.
This commit is contained in:
commit
4615e62514
@ -179,7 +179,7 @@ string IRGenerator::generate(
|
|||||||
);
|
);
|
||||||
|
|
||||||
t("useSrcMapCreation", useSrcMap);
|
t("useSrcMapCreation", useSrcMap);
|
||||||
t("sourceLocationComment", sourceLocationComment(_contract, m_context));
|
t("sourceLocationComment", sourceLocationComment(_contract));
|
||||||
|
|
||||||
t("CreationObject", IRNames::creationObject(_contract));
|
t("CreationObject", IRNames::creationObject(_contract));
|
||||||
t("library", _contract.isLibrary());
|
t("library", _contract.isLibrary());
|
||||||
@ -294,7 +294,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
|
|||||||
}
|
}
|
||||||
<sourceLocationComment>
|
<sourceLocationComment>
|
||||||
)");
|
)");
|
||||||
templ("sourceLocationComment", sourceLocationComment(_contract, m_context));
|
templ("sourceLocationComment", sourceLocationComment(_contract));
|
||||||
templ("functionName", funName);
|
templ("functionName", funName);
|
||||||
templ("panic", m_utils.panicFunction(PanicCode::InvalidInternalFunction));
|
templ("panic", m_utils.panicFunction(PanicCode::InvalidInternalFunction));
|
||||||
templ("in", suffixedVariableNameList("in_", 0, arity.in));
|
templ("in", suffixedVariableNameList("in_", 0, arity.in));
|
||||||
@ -347,10 +347,10 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function)
|
|||||||
<contractSourceLocationComment>
|
<contractSourceLocationComment>
|
||||||
)");
|
)");
|
||||||
|
|
||||||
t("sourceLocationComment", sourceLocationComment(_function, m_context));
|
t("sourceLocationComment", sourceLocationComment(_function));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
);
|
);
|
||||||
|
|
||||||
t("functionName", functionName);
|
t("functionName", functionName);
|
||||||
@ -436,10 +436,10 @@ string IRGenerator::generateModifier(
|
|||||||
_modifierInvocation.name().annotation().referencedDeclaration
|
_modifierInvocation.name().annotation().referencedDeclaration
|
||||||
);
|
);
|
||||||
solAssert(modifier, "");
|
solAssert(modifier, "");
|
||||||
t("sourceLocationComment", sourceLocationComment(*modifier, m_context));
|
t("sourceLocationComment", sourceLocationComment(*modifier));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (*_modifierInvocation.name().annotation().requiredLookup)
|
switch (*_modifierInvocation.name().annotation().requiredLookup)
|
||||||
@ -499,10 +499,10 @@ string IRGenerator::generateFunctionWithModifierInner(FunctionDefinition const&
|
|||||||
}
|
}
|
||||||
<contractSourceLocationComment>
|
<contractSourceLocationComment>
|
||||||
)");
|
)");
|
||||||
t("sourceLocationComment", sourceLocationComment(_function, m_context));
|
t("sourceLocationComment", sourceLocationComment(_function));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
);
|
);
|
||||||
t("functionName", functionName);
|
t("functionName", functionName);
|
||||||
vector<string> retParams;
|
vector<string> retParams;
|
||||||
@ -547,10 +547,10 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
|
|||||||
}
|
}
|
||||||
<contractSourceLocationComment>
|
<contractSourceLocationComment>
|
||||||
)")
|
)")
|
||||||
("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
|
("sourceLocationComment", sourceLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
)
|
)
|
||||||
("functionName", functionName)
|
("functionName", functionName)
|
||||||
("id", to_string(_varDecl.id()))
|
("id", to_string(_varDecl.id()))
|
||||||
@ -566,10 +566,10 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
|
|||||||
}
|
}
|
||||||
<contractSourceLocationComment>
|
<contractSourceLocationComment>
|
||||||
)")
|
)")
|
||||||
("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
|
("sourceLocationComment", sourceLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
)
|
)
|
||||||
("functionName", functionName)
|
("functionName", functionName)
|
||||||
("constantValueFunction", IRGeneratorForStatements(m_context, m_utils).constantValueFunction(_varDecl))
|
("constantValueFunction", IRGeneratorForStatements(m_context, m_utils).constantValueFunction(_varDecl))
|
||||||
@ -692,10 +692,10 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
|
|||||||
("params", joinHumanReadable(parameters))
|
("params", joinHumanReadable(parameters))
|
||||||
("retVariables", joinHumanReadable(returnVariables))
|
("retVariables", joinHumanReadable(returnVariables))
|
||||||
("code", std::move(code))
|
("code", std::move(code))
|
||||||
("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
|
("sourceLocationComment", sourceLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
)
|
)
|
||||||
.render();
|
.render();
|
||||||
});
|
});
|
||||||
@ -820,13 +820,12 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
|
|||||||
|
|
||||||
t("sourceLocationComment", sourceLocationComment(
|
t("sourceLocationComment", sourceLocationComment(
|
||||||
contract->constructor() ?
|
contract->constructor() ?
|
||||||
contract->constructor()->location() :
|
dynamic_cast<ASTNode const&>(*contract->constructor()) :
|
||||||
contract->location(),
|
dynamic_cast<ASTNode const&>(*contract)
|
||||||
m_context
|
|
||||||
));
|
));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract(), m_context)
|
sourceLocationComment(m_context.mostDerivedContract())
|
||||||
);
|
);
|
||||||
|
|
||||||
t("params", joinHumanReadable(params));
|
t("params", joinHumanReadable(params));
|
||||||
@ -1073,3 +1072,8 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon
|
|||||||
for (auto const& var: ContractType(_contract).stateVariables())
|
for (auto const& var: ContractType(_contract).stateVariables())
|
||||||
m_context.addStateVariable(*get<0>(var), get<1>(var), get<2>(var));
|
m_context.addStateVariable(*get<0>(var), get<1>(var), get<2>(var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string IRGenerator::sourceLocationComment(ASTNode const& _node) const
|
||||||
|
{
|
||||||
|
return ::sourceLocationComment(_node, m_context);
|
||||||
|
}
|
||||||
|
@ -119,6 +119,8 @@ private:
|
|||||||
|
|
||||||
void resetContext(ContractDefinition const& _contract, ExecutionContext _context);
|
void resetContext(ContractDefinition const& _contract, ExecutionContext _context);
|
||||||
|
|
||||||
|
std::string sourceLocationComment(ASTNode const& _node) const;
|
||||||
|
|
||||||
langutil::EVMVersion const m_evmVersion;
|
langutil::EVMVersion const m_evmVersion;
|
||||||
OptimiserSettings const m_optimiserSettings;
|
OptimiserSettings const m_optimiserSettings;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user