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>2018-11-09 13:31:14 +0800
commit433aebb7c91acf6d364acd76f6018dc1b4f847af (patch)
tree755cb38bb4ec4c873cc86c537200d4cfa1b1b83f /libsolidity/codegen
parent91c1c3ada94f983f71938fba5abb570207acc248 (diff)
downloaddexon-solidity-0.4.25.tar
dexon-solidity-0.4.25.tar.gz
dexon-solidity-0.4.25.tar.bz2
dexon-solidity-0.4.25.tar.lz
dexon-solidity-0.4.25.tar.xz
dexon-solidity-0.4.25.tar.zst
dexon-solidity-0.4.25.zip
Add opcode RAND supportv0.4.25
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 f38c1e67..0a6ce940 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1265,6 +1265,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")
@@ -1491,7 +1493,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;