mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4296 from ethereum/yul-internal
[WIP] Rename some internal constructs from Julia/Iulia to Yul
This commit is contained in:
commit
dc5cd3e1e7
@ -29,7 +29,7 @@ namespace solidity
|
||||
|
||||
enum class ExperimentalFeature
|
||||
{
|
||||
ABIEncoderV2, // new ABI encoder that makes use of JULIA
|
||||
ABIEncoderV2, // new ABI encoder that makes use of Yul
|
||||
SMTChecker,
|
||||
V050, // v0.5.0 breaking changes
|
||||
Test,
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* @author Christian <chris@ethereum.org>
|
||||
* @date 2017
|
||||
* Routines that generate JULIA code related to ABI encoding, decoding and type conversions.
|
||||
* Routines that generate Yul code related to ABI encoding, decoding and type conversions.
|
||||
*/
|
||||
|
||||
#include <libsolidity/codegen/ABIFunctions.h>
|
||||
@ -989,7 +989,7 @@ string ABIFunctions::abiEncodingFunctionStringLiteral(
|
||||
)");
|
||||
templ("functionName", functionName);
|
||||
|
||||
// TODO this can make use of CODECOPY for large strings once we have that in JULIA
|
||||
// TODO this can make use of CODECOPY for large strings once we have that in Yul
|
||||
size_t words = (value.size() + 31) / 32;
|
||||
templ("overallSize", to_string(32 + words * 32));
|
||||
templ("length", to_string(value.size()));
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* @author Christian <chris@ethereum.org>
|
||||
* @date 2017
|
||||
* Routines that generate JULIA code related to ABI encoding, decoding and type conversions.
|
||||
* Routines that generate Yul code related to ABI encoding, decoding and type conversions.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -186,7 +186,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
|
||||
/// Stack: <source_offset> <length>
|
||||
if (m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2))
|
||||
{
|
||||
// Use the new JULIA-based decoding function
|
||||
// Use the new Yul-based decoding function
|
||||
auto stackHeightBefore = m_context.stackHeight();
|
||||
abiDecodeV2(_typeParameters, _fromMemory);
|
||||
solAssert(m_context.stackHeight() - stackHeightBefore == sizeOnStack(_typeParameters) - 2, "");
|
||||
@ -368,7 +368,7 @@ void CompilerUtils::encodeToMemory(
|
||||
m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)
|
||||
)
|
||||
{
|
||||
// Use the new JULIA-based encoding function
|
||||
// Use the new Yul-based encoding function
|
||||
auto stackHeightBefore = m_context.stackHeight();
|
||||
abiEncodeV2(_givenTypes, targetTypes, _encodeAsLibraryTypes);
|
||||
solAssert(stackHeightBefore - m_context.stackHeight() == sizeOnStack(_givenTypes), "");
|
||||
|
@ -99,7 +99,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
|
||||
}
|
||||
else if (_literal.kind == assembly::LiteralKind::Boolean)
|
||||
{
|
||||
solAssert(m_flavour == AsmFlavour::IULIA, "");
|
||||
solAssert(m_flavour == AsmFlavour::Yul, "");
|
||||
solAssert(_literal.value == "true" || _literal.value == "false", "");
|
||||
}
|
||||
m_info.stackHeightInfo[&_literal] = m_stackHeight;
|
||||
@ -162,7 +162,7 @@ bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier)
|
||||
|
||||
bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr)
|
||||
{
|
||||
solAssert(m_flavour != AsmFlavour::IULIA, "");
|
||||
solAssert(m_flavour != AsmFlavour::Yul, "");
|
||||
bool success = true;
|
||||
for (auto const& arg: _instr.arguments | boost::adaptors::reversed)
|
||||
if (!expectExpression(arg))
|
||||
@ -550,7 +550,7 @@ Scope& AsmAnalyzer::scope(Block const* _block)
|
||||
}
|
||||
void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _location)
|
||||
{
|
||||
if (m_flavour != AsmFlavour::IULIA)
|
||||
if (m_flavour != AsmFlavour::Yul)
|
||||
return;
|
||||
|
||||
if (!builtinTypes.count(type))
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
* Forward declaration of classes for inline assembly / JULIA AST
|
||||
* Forward declaration of classes for inline assembly / Yul AST
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -57,7 +57,7 @@ enum class AsmFlavour
|
||||
{
|
||||
Loose, // no types, EVM instructions as function, jumps and direct stack manipulations
|
||||
Strict, // no types, EVM instructions as functions, but no jumps and no direct stack manipulations
|
||||
IULIA // same as Strict mode with types
|
||||
Yul // same as Strict mode with types
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ assembly::Statement Parser::parseStatement()
|
||||
if (currentToken() == Token::Assign && peekNextToken() != Token::Colon)
|
||||
{
|
||||
assembly::Assignment assignment = createWithLocation<assembly::Assignment>(identifier.location);
|
||||
if (m_flavour != AsmFlavour::IULIA && instructions().count(identifier.name))
|
||||
if (m_flavour != AsmFlavour::Yul && instructions().count(identifier.name))
|
||||
fatalParserError("Cannot use instruction names for identifier names.");
|
||||
advance();
|
||||
assignment.variableNames.emplace_back(identifier);
|
||||
@ -357,7 +357,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
|
||||
else
|
||||
literal = currentLiteral();
|
||||
// first search the set of instructions.
|
||||
if (m_flavour != AsmFlavour::IULIA && instructions().count(literal))
|
||||
if (m_flavour != AsmFlavour::Yul && instructions().count(literal))
|
||||
{
|
||||
dev::solidity::Instruction const& instr = instructions().at(literal);
|
||||
ret = Instruction{location(), instr};
|
||||
@ -398,7 +398,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
|
||||
""
|
||||
};
|
||||
advance();
|
||||
if (m_flavour == AsmFlavour::IULIA)
|
||||
if (m_flavour == AsmFlavour::Yul)
|
||||
{
|
||||
expectToken(Token::Colon);
|
||||
literal.location.end = endPosition();
|
||||
@ -411,7 +411,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
|
||||
}
|
||||
default:
|
||||
fatalParserError(
|
||||
m_flavour == AsmFlavour::IULIA ?
|
||||
m_flavour == AsmFlavour::Yul ?
|
||||
"Literal or identifier expected." :
|
||||
"Literal, identifier or instruction expected."
|
||||
);
|
||||
@ -481,7 +481,7 @@ assembly::Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
|
||||
RecursionGuard recursionGuard(*this);
|
||||
if (_initialOp.type() == typeid(Instruction))
|
||||
{
|
||||
solAssert(m_flavour != AsmFlavour::IULIA, "Instructions are invalid in JULIA");
|
||||
solAssert(m_flavour != AsmFlavour::Yul, "Instructions are invalid in Yul");
|
||||
Instruction& instruction = boost::get<Instruction>(_initialOp);
|
||||
FunctionalInstruction ret;
|
||||
ret.instruction = instruction.instruction;
|
||||
@ -552,7 +552,7 @@ assembly::Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
|
||||
}
|
||||
else
|
||||
fatalParserError(
|
||||
m_flavour == AsmFlavour::IULIA ?
|
||||
m_flavour == AsmFlavour::Yul ?
|
||||
"Function name expected." :
|
||||
"Assembly instruction or function name required in front of \"(\")"
|
||||
);
|
||||
@ -565,7 +565,7 @@ TypedName Parser::parseTypedName()
|
||||
RecursionGuard recursionGuard(*this);
|
||||
TypedName typedName = createWithLocation<TypedName>();
|
||||
typedName.name = expectAsmIdentifier();
|
||||
if (m_flavour == AsmFlavour::IULIA)
|
||||
if (m_flavour == AsmFlavour::Yul)
|
||||
{
|
||||
expectToken(Token::Colon);
|
||||
typedName.location.end = endPosition();
|
||||
@ -577,7 +577,7 @@ TypedName Parser::parseTypedName()
|
||||
string Parser::expectAsmIdentifier()
|
||||
{
|
||||
string name = currentLiteral();
|
||||
if (m_flavour == AsmFlavour::IULIA)
|
||||
if (m_flavour == AsmFlavour::Yul)
|
||||
{
|
||||
switch (currentToken())
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ using namespace dev::solidity::assembly;
|
||||
|
||||
string AsmPrinter::operator()(assembly::Instruction const& _instruction)
|
||||
{
|
||||
solAssert(!m_julia, "");
|
||||
solAssert(!m_yul, "");
|
||||
return boost::to_lower_copy(instructionInfo(_instruction.instruction).name);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ string AsmPrinter::operator()(assembly::Identifier const& _identifier)
|
||||
|
||||
string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functionalInstruction)
|
||||
{
|
||||
solAssert(!m_julia, "");
|
||||
solAssert(!m_yul, "");
|
||||
return
|
||||
boost::to_lower_copy(instructionInfo(_functionalInstruction.instruction).name) +
|
||||
"(" +
|
||||
@ -109,13 +109,13 @@ string AsmPrinter::operator()(ExpressionStatement const& _statement)
|
||||
|
||||
string AsmPrinter::operator()(assembly::Label const& _label)
|
||||
{
|
||||
solAssert(!m_julia, "");
|
||||
solAssert(!m_yul, "");
|
||||
return _label.name + ":";
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(assembly::StackAssignment const& _assignment)
|
||||
{
|
||||
solAssert(!m_julia, "");
|
||||
solAssert(!m_yul, "");
|
||||
return "=: " + (*this)(_assignment.variableName);
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ string AsmPrinter::operator()(Block const& _block)
|
||||
|
||||
string AsmPrinter::appendTypeName(std::string const& _type) const
|
||||
{
|
||||
if (m_julia)
|
||||
if (m_yul)
|
||||
return ":" + _type;
|
||||
return "";
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace assembly
|
||||
class AsmPrinter: public boost::static_visitor<std::string>
|
||||
{
|
||||
public:
|
||||
explicit AsmPrinter(bool _julia = false): m_julia(_julia) {}
|
||||
explicit AsmPrinter(bool _yul = false): m_yul(_yul) {}
|
||||
|
||||
std::string operator()(assembly::Instruction const& _instruction);
|
||||
std::string operator()(assembly::Literal const& _literal);
|
||||
@ -57,7 +57,7 @@ public:
|
||||
private:
|
||||
std::string appendTypeName(std::string const& _type) const;
|
||||
|
||||
bool m_julia = false;
|
||||
bool m_yul = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ bool Scope::registerLabel(string const& _name)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Scope::registerVariable(string const& _name, JuliaType const& _type)
|
||||
bool Scope::registerVariable(string const& _name, YulType const& _type)
|
||||
{
|
||||
if (exists(_name))
|
||||
return false;
|
||||
@ -42,7 +42,7 @@ bool Scope::registerVariable(string const& _name, JuliaType const& _type)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Scope::registerFunction(string const& _name, std::vector<JuliaType> const& _arguments, std::vector<JuliaType> const& _returns)
|
||||
bool Scope::registerFunction(string const& _name, std::vector<YulType> const& _arguments, std::vector<YulType> const& _returns)
|
||||
{
|
||||
if (exists(_name))
|
||||
return false;
|
||||
|
@ -62,27 +62,27 @@ struct GenericVisitor<>: public boost::static_visitor<> {
|
||||
|
||||
struct Scope
|
||||
{
|
||||
using JuliaType = std::string;
|
||||
using YulType = std::string;
|
||||
using LabelID = size_t;
|
||||
|
||||
struct Variable { JuliaType type; };
|
||||
struct Variable { YulType type; };
|
||||
struct Label { };
|
||||
struct Function
|
||||
{
|
||||
std::vector<JuliaType> arguments;
|
||||
std::vector<JuliaType> returns;
|
||||
std::vector<YulType> arguments;
|
||||
std::vector<YulType> returns;
|
||||
};
|
||||
|
||||
using Identifier = boost::variant<Variable, Label, Function>;
|
||||
using Visitor = GenericVisitor<Variable const, Label const, Function const>;
|
||||
using NonconstVisitor = GenericVisitor<Variable, Label, Function>;
|
||||
|
||||
bool registerVariable(std::string const& _name, JuliaType const& _type);
|
||||
bool registerVariable(std::string const& _name, YulType const& _type);
|
||||
bool registerLabel(std::string const& _name);
|
||||
bool registerFunction(
|
||||
std::string const& _name,
|
||||
std::vector<JuliaType> const& _arguments,
|
||||
std::vector<JuliaType> const& _returns
|
||||
std::vector<YulType> const& _arguments,
|
||||
std::vector<YulType> const& _returns
|
||||
);
|
||||
|
||||
/// Looks up the identifier in this or super scopes and returns a valid pointer if found
|
||||
|
@ -75,10 +75,10 @@ bool ScopeFiller::operator()(assembly::VariableDeclaration const& _varDecl)
|
||||
bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef)
|
||||
{
|
||||
bool success = true;
|
||||
vector<Scope::JuliaType> arguments;
|
||||
vector<Scope::YulType> arguments;
|
||||
for (auto const& _argument: _funDef.parameters)
|
||||
arguments.push_back(_argument.type);
|
||||
vector<Scope::JuliaType> returns;
|
||||
vector<Scope::YulType> returns;
|
||||
for (auto const& _return: _funDef.returnVariables)
|
||||
returns.push_back(_return.type);
|
||||
if (!m_currentScope->registerFunction(_funDef.name, arguments, returns))
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
|
||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||
* eWasm as output.
|
||||
*/
|
||||
|
||||
@ -48,11 +48,11 @@ assembly::AsmFlavour languageToAsmFlavour(AssemblyStack::Language _language)
|
||||
return assembly::AsmFlavour::Loose;
|
||||
case AssemblyStack::Language::StrictAssembly:
|
||||
return assembly::AsmFlavour::Strict;
|
||||
case AssemblyStack::Language::JULIA:
|
||||
return assembly::AsmFlavour::IULIA;
|
||||
case AssemblyStack::Language::Yul:
|
||||
return assembly::AsmFlavour::Yul;
|
||||
}
|
||||
solAssert(false, "");
|
||||
return assembly::AsmFlavour::IULIA;
|
||||
return assembly::AsmFlavour::Yul;
|
||||
}
|
||||
|
||||
}
|
||||
@ -117,7 +117,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
||||
{
|
||||
MachineAssemblyObject object;
|
||||
julia::EVMAssembly assembly(true);
|
||||
julia::CodeTransform(assembly, *m_analysisInfo, m_language == Language::JULIA, true)(*m_parserResult);
|
||||
julia::CodeTransform(assembly, *m_analysisInfo, m_language == Language::Yul, true)(*m_parserResult);
|
||||
object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize());
|
||||
/// TOOD: fill out text representation
|
||||
return object;
|
||||
@ -132,5 +132,5 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
||||
string AssemblyStack::print() const
|
||||
{
|
||||
solAssert(m_parserResult, "");
|
||||
return assembly::AsmPrinter(m_language == Language::JULIA)(*m_parserResult);
|
||||
return assembly::AsmPrinter(m_language == Language::Yul)(*m_parserResult);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
|
||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||
* eWasm as output.
|
||||
*/
|
||||
|
||||
@ -47,13 +47,13 @@ struct MachineAssemblyObject
|
||||
};
|
||||
|
||||
/*
|
||||
* Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
|
||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||
* eWasm as output.
|
||||
*/
|
||||
class AssemblyStack
|
||||
{
|
||||
public:
|
||||
enum class Language { JULIA, Assembly, StrictAssembly };
|
||||
enum class Language { Yul, Assembly, StrictAssembly };
|
||||
enum class Machine { EVM, EVM15, eWasm };
|
||||
|
||||
explicit AssemblyStack(EVMVersion _evmVersion = EVMVersion(), Language _language = Language::Assembly):
|
||||
|
@ -787,7 +787,7 @@ bool CommandLineInterface::processInput()
|
||||
m_onlyAssemble = true;
|
||||
using Input = AssemblyStack::Language;
|
||||
using Machine = AssemblyStack::Machine;
|
||||
Input inputLanguage = m_args.count(g_argYul) ? Input::JULIA : (m_args.count(g_argStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
|
||||
Input inputLanguage = m_args.count(g_argYul) ? Input::Yul : (m_args.count(g_argStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
|
||||
Machine targetMachine = Machine::EVM;
|
||||
if (m_args.count(g_argMachine))
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
/**
|
||||
* @date 2017
|
||||
* Common functions the iulia tests.
|
||||
* Common functions the Yul tests.
|
||||
*/
|
||||
|
||||
#include <test/libjulia/Common.h>
|
||||
@ -52,9 +52,9 @@ void dev::julia::test::printErrors(ErrorList const& _errors, Scanner const& _sca
|
||||
}
|
||||
|
||||
|
||||
pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test::parse(string const& _source, bool _julia)
|
||||
pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test::parse(string const& _source, bool _yul)
|
||||
{
|
||||
auto flavour = _julia ? assembly::AsmFlavour::IULIA : assembly::AsmFlavour::Strict;
|
||||
auto flavour = _yul ? assembly::AsmFlavour::Yul : assembly::AsmFlavour::Strict;
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
auto scanner = make_shared<Scanner>(CharStream(_source), "");
|
||||
@ -83,13 +83,13 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test:
|
||||
return {};
|
||||
}
|
||||
|
||||
assembly::Block dev::julia::test::disambiguate(string const& _source, bool _julia)
|
||||
assembly::Block dev::julia::test::disambiguate(string const& _source, bool _yul)
|
||||
{
|
||||
auto result = parse(_source, _julia);
|
||||
auto result = parse(_source, _yul);
|
||||
return boost::get<Block>(Disambiguator(*result.second)(*result.first));
|
||||
}
|
||||
|
||||
string dev::julia::test::format(string const& _source, bool _julia)
|
||||
string dev::julia::test::format(string const& _source, bool _yul)
|
||||
{
|
||||
return assembly::AsmPrinter(_julia)(*parse(_source, _julia).first);
|
||||
return assembly::AsmPrinter(_yul)(*parse(_source, _yul).first);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
/**
|
||||
* @date 2017
|
||||
* Common functions the iulia tests.
|
||||
* Common functions the Yul tests.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -46,9 +46,9 @@ namespace test
|
||||
|
||||
void printErrors(solidity::ErrorList const& _errors, solidity::Scanner const& _scanner);
|
||||
std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>>
|
||||
parse(std::string const& _source, bool _julia = true);
|
||||
solidity::assembly::Block disambiguate(std::string const& _source, bool _julia = true);
|
||||
std::string format(std::string const& _source, bool _julia = true);
|
||||
parse(std::string const& _source, bool _yul = true);
|
||||
solidity::assembly::Block disambiguate(std::string const& _source, bool _yul = true);
|
||||
std::string format(std::string const& _source, bool _yul = true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
/**
|
||||
* @date 2017
|
||||
* Unit tests for the iulia name disambiguator.
|
||||
* Unit tests for the Yul name disambiguator.
|
||||
*/
|
||||
|
||||
#include <test/libjulia/Common.h>
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
/**
|
||||
* @date 2017
|
||||
* Unit tests for parsing Julia.
|
||||
* Unit tests for parsing Yul.
|
||||
*/
|
||||
|
||||
#include <test/Options.h>
|
||||
@ -52,7 +52,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
|
||||
try
|
||||
{
|
||||
auto scanner = make_shared<Scanner>(CharStream(_source));
|
||||
auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::IULIA).parse(scanner, false);
|
||||
auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::Yul).parse(scanner, false);
|
||||
if (parserResult)
|
||||
{
|
||||
assembly::AsmAnalysisInfo analysisInfo;
|
||||
@ -61,7 +61,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
|
||||
errorReporter,
|
||||
dev::test::Options::get().evmVersion(),
|
||||
boost::none,
|
||||
assembly::AsmFlavour::IULIA
|
||||
assembly::AsmFlavour::Yul
|
||||
)).analyze(*parserResult);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user