aboutsummaryrefslogtreecommitdiffstats
path: root/NameAndTypeResolver.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-10-30 08:20:32 +0800
committerChristian <c@ethdev.com>2014-10-30 08:25:42 +0800
commit7f19f3d133b74bd7ebc96d18b09e145417b7daac (patch)
treea344a8faf9675882eb42f4f83e57f3a825844dcf /NameAndTypeResolver.h
parent51349bdae53e7d495732085c446ff9488473dcc8 (diff)
downloaddexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.tar.gz
dexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.tar.zst
dexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.zip
Contract compiler and also add ExpressionStatement to AST.
ExpressionStatement functions as glue between Statements and Expressions. This way it is possible to detect when the border between statements and expressions is crossed while walking the AST. Note that ExpressionStatement is not the only border, almost every statement can contains expressions.
Diffstat (limited to 'NameAndTypeResolver.h')
-rw-r--r--NameAndTypeResolver.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/NameAndTypeResolver.h b/NameAndTypeResolver.h
index 7abcbb0c..cdc334a6 100644
--- a/NameAndTypeResolver.h
+++ b/NameAndTypeResolver.h
@@ -41,6 +41,14 @@ public:
NameAndTypeResolver() {}
void resolveNamesAndTypes(ContractDefinition& _contract);
+
+ /// Resolves the given @a _name inside the scope @a _scope. If @a _scope is omitted,
+ /// the global scope is used (i.e. the one containing only the contract).
+ /// @returns a pointer to the declaration on success or nullptr on failure.
+ Declaration* resolveName(ASTString const& _name, Declaration const* _scope = nullptr) const;
+
+ /// Resolves a name in the "current" scope. Should only be called during the initial
+ /// resolving phase.
Declaration* getNameFromCurrentScope(ASTString const& _name, bool _recursive = true);
private:
@@ -48,7 +56,7 @@ private:
//! Maps nodes declaring a scope to scopes, i.e. ContractDefinition, FunctionDeclaration and
//! StructDefinition (@todo not yet implemented), where nullptr denotes the global scope.
- std::map<ASTNode*, Scope> m_scopes;
+ std::map<ASTNode const*, Scope> m_scopes;
Scope* m_currentScope;
};
@@ -58,7 +66,7 @@ private:
class DeclarationRegistrationHelper: private ASTVisitor
{
public:
- DeclarationRegistrationHelper(std::map<ASTNode*, Scope>& _scopes, ASTNode& _astRoot);
+ DeclarationRegistrationHelper(std::map<ASTNode const*, Scope>& _scopes, ASTNode& _astRoot);
private:
bool visit(ContractDefinition& _contract);
@@ -67,15 +75,16 @@ private:
void endVisit(StructDefinition& _struct);
bool visit(FunctionDefinition& _function);
void endVisit(FunctionDefinition& _function);
+ void endVisit(VariableDefinition& _variableDefinition);
bool visit(VariableDeclaration& _declaration);
- void endVisit(VariableDeclaration& _declaration);
void enterNewSubScope(ASTNode& _node);
void closeCurrentScope();
void registerDeclaration(Declaration& _declaration, bool _opensScope);
- std::map<ASTNode*, Scope>& m_scopes;
+ std::map<ASTNode const*, Scope>& m_scopes;
Scope* m_currentScope;
+ FunctionDefinition* m_currentFunction;
};
//! Resolves references to declarations (of variables and types) and also establishes the link