diff options
author | chriseth <c@ethdev.com> | 2015-03-10 02:22:43 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-10 02:22:43 +0800 |
commit | 9c82cbeddf1b03cc99660a867de8720d1d174b9c (patch) | |
tree | 3efc5371eb10398627ec8e1ea05d734783b50f85 /ExpressionCompiler.cpp | |
parent | cd8a0ab65d387cd88f3062f937a456b7c0e33b5c (diff) | |
download | dexon-solidity-9c82cbeddf1b03cc99660a867de8720d1d174b9c.tar.gz dexon-solidity-9c82cbeddf1b03cc99660a867de8720d1d174b9c.tar.zst dexon-solidity-9c82cbeddf1b03cc99660a867de8720d1d174b9c.zip |
Global variable "now" (alias for block.timestamp).
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index b02aecf5..d2457e67 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -825,10 +825,20 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) Declaration const* declaration = _identifier.getReferencedDeclaration(); if (MagicVariableDeclaration const* magicVar = dynamic_cast<MagicVariableDeclaration const*>(declaration)) { - if (magicVar->getType()->getCategory() == Type::Category::Contract) + switch (magicVar->getType()->getCategory()) + { + case Type::Category::Contract: // "this" or "super" if (!dynamic_cast<ContractType const&>(*magicVar->getType()).isSuper()) m_context << eth::Instruction::ADDRESS; + break; + case Type::Category::Integer: + // "now" + m_context << eth::Instruction::TIMESTAMP; + break; + default: + break; + } } else if (FunctionDefinition const* functionDef = dynamic_cast<FunctionDefinition const*>(declaration)) m_context << m_context.getVirtualFunctionEntryLabel(*functionDef).pushTag(); |