mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
- renamed AST to ast and ABI to abi
- style fixes
This commit is contained in:
parent
02d4198242
commit
df8c82bc60
@ -112,8 +112,10 @@ map<FixedHash<4>, FunctionTypePointer> ContractDefinition::interfaceFunctions()
|
|||||||
for (auto const& it: exportedFunctionList)
|
for (auto const& it: exportedFunctionList)
|
||||||
exportedFunctions.insert(it);
|
exportedFunctions.insert(it);
|
||||||
|
|
||||||
solAssert(exportedFunctionList.size() == exportedFunctions.size(),
|
solAssert(
|
||||||
"Hash collision at Function Definition Hash calculation");
|
exportedFunctionList.size() == exportedFunctions.size(),
|
||||||
|
"Hash collision at Function Definition Hash calculation"
|
||||||
|
);
|
||||||
|
|
||||||
return exportedFunctions;
|
return exportedFunctions;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
|||||||
return *source(_sourceName).scanner;
|
return *source(_sourceName).scanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceUnit const& CompilerStack::AST(string const& _sourceName) const
|
SourceUnit const& CompilerStack::ast(string const& _sourceName) const
|
||||||
{
|
{
|
||||||
return *source(_sourceName).ast;
|
return *source(_sourceName).ast;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public:
|
|||||||
/// @returns the previously used scanner, useful for counting lines during error reporting.
|
/// @returns the previously used scanner, useful for counting lines during error reporting.
|
||||||
Scanner const& scanner(std::string const& _sourceName = "") const;
|
Scanner const& scanner(std::string const& _sourceName = "") const;
|
||||||
/// @returns the parsed source unit with the supplied name.
|
/// @returns the parsed source unit with the supplied name.
|
||||||
SourceUnit const& AST(std::string const& _sourceName = "") const;
|
SourceUnit const& ast(std::string const& _sourceName = "") const;
|
||||||
/// @returns the parsed contract with the supplied name. Throws an exception if the contract
|
/// @returns the parsed contract with the supplied name. Throws an exception if the contract
|
||||||
/// does not exist.
|
/// does not exist.
|
||||||
ContractDefinition const& contractDefinition(std::string const& _contractName) const;
|
ContractDefinition const& contractDefinition(std::string const& _contractName) const;
|
||||||
|
@ -28,7 +28,7 @@ string InterfaceHandler::documentation(
|
|||||||
case DocumentationType::NatspecDev:
|
case DocumentationType::NatspecDev:
|
||||||
return devDocumentation(_contractDef);
|
return devDocumentation(_contractDef);
|
||||||
case DocumentationType::ABIInterface:
|
case DocumentationType::ABIInterface:
|
||||||
return ABIInterface(_contractDef);
|
return abiInterface(_contractDef);
|
||||||
case DocumentationType::ABISolidityInterface:
|
case DocumentationType::ABISolidityInterface:
|
||||||
return ABISolidityInterface(_contractDef);
|
return ABISolidityInterface(_contractDef);
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ string InterfaceHandler::documentation(
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
string InterfaceHandler::ABIInterface(ContractDefinition const& _contractDef)
|
string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef)
|
||||||
{
|
{
|
||||||
Json::Value abi(Json::arrayValue);
|
Json::Value abi(Json::arrayValue);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
/// Get the ABI Interface of the contract
|
/// Get the ABI Interface of the contract
|
||||||
/// @param _contractDef The contract definition
|
/// @param _contractDef The contract definition
|
||||||
/// @return A string with the json representation of the contract's ABI Interface
|
/// @return A string with the json representation of the contract's ABI Interface
|
||||||
std::string ABIInterface(ContractDefinition const& _contractDef);
|
std::string abiInterface(ContractDefinition const& _contractDef);
|
||||||
std::string ABISolidityInterface(ContractDefinition const& _contractDef);
|
std::string ABISolidityInterface(ContractDefinition const& _contractDef);
|
||||||
/// Get the User documentation of the contract
|
/// Get the User documentation of the contract
|
||||||
/// @param _contractDef The contract definition
|
/// @param _contractDef The contract definition
|
||||||
|
@ -80,7 +80,9 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
{
|
{
|
||||||
m_currentScope = &m_scopes[function.get()];
|
m_currentScope = &m_scopes[function.get()];
|
||||||
ReferencesResolver referencesResolver(
|
ReferencesResolver referencesResolver(
|
||||||
*function, *this, &_contract,
|
*function,
|
||||||
|
*this,
|
||||||
|
&_contract,
|
||||||
function->returnParameterList().get()
|
function->returnParameterList().get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -139,16 +139,19 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Token::Value currentTokenValue= m_scanner->currentToken();
|
Token::Value currentTokenValue= m_scanner->currentToken();
|
||||||
if (currentTokenValue== Token::RBrace)
|
if (currentTokenValue == Token::RBrace)
|
||||||
break;
|
break;
|
||||||
else if (currentTokenValue== Token::Function)
|
else if (currentTokenValue == Token::Function)
|
||||||
functions.push_back(parseFunctionDefinition(name.get()));
|
functions.push_back(parseFunctionDefinition(name.get()));
|
||||||
else if (currentTokenValue== Token::Struct)
|
else if (currentTokenValue == Token::Struct)
|
||||||
structs.push_back(parseStructDefinition());
|
structs.push_back(parseStructDefinition());
|
||||||
else if (currentTokenValue== Token::Enum)
|
else if (currentTokenValue == Token::Enum)
|
||||||
enums.push_back(parseEnumDefinition());
|
enums.push_back(parseEnumDefinition());
|
||||||
else if (currentTokenValue== Token::Identifier || currentTokenValue== Token::Mapping ||
|
else if (
|
||||||
Token::isElementaryTypeName(currentTokenValue))
|
currentTokenValue == Token::Identifier ||
|
||||||
|
currentTokenValue == Token::Mapping ||
|
||||||
|
Token::isElementaryTypeName(currentTokenValue)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
VarDeclParserOptions options;
|
VarDeclParserOptions options;
|
||||||
options.isStateVariable = true;
|
options.isStateVariable = true;
|
||||||
@ -156,9 +159,9 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
|
|||||||
stateVariables.push_back(parseVariableDeclaration(options));
|
stateVariables.push_back(parseVariableDeclaration(options));
|
||||||
expectToken(Token::Semicolon);
|
expectToken(Token::Semicolon);
|
||||||
}
|
}
|
||||||
else if (currentTokenValue== Token::Modifier)
|
else if (currentTokenValue == Token::Modifier)
|
||||||
modifiers.push_back(parseModifierDefinition());
|
modifiers.push_back(parseModifierDefinition());
|
||||||
else if (currentTokenValue== Token::Event)
|
else if (currentTokenValue == Token::Event)
|
||||||
events.push_back(parseEventDefinition());
|
events.push_back(parseEventDefinition());
|
||||||
else
|
else
|
||||||
BOOST_THROW_EXCEPTION(createParserError("Function, variable, struct or modifier declaration expected."));
|
BOOST_THROW_EXCEPTION(createParserError("Function, variable, struct or modifier declaration expected."));
|
||||||
|
@ -522,7 +522,7 @@ void CommandLineInterface::handleCombinedJSON()
|
|||||||
output["sources"] = Json::Value(Json::objectValue);
|
output["sources"] = Json::Value(Json::objectValue);
|
||||||
for (auto const& sourceCode: m_sourceCodes)
|
for (auto const& sourceCode: m_sourceCodes)
|
||||||
{
|
{
|
||||||
ASTJsonConverter converter(m_compiler->AST(sourceCode.first));
|
ASTJsonConverter converter(m_compiler->ast(sourceCode.first));
|
||||||
output["sources"][sourceCode.first] = Json::Value(Json::objectValue);
|
output["sources"][sourceCode.first] = Json::Value(Json::objectValue);
|
||||||
output["sources"][sourceCode.first]["AST"] = converter.json();
|
output["sources"][sourceCode.first]["AST"] = converter.json();
|
||||||
}
|
}
|
||||||
@ -546,7 +546,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
|
|||||||
{
|
{
|
||||||
vector<ASTNode const*> asts;
|
vector<ASTNode const*> asts;
|
||||||
for (auto const& sourceCode: m_sourceCodes)
|
for (auto const& sourceCode: m_sourceCodes)
|
||||||
asts.push_back(&m_compiler->AST(sourceCode.first));
|
asts.push_back(&m_compiler->ast(sourceCode.first));
|
||||||
map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
|
map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
|
||||||
if (m_compiler->runtimeAssemblyItems())
|
if (m_compiler->runtimeAssemblyItems())
|
||||||
gasCosts = GasEstimator::breakToStatementLevel(
|
gasCosts = GasEstimator::breakToStatementLevel(
|
||||||
@ -562,12 +562,12 @@ void CommandLineInterface::handleAst(string const& _argStr)
|
|||||||
string postfix = "";
|
string postfix = "";
|
||||||
if (_argStr == g_argAstStr)
|
if (_argStr == g_argAstStr)
|
||||||
{
|
{
|
||||||
ASTPrinter printer(m_compiler->AST(sourceCode.first), sourceCode.second);
|
ASTPrinter printer(m_compiler->ast(sourceCode.first), sourceCode.second);
|
||||||
printer.print(data);
|
printer.print(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASTJsonConverter converter(m_compiler->AST(sourceCode.first));
|
ASTJsonConverter converter(m_compiler->ast(sourceCode.first));
|
||||||
converter.print(data);
|
converter.print(data);
|
||||||
postfix += "_json";
|
postfix += "_json";
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
|
|||||||
if (_argStr == g_argAstStr)
|
if (_argStr == g_argAstStr)
|
||||||
{
|
{
|
||||||
ASTPrinter printer(
|
ASTPrinter printer(
|
||||||
m_compiler->AST(sourceCode.first),
|
m_compiler->ast(sourceCode.first),
|
||||||
sourceCode.second,
|
sourceCode.second,
|
||||||
gasCosts
|
gasCosts
|
||||||
);
|
);
|
||||||
@ -592,7 +592,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASTJsonConverter converter(m_compiler->AST(sourceCode.first));
|
ASTJsonConverter converter(m_compiler->ast(sourceCode.first));
|
||||||
converter.print(cout);
|
converter.print(cout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ string compile(string _input, bool _optimize)
|
|||||||
|
|
||||||
output["sources"] = Json::Value(Json::objectValue);
|
output["sources"] = Json::Value(Json::objectValue);
|
||||||
output["sources"][""] = Json::Value(Json::objectValue);
|
output["sources"][""] = Json::Value(Json::objectValue);
|
||||||
output["sources"][""]["AST"] = ASTJsonConverter(compiler.AST("")).json();
|
output["sources"][""]["AST"] = ASTJsonConverter(compiler.ast("")).json();
|
||||||
|
|
||||||
return Json::FastWriter().write(output);
|
return Json::FastWriter().write(output);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
|
ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
|
||||||
|
|
||||||
AssemblyItems const* items = m_compiler.runtimeAssemblyItems("");
|
AssemblyItems const* items = m_compiler.runtimeAssemblyItems("");
|
||||||
ASTNode const& sourceUnit = m_compiler.AST();
|
ASTNode const& sourceUnit = m_compiler.ast();
|
||||||
BOOST_REQUIRE(items != nullptr);
|
BOOST_REQUIRE(items != nullptr);
|
||||||
m_gasCosts = GasEstimator::breakToStatementLevel(
|
m_gasCosts = GasEstimator::breakToStatementLevel(
|
||||||
GasEstimator::structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
|
GasEstimator::structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
|
||||||
|
Loading…
Reference in New Issue
Block a user