diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/cargo/builder.py | 2 | ||||
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/mparser.py | 12 |
3 files changed, 12 insertions, 4 deletions
diff --git a/mesonbuild/cargo/builder.py b/mesonbuild/cargo/builder.py index fb086d1..2442fbf 100644 --- a/mesonbuild/cargo/builder.py +++ b/mesonbuild/cargo/builder.py @@ -45,7 +45,7 @@ def number(value: int, filename: str) -> mparser.NumberNode: :param filename: the file that the value came from :return: A NumberNode """ - return mparser.NumberNode(_token('number', filename, value)) + return mparser.NumberNode(_token('number', filename, str(value))) def bool(value: builtins.bool, filename: str) -> mparser.BooleanNode: diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index f88d091..f577ba7 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -966,7 +966,7 @@ class CMakeInterpreter: return IdNode(token(val=value)) def number(value: int) -> NumberNode: - return NumberNode(token(val=value)) + return NumberNode(token(val=str(value))) def nodeify(value: TYPE_mixed_list) -> BaseNode: if isinstance(value, str): diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 9867c71..5ab76e7 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -217,7 +217,7 @@ class Lexer: lineno += len(lines) - 1 line_start = mo.end() - len(lines[-1]) elif tid == 'number': - value = int(match_text, base=0) + value = match_text elif tid == 'eol_cont': lineno += 1 line_start = loc @@ -285,8 +285,16 @@ class IdNode(ElementaryNode[str]): def __str__(self) -> str: return "Id node: '%s' (%d, %d)." % (self.value, self.lineno, self.colno) +@dataclass(unsafe_hash=True) class NumberNode(ElementaryNode[int]): - pass + + raw_value: str = field(hash=False) + + def __init__(self, token: Token[str]): + BaseNode.__init__(self, token.lineno, token.colno, token.filename) + self.raw_value = token.value + self.value = int(token.value, base=0) + self.bytespan = token.bytespan class StringNode(ElementaryNode[str]): def __str__(self) -> str: |