aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-18 11:38:05 +0800
committerJimmy Hu <jimmy.hu@dexon.org>2019-04-13 20:54:32 +0800
commit500ab821044759594eb3db08876b2925b9b3709b (patch)
tree72da52de9a7e22509b210a70e92430beb143bcae /libsolidity/codegen
parent0957231a8ed1990baacd67f48c3d3550b5250733 (diff)
downloaddexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.gz
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.bz2
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.lz
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.xz
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.zst
dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.zip
Add opcode RAND support
DEXON has a built-in on chain random oracle that allow one to retrieve a random variable. Add `rand` solidity variable is introduced to load the random variable onto the stack.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp8
1 files changed, 7 insertions, 1 deletions
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;