Simple aliasing during import.

This commit is contained in:
chriseth
2015-12-18 12:46:56 +01:00
parent d3c459b5a9
commit 603dc58040
10 changed files with 148 additions and 52 deletions
+5 -3
View File
@@ -111,7 +111,8 @@ private:
/// Maps nodes declaring a scope to scopes, i.e. ContractDefinition and FunctionDeclaration,
/// where nullptr denotes the global scope. Note that structs are not scope since they do
/// not contain code.
std::map<ASTNode const*, std::unique_ptr<DeclarationContainer>> m_scopes;
/// Aliases (for example `import "x" as y;`) create multiple pointers to the same scope.
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
DeclarationContainer* m_currentScope = nullptr;
ErrorList& m_errors;
@@ -125,12 +126,13 @@ class DeclarationRegistrationHelper: private ASTVisitor
{
public:
DeclarationRegistrationHelper(
std::map<ASTNode const*, std::unique_ptr<DeclarationContainer>>& _scopes,
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
ASTNode& _astRoot,
ErrorList& _errors
);
private:
bool visit(ImportDirective& _declaration) override;
bool visit(ContractDefinition& _contract) override;
void endVisit(ContractDefinition& _contract) override;
bool visit(StructDefinition& _struct) override;
@@ -166,7 +168,7 @@ private:
// creates the Declaration error and adds it in the errors list and throws FatalError
void fatalDeclarationError(SourceLocation _sourceLocation, std::string const& _description);
std::map<ASTNode const*, std::unique_ptr<DeclarationContainer>>& m_scopes;
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
ASTNode const* m_currentScope = nullptr;
VariableScope* m_currentFunction = nullptr;
ErrorList& m_errors;