mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Bugfix.
This commit is contained in:
parent
6bbef64034
commit
eec258c2d2
@ -122,24 +122,33 @@ optional<KnowledgeBase::VariableOffset> KnowledgeBase::explore(Expression const&
|
|||||||
else if (Identifier const* identifier = std::get_if<Identifier>(&_value))
|
else if (Identifier const* identifier = std::get_if<Identifier>(&_value))
|
||||||
return explore(identifier->name);
|
return explore(identifier->name);
|
||||||
else if (FunctionCall const* f = get_if<FunctionCall>(&_value))
|
else if (FunctionCall const* f = get_if<FunctionCall>(&_value))
|
||||||
if (f->functionName.name == "add"_yulstring || f->functionName.name == "sub"_yulstring)
|
{
|
||||||
|
if (f->functionName.name == "add"_yulstring)
|
||||||
|
{
|
||||||
if (optional<VariableOffset> a = explore(f->arguments[0]))
|
if (optional<VariableOffset> a = explore(f->arguments[0]))
|
||||||
if (optional<VariableOffset> b = explore(f->arguments[1]))
|
if (optional<VariableOffset> b = explore(f->arguments[1]))
|
||||||
{
|
{
|
||||||
u256 offset =
|
u256 offset = a->offset + b->offset;
|
||||||
f->functionName.name == "add"_yulstring ?
|
if (a->reference.empty())
|
||||||
a->offset + b->offset :
|
|
||||||
a->offset - b->offset;
|
|
||||||
if (a->reference == b->reference)
|
|
||||||
// Offsets relative to the same reference variable
|
|
||||||
return VariableOffset{a->reference, offset};
|
|
||||||
else if (a->reference == YulString{})
|
|
||||||
// a is constant
|
// a is constant
|
||||||
return VariableOffset{b->reference, offset};
|
return VariableOffset{b->reference, offset};
|
||||||
else if (b->reference == YulString{})
|
else if (b->reference.empty())
|
||||||
// b is constant
|
// b is constant
|
||||||
return VariableOffset{a->reference, offset};
|
return VariableOffset{a->reference, offset};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (f->functionName.name == "sub"_yulstring)
|
||||||
|
if (optional<VariableOffset> a = explore(f->arguments[0]))
|
||||||
|
if (optional<VariableOffset> b = explore(f->arguments[1]))
|
||||||
|
{
|
||||||
|
u256 offset = a->offset - b->offset;
|
||||||
|
if (a->reference == b->reference)
|
||||||
|
return VariableOffset{YulString{}, offset};
|
||||||
|
else if (b->reference.empty())
|
||||||
|
// b is constant
|
||||||
|
return VariableOffset{a->reference, offset};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user