set type of constants

pull/283/head
Ankur Sundara 6 years ago
parent 5d6ab217a8
commit a1ecf12258
  1. 10
      slither/visitors/slithir/expression_to_slithir.py

@ -227,32 +227,32 @@ class ExpressionToSlithIR(ExpressionVisitor):
self._result.append(operation) self._result.append(operation)
set_val(expression, value) set_val(expression, value)
elif expression.type in [UnaryOperationType.PLUSPLUS_PRE]: elif expression.type in [UnaryOperationType.PLUSPLUS_PRE]:
operation = Binary(value, value, Constant("1"), BinaryType.ADDITION) operation = Binary(value, value, Constant("1", value.type), BinaryType.ADDITION)
self._result.append(operation) self._result.append(operation)
set_val(expression, value) set_val(expression, value)
elif expression.type in [UnaryOperationType.MINUSMINUS_PRE]: elif expression.type in [UnaryOperationType.MINUSMINUS_PRE]:
operation = Binary(value, value, Constant("1"), BinaryType.SUBTRACTION) operation = Binary(value, value, Constant("1", value.type), BinaryType.SUBTRACTION)
self._result.append(operation) self._result.append(operation)
set_val(expression, value) set_val(expression, value)
elif expression.type in [UnaryOperationType.PLUSPLUS_POST]: elif expression.type in [UnaryOperationType.PLUSPLUS_POST]:
lvalue = TemporaryVariable(self._node) lvalue = TemporaryVariable(self._node)
operation = Assignment(lvalue, value, value.type) operation = Assignment(lvalue, value, value.type)
self._result.append(operation) self._result.append(operation)
operation = Binary(value, value, Constant("1"), BinaryType.ADDITION) operation = Binary(value, value, Constant("1", value.type), BinaryType.ADDITION)
self._result.append(operation) self._result.append(operation)
set_val(expression, lvalue) set_val(expression, lvalue)
elif expression.type in [UnaryOperationType.MINUSMINUS_POST]: elif expression.type in [UnaryOperationType.MINUSMINUS_POST]:
lvalue = TemporaryVariable(self._node) lvalue = TemporaryVariable(self._node)
operation = Assignment(lvalue, value, value.type) operation = Assignment(lvalue, value, value.type)
self._result.append(operation) self._result.append(operation)
operation = Binary(value, value, Constant("1"), BinaryType.SUBTRACTION) operation = Binary(value, value, Constant("1", value.type), BinaryType.SUBTRACTION)
self._result.append(operation) self._result.append(operation)
set_val(expression, lvalue) set_val(expression, lvalue)
elif expression.type in [UnaryOperationType.PLUS_PRE]: elif expression.type in [UnaryOperationType.PLUS_PRE]:
set_val(expression, value) set_val(expression, value)
elif expression.type in [UnaryOperationType.MINUS_PRE]: elif expression.type in [UnaryOperationType.MINUS_PRE]:
lvalue = TemporaryVariable(self._node) lvalue = TemporaryVariable(self._node)
operation = Binary(lvalue, Constant("0"), value, BinaryType.SUBTRACTION) operation = Binary(lvalue, Constant("0", value.type), value, BinaryType.SUBTRACTION)
self._result.append(operation) self._result.append(operation)
set_val(expression, lvalue) set_val(expression, lvalue)
else: else:

Loading…
Cancel
Save