# HG changeset patch # User Paul Boddie # Date 1624397764 -7200 # Node ID b4b4179c39f2eb1e2b78b864ee18304f2aa048cf # Parent e6da95e33e43e2ee0be438bb49b7535978b08840 Renamed the int class to integer and introduced an int function. diff -r e6da95e33e43 -r b4b4179c39f2 common.py --- a/common.py Tue Jun 22 23:03:52 2021 +0200 +++ b/common.py Tue Jun 22 23:36:04 2021 +0200 @@ -3,8 +3,7 @@ """ Common functions. -Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, - 2017, 2018, 2019 Paul Boddie +Copyright (C) 2007-2019, 2021 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1595,7 +1594,9 @@ "Return the module name containing the given type 'name'." - if name == "string": + if name == "integer": + modname = "int" + elif name == "string": modname = "str" elif name == "utf8string": modname = "unicode" @@ -1610,7 +1611,9 @@ "Return the type name provided by the given Python value 'name'." - if name == "str": + if name == "int": + return "integer" + elif name == "str": return "string" elif name == "unicode": return "utf8string" diff -r e6da95e33e43 -r b4b4179c39f2 generator.py --- a/generator.py Tue Jun 22 23:03:52 2021 +0200 +++ b/generator.py Tue Jun 22 23:36:04 2021 +0200 @@ -3,7 +3,7 @@ """ Generate C code from object layouts and other deduced information. -Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2018, 2019, 2021 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -43,7 +43,7 @@ dict_type = "__builtins__.dict.dict" function_type = "__builtins__.core.function" - int_type = "__builtins__.int.int" + int_type = "__builtins__.int.integer" list_type = "__builtins__.list.list" none_type = "__builtins__.none.NoneType" string_type = "__builtins__.str.string" diff -r e6da95e33e43 -r b4b4179c39f2 lib/__builtins__/__init__.py --- a/lib/__builtins__/__init__.py Tue Jun 22 23:03:52 2021 +0200 +++ b/lib/__builtins__/__init__.py Tue Jun 22 23:36:04 2021 +0200 @@ -61,7 +61,7 @@ from __builtins__.dict import dict from __builtins__.file import file from __builtins__.float import float -from __builtins__.int import int +from __builtins__.int import int, integer from __builtins__.span import range, slice, xrange from __builtins__.list import list from __builtins__.long import long diff -r e6da95e33e43 -r b4b4179c39f2 lib/__builtins__/buffer.py --- a/lib/__builtins__/buffer.py Tue Jun 22 23:03:52 2021 +0200 +++ b/lib/__builtins__/buffer.py Tue Jun 22 23:36:04 2021 +0200 @@ -3,7 +3,7 @@ """ Buffer object. -Copyright (C) 2015, 2016, 2017 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2021 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -31,7 +31,7 @@ if args is not None: n = len(args) - elif isinstance(size, int): + elif isinstance(size, integer): n = size else: raise ValueError(size) diff -r e6da95e33e43 -r b4b4179c39f2 lib/__builtins__/int.py --- a/lib/__builtins__/int.py Tue Jun 22 23:03:52 2021 +0200 +++ b/lib/__builtins__/int.py Tue Jun 22 23:36:04 2021 +0200 @@ -3,7 +3,7 @@ """ Integer objects. -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2018, 2021 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -26,18 +26,19 @@ int_neg, int_not, int_or, int_pow, int_rshift, int_str, \ int_sub, int_xor -class int: +def int(number_or_string): + + "Initialise the integer with the given 'number_or_string'." + + if is_int(number_or_string): + return number_or_string + else: + raise TypeError + +class integer: "An integer abstraction." - def __init__(self, number_or_string=None): - - "Initialise the integer with the given 'number_or_string'." - - # NOTE: To be implemented. - - pass - def __hash__(self): "Return a value for hashing purposes." diff -r e6da95e33e43 -r b4b4179c39f2 transresults.py --- a/transresults.py Tue Jun 22 23:03:52 2021 +0200 +++ b/transresults.py Tue Jun 22 23:36:04 2021 +0200 @@ -3,7 +3,7 @@ """ Translation result abstractions. -Copyright (C) 2016, 2017, 2018 Paul Boddie +Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -142,7 +142,7 @@ # NOTE: Should reference a common variable for the type name. - if self.ref.get_origin() == "__builtins__.int.int": + if self.ref.get_origin() == "__builtins__.int.integer": return "__INTVALUE(%s)" % self.value else: return encode_literal_constant(self.number)