Passed
Branch master (0442a2)
by P.R.
02:00
created

IntegerDataType.debug()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 1
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from sdoc.sdoc1.data_type.DataType import DataType
10
11
12 View Code Duplication
class IntegerDataType(DataType):
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13
    """
14
    Class for integer data types.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def __init__(self, value):
19
        """
20
        Object constructor.
21
22
        :param int|str value: The value of this integer constant.
23
        """
24
        self._value = int(value)
25
        """
26
        The value of this constant integer.
27
28
        :type: int
29
        """
30
31
    # ------------------------------------------------------------------------------------------------------------------
32
    def debug(self, indent=0):
33
        """
34
        Returns a string for debugging.
35
36
        :param int indent: Unused.
37
38
        :rtype: str
39
        """
40
        return str(self._value)
41
42
    # ------------------------------------------------------------------------------------------------------------------
43
    def dereference(self):
44
        """
45
        Returns a clone of this integer.
46
47
        :rtype: IntegerDataType
48
        """
49
        return IntegerDataType(self._value)
50
51
    # ------------------------------------------------------------------------------------------------------------------
52
    def get_value(self):
53
        """
54
        Returns the underling value of this data type.
55
56
        :rtype: int
57
        """
58
        return self._value
59
60
    # ------------------------------------------------------------------------------------------------------------------
61
    def get_type_id(self):
62
        """
63
        Returns the ID of this data type.
64
65
        :rtype: int
66
        """
67
        return DataType.INT
68
69
    # ------------------------------------------------------------------------------------------------------------------
70
    def is_constant(self):
71
        """
72
        Returns False always.
73
74
        :rtype: bool
75
        """
76
        return False
77
78
    # ------------------------------------------------------------------------------------------------------------------
79
    def is_defined(self):
80
        """
81
        Returns True always.
82
83
        :rtype: bool
84
        """
85
        return True
86
87
    # ------------------------------------------------------------------------------------------------------------------
88
    def is_scalar(self):
89
        """
90
        Returns True always.
91
92
        :rtype: bool
93
        """
94
        return False
95
96
    # ------------------------------------------------------------------------------------------------------------------
97
    def is_true(self):
98
        """
99
        Returns True if this integer is not 0. Returns False otherwise.
100
101
        :rtype: bool
102
        """
103
        return self._value != 0
104
105
    # ------------------------------------------------------------------------------------------------------------------
106
    def __str__(self):
107
        """
108
        Returns the string representation of the integer constant.
109
110
        :rtype: str
111
        """
112
        return str(self._value)
113
114
# ----------------------------------------------------------------------------------------------------------------------
115