Skip to content

Commit

Permalink
Use 'equal()' method to check numeric type equality
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Apr 7, 2021
1 parent 3b26bad commit 7799b19
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions runtime/interpreter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ func (v IntValue) ToBigEndianBytes() []byte {

func (v IntValue) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.IntType
return ok && sema.IntType.Equal(numberType.StaticType)
}

// Int8Value
Expand Down Expand Up @@ -1332,7 +1332,7 @@ func (v Int8Value) ToBigEndianBytes() []byte {

func (v Int8Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int8Type
return ok && sema.Int8Type.Equal(numberType.StaticType)
}

// Int16Value
Expand Down Expand Up @@ -1575,7 +1575,7 @@ func (v Int16Value) ToBigEndianBytes() []byte {

func (v Int16Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int16Type
return ok && sema.Int16Type.Equal(numberType.StaticType)
}

// Int32Value
Expand Down Expand Up @@ -1818,7 +1818,7 @@ func (v Int32Value) ToBigEndianBytes() []byte {

func (v Int32Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int32Type
return ok && sema.Int32Type.Equal(numberType.StaticType)
}

// Int64Value
Expand Down Expand Up @@ -2060,7 +2060,7 @@ func (v Int64Value) ToBigEndianBytes() []byte {

func (v Int64Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int64Type
return ok && sema.Int64Type.Equal(numberType.StaticType)
}

// Int128Value
Expand Down Expand Up @@ -2360,7 +2360,7 @@ func (v Int128Value) ToBigEndianBytes() []byte {

func (v Int128Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int128Type
return ok && sema.Int128Type.Equal(numberType.StaticType)
}

// Int256Value
Expand Down Expand Up @@ -2661,7 +2661,7 @@ func (v Int256Value) ToBigEndianBytes() []byte {

func (v Int256Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Int256Type
return ok && sema.Int256Type.Equal(numberType.StaticType)
}

// UIntValue
Expand Down Expand Up @@ -2908,7 +2908,7 @@ func (v UIntValue) ToBigEndianBytes() []byte {

func (v UIntValue) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UIntType
return ok && sema.UIntType.Equal(numberType.StaticType)
}

// UInt8Value
Expand Down Expand Up @@ -3117,7 +3117,7 @@ func (v UInt8Value) ToBigEndianBytes() []byte {

func (v UInt8Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt8Type
return ok && sema.UInt8Type.Equal(numberType.StaticType)
}

// UInt16Value
Expand Down Expand Up @@ -3326,7 +3326,7 @@ func (v UInt16Value) ToBigEndianBytes() []byte {

func (v UInt16Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt16Type
return ok && sema.UInt16Type.Equal(numberType.StaticType)
}

// UInt32Value
Expand Down Expand Up @@ -3537,7 +3537,7 @@ func (v UInt32Value) ToBigEndianBytes() []byte {

func (v UInt32Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt32Type
return ok && sema.UInt32Type.Equal(numberType.StaticType)
}

// UInt64Value
Expand Down Expand Up @@ -3751,7 +3751,7 @@ func (v UInt64Value) ToBigEndianBytes() []byte {

func (v UInt64Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt64Type
return ok && sema.UInt64Type.Equal(numberType.StaticType)
}

// UInt128Value
Expand Down Expand Up @@ -4021,7 +4021,7 @@ func (v UInt128Value) ToBigEndianBytes() []byte {

func (v UInt128Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt128Type
return ok && sema.UInt128Type.Equal(numberType.StaticType)
}

// UInt256Value
Expand Down Expand Up @@ -4292,7 +4292,7 @@ func (v UInt256Value) ToBigEndianBytes() []byte {

func (v UInt256Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UInt256Type
return ok && sema.UInt256Type.Equal(numberType.StaticType)
}

// Word8Value
Expand Down Expand Up @@ -4462,7 +4462,7 @@ func (v Word8Value) ToBigEndianBytes() []byte {

func (v Word8Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Word8Type
return ok && sema.Word8Type.Equal(numberType.StaticType)
}

// Word16Value
Expand Down Expand Up @@ -4632,7 +4632,7 @@ func (v Word16Value) ToBigEndianBytes() []byte {

func (v Word16Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Word16Type
return ok && sema.Word16Type.Equal(numberType.StaticType)
}

// Word32Value
Expand Down Expand Up @@ -4804,7 +4804,7 @@ func (v Word32Value) ToBigEndianBytes() []byte {

func (v Word32Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Word32Type
return ok && sema.Word32Type.Equal(numberType.StaticType)
}

// Word64Value
Expand Down Expand Up @@ -4976,7 +4976,7 @@ func (v Word64Value) ToBigEndianBytes() []byte {

func (v Word64Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Word64Type
return ok && sema.Word64Type.Equal(numberType.StaticType)
}

// Fix64Value
Expand Down Expand Up @@ -5201,7 +5201,7 @@ func (v Fix64Value) ToBigEndianBytes() []byte {

func (v Fix64Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.Fix64Type
return ok && sema.Fix64Type.Equal(numberType.StaticType)
}

// UFix64Value
Expand Down Expand Up @@ -5422,7 +5422,7 @@ func (v UFix64Value) ToBigEndianBytes() []byte {

func (v UFix64Value) ConformsToDynamicType(_ *Interpreter, dynamicType DynamicType) bool {
numberType, ok := dynamicType.(NumberDynamicType)
return ok && numberType.StaticType == sema.UFix64Type
return ok && sema.UFix64Type.Equal(numberType.StaticType)
}

// CompositeValue
Expand Down

0 comments on commit 7799b19

Please sign in to comment.