aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'ExpressionCompiler.h')
-rw-r--r--ExpressionCompiler.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/ExpressionCompiler.h b/ExpressionCompiler.h
index a930723c..d67814be 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,14 @@ 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.
+ /// If @a _cleanupNeeded, high order bits cleanup is also done if no type conversion would be
+ /// necessary.
+ void appendTypeConversion(Type const& _typeOnStack, Type const& _targetType, bool _cleanupNeeded = false);
+ //// 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);