# HG changeset patch # User Paul Boddie # Date 1477429597 -7200 # Node ID 43aac14966b1fc2d438682513a1805cdf9baa51f # Parent 87613c4c3ee3589ae0286245b7846c2cc2ab0413 Added predefined constant instances. Introduced __data__ for internal data. diff -r 87613c4c3ee3 -r 43aac14966b1 inspector.py --- a/inspector.py Tue Oct 25 22:26:03 2016 +0200 +++ b/inspector.py Tue Oct 25 23:06:37 2016 +0200 @@ -126,12 +126,20 @@ in_function = self.function_locals.has_key(path) for name in names: - if name in predefined_constants or in_function and name in self.function_locals[path]: + if in_function and name in self.function_locals[path]: + continue + + key = "%s.%s" % (path, name) + + # Find predefined constant names before anything else. + + if name in predefined_constants: + ref = self.get_builtin(name) + self.set_name_reference(key, ref) continue # Find local definitions (within dynamic namespaces). - key = "%s.%s" % (path, name) ref = self.get_resolved_object(key) if ref: self.set_name_reference(key, ref) diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/__init__.py --- a/lib/__builtins__/__init__.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/__init__.py Tue Oct 25 23:06:37 2016 +0200 @@ -73,7 +73,7 @@ # Classes. -from __builtins__.bool import bool +from __builtins__.bool import bool, False, True from __builtins__.buffer import buffer from __builtins__.complex import complex from __builtins__.dict import dict @@ -84,8 +84,8 @@ from __builtins__.iterator import listiterator from __builtins__.list import list from __builtins__.long import long -from __builtins__.none import NoneType -from __builtins__.notimplemented import NotImplementedType +from __builtins__.none import None, NoneType +from __builtins__.notimplemented import NotImplemented, NotImplementedType from __builtins__.set import frozenset, set from __builtins__.str import basestring, str, unicode from __builtins__.tuple import tuple diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/bool.py --- a/lib/__builtins__/bool.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/bool.py Tue Oct 25 23:06:37 2016 +0200 @@ -3,7 +3,7 @@ """ Boolean objects. -Copyright (C) 2015 Paul Boddie +Copyright (C) 2015, 2016 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,4 +26,7 @@ def __str__(self): return self is True and "True" or "False" +False = bool() +True = bool() + # vim: tabstop=4 expandtab shiftwidth=4 diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/float.py --- a/lib/__builtins__/float.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/float.py Tue Oct 25 23:06:37 2016 +0200 @@ -22,7 +22,7 @@ class float(object): def __init__(self, number_or_string=None): # Note member. - self.data = 0 + self.__data__ = 0.0 def __iadd__(self, other): pass def __isub__(self, other): pass diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/int.py --- a/lib/__builtins__/int.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/int.py Tue Oct 25 23:06:37 2016 +0200 @@ -25,7 +25,7 @@ class int(object): def __init__(self, number_or_string=None): # Note member. - self.data = 0 + self.__data__ = 0 def __iadd__(self, other): "Return a new int for the operation." diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/none.py --- a/lib/__builtins__/none.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/none.py Tue Oct 25 23:06:37 2016 +0200 @@ -3,7 +3,7 @@ """ None objects. -Copyright (C) 2015 Paul Boddie +Copyright (C) 2015, 2016 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 @@ -24,4 +24,6 @@ "None is always false." return False +None = NoneType() + # vim: tabstop=4 expandtab shiftwidth=4 diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/notimplemented.py --- a/lib/__builtins__/notimplemented.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/notimplemented.py Tue Oct 25 23:06:37 2016 +0200 @@ -3,7 +3,7 @@ """ Not implemented object. -Copyright (C) 2015 Paul Boddie +Copyright (C) 2015, 2016 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 @@ -21,4 +21,6 @@ class NotImplementedType: pass +NotImplemented = NotImplementedType() + # vim: tabstop=4 expandtab shiftwidth=4 diff -r 87613c4c3ee3 -r 43aac14966b1 lib/__builtins__/str.py --- a/lib/__builtins__/str.py Tue Oct 25 22:26:03 2016 +0200 +++ b/lib/__builtins__/str.py Tue Oct 25 23:06:37 2016 +0200 @@ -26,7 +26,7 @@ class basestring(object): def __init__(self, data=None): # Note member. - self.data = data + self.__data__ = "" def __contains__(self, value): pass diff -r 87613c4c3ee3 -r 43aac14966b1 resolving.py --- a/resolving.py Tue Oct 25 22:26:03 2016 +0200 +++ b/resolving.py Tue Oct 25 23:06:37 2016 +0200 @@ -19,7 +19,7 @@ this program. If not, see . """ -from common import init_item, predefined_constants +from common import init_item from results import AccessRef, InstanceRef, InvocationRef, LocalNameRef, \ NameRef, ResolvedNameRef from referencing import Reference