aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/GlobalContext.cpp1
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp8
3 files changed, 9 insertions, 2 deletions
diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp
index 2276d783..48489b6b 100644
--- a/libsolidity/analysis/GlobalContext.cpp
+++ b/libsolidity/analysis/GlobalContext.cpp
@@ -52,6 +52,7 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{
make_shared<MagicVariableDeclaration>("msg", make_shared<MagicType>(MagicType::Kind::Message)),
make_shared<MagicVariableDeclaration>("mulmod", make_shared<FunctionType>(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::MulMod, false, StateMutability::Pure)),
make_shared<MagicVariableDeclaration>("now", make_shared<IntegerType>(256)),
+ make_shared<MagicVariableDeclaration>("rand", make_shared<IntegerType>(256)),
make_shared<MagicVariableDeclaration>("require", make_shared<FunctionType>(strings{"bool"}, strings{}, FunctionType::Kind::Require, false, StateMutability::Pure)),
make_shared<MagicVariableDeclaration>("require", make_shared<FunctionType>(strings{"bool", "string memory"}, strings{}, FunctionType::Kind::Require, false, StateMutability::Pure)),
make_shared<MagicVariableDeclaration>("revert", make_shared<FunctionType>(strings(), strings(), FunctionType::Kind::Revert, false, StateMutability::Pure)),
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 7df7ac17..0ffe6a6a 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -201,7 +201,7 @@ void ViewPureChecker::endVisit(Identifier const& _identifier)
mutability = StateMutability::View;
break;
case Type::Category::Integer:
- solAssert(_identifier.name() == "now", "");
+ solAssert(_identifier.name() == "now" || _identifier.name() == "rand", "");
mutability = StateMutability::View;
break;
default:
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index e6bb163d..46a335bb 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1314,6 +1314,8 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
m_context << Instruction::COINBASE;
else if (member == "timestamp")
m_context << Instruction::TIMESTAMP;
+ else if (member == "rand")
+ m_context << Instruction::RAND;
else if (member == "difficulty")
m_context << Instruction::DIFFICULTY;
else if (member == "number")
@@ -1558,7 +1560,11 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier)
break;
case Type::Category::Integer:
// "now"
- m_context << Instruction::TIMESTAMP;
+ if (_identifier.name() == "now") {
+ m_context << Instruction::TIMESTAMP;
+ } else if (_identifier.name() == "rand") {
+ m_context << Instruction::RAND;
+ }
break;
default:
break;