diff options
author | Christian <c@ethdev.com> | 2014-11-05 02:13:03 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-06 09:36:39 +0800 |
commit | 13baaf98b8a3ca2a97c96e5a25398a0cae26e5fb (patch) | |
tree | 79a400acba06f1d3c43885bda0c2f69c2e809ed5 /ExpressionCompiler.h | |
parent | 4b6c42231595cd8a53327656db4ac22db70960d5 (diff) | |
download | dexon-solidity-13baaf98b8a3ca2a97c96e5a25398a0cae26e5fb.tar.gz dexon-solidity-13baaf98b8a3ca2a97c96e5a25398a0cae26e5fb.tar.zst dexon-solidity-13baaf98b8a3ca2a97c96e5a25398a0cae26e5fb.zip |
Proper type promotion and conversion.
Diffstat (limited to 'ExpressionCompiler.h')
-rw-r--r-- | ExpressionCompiler.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ExpressionCompiler.h b/ExpressionCompiler.h index a930723c..7c731ec7 100644 --- a/ExpressionCompiler.h +++ b/ExpressionCompiler.h @@ -26,6 +26,8 @@ namespace dev { namespace solidity { class CompilerContext; // forward +class Type; // forward +class IntegerType; // forward /// Compiler for expressions, i.e. converts an AST tree whose root is an Expression into a stream /// of EVM instructions. It needs a compiler context that is the same for the whole compilation @@ -37,7 +39,7 @@ public: static void compileExpression(CompilerContext& _context, Expression& _expression); /// Appends code to remove dirty higher order bits in case of an implicit promotion to a wider type. - static void cleanHigherOrderBitsIfNeeded(Type const& _typeOnStack, Type const& _targetType); + static void appendTypeConversion(CompilerContext& _context, Type const& _typeOnStack, Type const& _targetType); private: ExpressionCompiler(CompilerContext& _compilerContext): m_currentLValue(nullptr), m_context(_compilerContext) {} @@ -62,6 +64,12 @@ private: void appendShiftOperatorCode(Token::Value _operator); /// @} + /// Appends an implicit or explicit type conversion. For now this comprises only erasing + /// higher-order bits (@see appendHighBitCleanup) when widening integer types. + void appendTypeConversion(Type const& _typeOnStack, Type const& _targetType); + //// Appends code that cleans higher-order bits for integer types. + void appendHighBitsCleanup(IntegerType const& _typeOnStack); + /// Stores the value on top of the stack in the current lvalue and copies that value to the /// top of the stack again void storeInLValue(Expression const& _expression); |