mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove Scope::Label.
This commit is contained in:
parent
3d4a2219a6
commit
81569f7208
@ -123,10 +123,6 @@ bool AsmAnalyzer::operator()(Identifier const& _identifier)
|
||||
}
|
||||
++m_stackHeight;
|
||||
},
|
||||
[&](Scope::Label const&)
|
||||
{
|
||||
++m_stackHeight;
|
||||
},
|
||||
[&](Scope::Function const&)
|
||||
{
|
||||
m_errorReporter.typeError(
|
||||
@ -293,14 +289,6 @@ bool AsmAnalyzer::operator()(FunctionCall const& _funCall)
|
||||
);
|
||||
success = false;
|
||||
},
|
||||
[&](Scope::Label const&)
|
||||
{
|
||||
m_errorReporter.typeError(
|
||||
_funCall.functionName.location,
|
||||
"Attempt to call label instead of function."
|
||||
);
|
||||
success = false;
|
||||
},
|
||||
[&](Scope::Function const& _fun)
|
||||
{
|
||||
/// TODO: compare types too
|
||||
|
@ -25,14 +25,6 @@ using namespace solidity;
|
||||
using namespace solidity::yul;
|
||||
using namespace solidity::util;
|
||||
|
||||
bool Scope::registerLabel(YulString _name)
|
||||
{
|
||||
if (exists(_name))
|
||||
return false;
|
||||
identifiers[_name] = Label();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Scope::registerVariable(YulString _name, YulType const& _type)
|
||||
{
|
||||
if (exists(_name))
|
||||
|
@ -37,20 +37,17 @@ namespace solidity::yul
|
||||
struct Scope
|
||||
{
|
||||
using YulType = YulString;
|
||||
using LabelID = size_t;
|
||||
|
||||
struct Variable { YulType type; };
|
||||
struct Label { };
|
||||
struct Function
|
||||
{
|
||||
std::vector<YulType> arguments;
|
||||
std::vector<YulType> returns;
|
||||
};
|
||||
|
||||
using Identifier = std::variant<Variable, Label, Function>;
|
||||
using Identifier = std::variant<Variable, Function>;
|
||||
|
||||
bool registerVariable(YulString _name, YulType const& _type);
|
||||
bool registerLabel(YulString _name);
|
||||
bool registerFunction(
|
||||
YulString _name,
|
||||
std::vector<YulType> _arguments,
|
||||
|
@ -88,7 +88,6 @@ void VariableReferenceCounter::increaseRefIfFound(YulString _variableName)
|
||||
{
|
||||
++m_context.variableReferences[&_var];
|
||||
},
|
||||
[=](Scope::Label const&) { },
|
||||
[=](Scope::Function const&) { }
|
||||
});
|
||||
}
|
||||
@ -286,7 +285,6 @@ void CodeTransform::operator()(FunctionCall const& _call)
|
||||
Scope::Function* function = nullptr;
|
||||
yulAssert(m_scope->lookup(_call.functionName.name, GenericVisitor{
|
||||
[=](Scope::Variable&) { yulAssert(false, "Expected function name."); },
|
||||
[=](Scope::Label&) { yulAssert(false, "Expected function name."); },
|
||||
[&](Scope::Function& _function) { function = &_function; }
|
||||
}), "Function name not found.");
|
||||
yulAssert(function, "");
|
||||
@ -323,10 +321,6 @@ void CodeTransform::operator()(Identifier const& _identifier)
|
||||
m_assembly.appendConstant(u256(0));
|
||||
decreaseReference(_identifier.name, _var);
|
||||
},
|
||||
[=](Scope::Label& _label)
|
||||
{
|
||||
m_assembly.appendLabelReference(labelID(_label));
|
||||
},
|
||||
[=](Scope::Function&)
|
||||
{
|
||||
yulAssert(false, "Function not removed during desugaring.");
|
||||
@ -634,30 +628,6 @@ void CodeTransform::operator()(Block const& _block)
|
||||
BOOST_THROW_EXCEPTION(m_stackErrors.front());
|
||||
}
|
||||
|
||||
AbstractAssembly::LabelID CodeTransform::labelFromIdentifier(Identifier const& _identifier)
|
||||
{
|
||||
AbstractAssembly::LabelID label = AbstractAssembly::LabelID(-1);
|
||||
if (!m_scope->lookup(_identifier.name, GenericVisitor{
|
||||
[=](Scope::Variable&) { yulAssert(false, "Expected label"); },
|
||||
[&](Scope::Label& _label)
|
||||
{
|
||||
label = labelID(_label);
|
||||
},
|
||||
[=](Scope::Function&) { yulAssert(false, "Expected label"); }
|
||||
}))
|
||||
{
|
||||
yulAssert(false, "Identifier not found.");
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
AbstractAssembly::LabelID CodeTransform::labelID(Scope::Label const& _label)
|
||||
{
|
||||
if (!m_context->labelIDs.count(&_label))
|
||||
m_context->labelIDs[&_label] = m_assembly.newLabelId();
|
||||
return m_context->labelIDs[&_label];
|
||||
}
|
||||
|
||||
AbstractAssembly::LabelID CodeTransform::functionEntryID(YulString _name, Scope::Function const& _function)
|
||||
{
|
||||
if (!m_context->functionEntryIDs.count(&_function))
|
||||
|
@ -53,7 +53,6 @@ struct StackTooDeepError: virtual YulException
|
||||
|
||||
struct CodeTransformContext
|
||||
{
|
||||
std::map<Scope::Label const*, AbstractAssembly::LabelID> labelIDs;
|
||||
std::map<Scope::Function const*, AbstractAssembly::LabelID> functionEntryIDs;
|
||||
std::map<Scope::Variable const*, int> variableStackHeights;
|
||||
std::map<Scope::Variable const*, unsigned> variableReferences;
|
||||
@ -187,9 +186,6 @@ public:
|
||||
|
||||
private:
|
||||
AbstractAssembly::LabelID labelFromIdentifier(Identifier const& _identifier);
|
||||
/// @returns the label ID corresponding to the given label, allocating a new one if
|
||||
/// necessary.
|
||||
AbstractAssembly::LabelID labelID(Scope::Label const& _label);
|
||||
AbstractAssembly::LabelID functionEntryID(YulString _name, Scope::Function const& _function);
|
||||
/// Generates code for an expression that is supposed to return a single value.
|
||||
void visitExpression(Expression const& _expression);
|
||||
|
Loading…
Reference in New Issue
Block a user