cython-devel

changeset 2811:6f8fc01ddab1

Verbose type inference directive.
author Robert Bradshaw <robertwb@math.washington.edu>
date Thu Jan 21 16:41:28 2010 -0800 (2 years ago)
parents 35f3362e1cfc
children 5215ebde137d
files Cython/Compiler/Options.py Cython/Compiler/TypeInference.py
line diff
1.1 --- a/Cython/Compiler/Options.py Thu Jan 21 16:23:13 2010 -0800 1.2 +++ b/Cython/Compiler/Options.py Thu Jan 21 16:41:28 2010 -0800 1.3 @@ -63,6 +63,7 @@ 1.4 'callspec' : "", 1.5 'profile': False, 1.6 'infer_types': False, 1.7 + 'infer_types.verbose': False, 1.8 'autotestdict': True, 1.9 1.10 'warn': None,
2.1 --- a/Cython/Compiler/TypeInference.py Thu Jan 21 16:23:13 2010 -0800 2.2 +++ b/Cython/Compiler/TypeInference.py Thu Jan 21 16:41:28 2010 -0800 2.3 @@ -1,3 +1,4 @@ 2.4 +from Errors import error, warning, warn_once, InternalError 2.5 import ExprNodes 2.6 import Nodes 2.7 import Builtin 2.8 @@ -132,6 +133,7 @@ 2.9 # (Something more powerful than just extending this one...) 2.10 def infer_types(self, scope): 2.11 enabled = scope.directives['infer_types'] 2.12 + verbose = scope.directives['infer_types.verbose'] 2.13 if enabled == True: 2.14 spanning_type = aggressive_spanning_type 2.15 elif enabled is None: # safe mode 2.16 @@ -178,6 +180,8 @@ 2.17 # FIXME: raise a warning? 2.18 # print "No assignments", entry.pos, entry 2.19 entry.type = py_object_type 2.20 + if verbose: 2.21 + warning(entry.pos, "inferred '%s' to be of type '%s'" % (entry.name, entry.type), 1) 2.22 resolve_dependancy(entry) 2.23 # Deal with simple circular dependancies... 2.24 for entry, deps in dependancies_by_entry.items(): 2.25 @@ -197,6 +201,8 @@ 2.26 # We can't figure out the rest with this algorithm, let them be objects. 2.27 for entry in dependancies_by_entry: 2.28 entry.type = py_object_type 2.29 + if verbose: 2.30 + warning(entry.pos, "inferred '%s' to be of type '%s' (default)" % (entry.name, entry.type), 1) 2.31 2.32 def find_spanning_type(type1, type2): 2.33 if type1 is type2: