mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename source location function.
This commit is contained in:
parent
f14b7598c7
commit
5093cff7ae
@ -127,7 +127,7 @@ string IRNames::zeroValue(Type const& _type, string const& _variableName)
|
|||||||
return "zero_" + _type.identifier() + _variableName;
|
return "zero_" + _type.identifier() + _variableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
string sourceLocationComment(langutil::SourceLocation const& _location, IRGenerationContext& _context)
|
string dispenseLocationComment(langutil::SourceLocation const& _location, IRGenerationContext& _context)
|
||||||
{
|
{
|
||||||
solAssert(_location.sourceName, "");
|
solAssert(_location.sourceName, "");
|
||||||
_context.markSourceUsed(*_location.sourceName);
|
_context.markSourceUsed(*_location.sourceName);
|
||||||
@ -139,9 +139,9 @@ string sourceLocationComment(langutil::SourceLocation const& _location, IRGenera
|
|||||||
+ to_string(_location.end);
|
+ to_string(_location.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
string sourceLocationComment(ASTNode const& _node, IRGenerationContext& _context)
|
string dispenseLocationComment(ASTNode const& _node, IRGenerationContext& _context)
|
||||||
{
|
{
|
||||||
return sourceLocationComment(_node.location(), _context);
|
return dispenseLocationComment(_node.location(), _context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,11 @@ struct IRNames
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a source location comment in the form of
|
* @returns a source location comment in the form of
|
||||||
* `/// @src <sourceIndex>:<locationStart>:<locationEnd>`.
|
* `/// @src <sourceIndex>:<locationStart>:<locationEnd>`
|
||||||
|
* and marks the source index as used.
|
||||||
*/
|
*/
|
||||||
std::string sourceLocationComment(langutil::SourceLocation const& _location, IRGenerationContext& _context);
|
std::string dispenseLocationComment(langutil::SourceLocation const& _location, IRGenerationContext& _context);
|
||||||
std::string sourceLocationComment(ASTNode const& _node, IRGenerationContext& _context);
|
std::string dispenseLocationComment(ASTNode const& _node, IRGenerationContext& _context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ string IRGenerator::generate(
|
|||||||
m_context.registerImmutableVariable(*var);
|
m_context.registerImmutableVariable(*var);
|
||||||
|
|
||||||
t("CreationObject", IRNames::creationObject(_contract));
|
t("CreationObject", IRNames::creationObject(_contract));
|
||||||
t("sourceLocationCommentCreation", sourceLocationComment(_contract));
|
t("sourceLocationCommentCreation", dispenseLocationComment(_contract));
|
||||||
t("library", _contract.isLibrary());
|
t("library", _contract.isLibrary());
|
||||||
|
|
||||||
FunctionDefinition const* constructor = _contract.constructor();
|
FunctionDefinition const* constructor = _contract.constructor();
|
||||||
@ -220,7 +220,7 @@ string IRGenerator::generate(
|
|||||||
|
|
||||||
// Do not register immutables to avoid assignment.
|
// Do not register immutables to avoid assignment.
|
||||||
t("DeployedObject", IRNames::deployedObject(_contract));
|
t("DeployedObject", IRNames::deployedObject(_contract));
|
||||||
t("sourceLocationCommentDeployed", sourceLocationComment(_contract));
|
t("sourceLocationCommentDeployed", dispenseLocationComment(_contract));
|
||||||
t("library_address", IRNames::libraryAddressImmutable());
|
t("library_address", IRNames::libraryAddressImmutable());
|
||||||
t("dispatch", dispatchRoutine(_contract));
|
t("dispatch", dispatchRoutine(_contract));
|
||||||
set<FunctionDefinition const*> deployedFunctionList = generateQueuedFunctions();
|
set<FunctionDefinition const*> deployedFunctionList = generateQueuedFunctions();
|
||||||
@ -294,7 +294,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
|
|||||||
}
|
}
|
||||||
<sourceLocationComment>
|
<sourceLocationComment>
|
||||||
)");
|
)");
|
||||||
templ("sourceLocationComment", sourceLocationComment(_contract));
|
templ("sourceLocationComment", dispenseLocationComment(_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));
|
t("sourceLocationComment", dispenseLocationComment(_function));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(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));
|
t("sourceLocationComment", dispenseLocationComment(*modifier));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(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));
|
t("sourceLocationComment", dispenseLocationComment(_function));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(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))
|
("sourceLocationComment", dispenseLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(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))
|
("sourceLocationComment", dispenseLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(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))
|
("sourceLocationComment", dispenseLocationComment(_varDecl))
|
||||||
(
|
(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(m_context.mostDerivedContract())
|
||||||
)
|
)
|
||||||
.render();
|
.render();
|
||||||
});
|
});
|
||||||
@ -818,14 +818,14 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
|
|||||||
for (ASTPointer<VariableDeclaration> const& varDecl: contract->constructor()->parameters())
|
for (ASTPointer<VariableDeclaration> const& varDecl: contract->constructor()->parameters())
|
||||||
params += m_context.addLocalVariable(*varDecl).stackSlots();
|
params += m_context.addLocalVariable(*varDecl).stackSlots();
|
||||||
|
|
||||||
t("sourceLocationComment", sourceLocationComment(
|
t("sourceLocationComment", dispenseLocationComment(
|
||||||
contract->constructor() ?
|
contract->constructor() ?
|
||||||
dynamic_cast<ASTNode const&>(*contract->constructor()) :
|
dynamic_cast<ASTNode const&>(*contract->constructor()) :
|
||||||
dynamic_cast<ASTNode const&>(*contract)
|
dynamic_cast<ASTNode const&>(*contract)
|
||||||
));
|
));
|
||||||
t(
|
t(
|
||||||
"contractSourceLocationComment",
|
"contractSourceLocationComment",
|
||||||
sourceLocationComment(m_context.mostDerivedContract())
|
dispenseLocationComment(m_context.mostDerivedContract())
|
||||||
);
|
);
|
||||||
|
|
||||||
t("params", joinHumanReadable(params));
|
t("params", joinHumanReadable(params));
|
||||||
@ -1073,7 +1073,7 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon
|
|||||||
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)
|
string IRGenerator::dispenseLocationComment(ASTNode const& _node)
|
||||||
{
|
{
|
||||||
return ::sourceLocationComment(_node, m_context);
|
return ::dispenseLocationComment(_node, m_context);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ private:
|
|||||||
|
|
||||||
void resetContext(ContractDefinition const& _contract, ExecutionContext _context);
|
void resetContext(ContractDefinition const& _contract, ExecutionContext _context);
|
||||||
|
|
||||||
std::string sourceLocationComment(ASTNode const& _node);
|
std::string dispenseLocationComment(ASTNode const& _node);
|
||||||
|
|
||||||
langutil::EVMVersion const m_evmVersion;
|
langutil::EVMVersion const m_evmVersion;
|
||||||
OptimiserSettings const m_optimiserSettings;
|
OptimiserSettings const m_optimiserSettings;
|
||||||
|
@ -217,7 +217,7 @@ std::ostringstream& IRGeneratorForStatementsBase::appendCode(bool _addLocationCo
|
|||||||
m_currentLocation.isValid() &&
|
m_currentLocation.isValid() &&
|
||||||
m_lastLocation != m_currentLocation
|
m_lastLocation != m_currentLocation
|
||||||
)
|
)
|
||||||
m_code << sourceLocationComment(m_currentLocation, m_context) << "\n";
|
m_code << dispenseLocationComment(m_currentLocation, m_context) << "\n";
|
||||||
|
|
||||||
m_lastLocation = m_currentLocation;
|
m_lastLocation = m_currentLocation;
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ string IRGeneratorForStatements::constantValueFunction(VariableDeclaration const
|
|||||||
<ret> := <value>
|
<ret> := <value>
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
templ("sourceLocationComment", sourceLocationComment(_constant, m_context));
|
templ("sourceLocationComment", dispenseLocationComment(_constant, m_context));
|
||||||
templ("functionName", functionName);
|
templ("functionName", functionName);
|
||||||
IRGeneratorForStatements generator(m_context, m_utils);
|
IRGeneratorForStatements generator(m_context, m_utils);
|
||||||
solAssert(_constant.value(), "");
|
solAssert(_constant.value(), "");
|
||||||
|
Loading…
Reference in New Issue
Block a user