if entry and entry.is_cfunction:
var_entry = entry.as_variable
if var_entry:
- if var_entry.is_builtin and Options.cache_builtins:
+ if var_entry.is_builtin and var_entry.is_const:
var_entry = env.declare_builtin(var_entry.name, self.pos)
node = NameNode(self.pos, name = self.name)
node.entry = var_entry
if entry.is_declared_generic:
self.result_ctype = py_object_type
if entry.is_pyglobal or entry.is_builtin:
- if Options.cache_builtins and entry.is_builtin:
+ if entry.is_builtin and entry.is_const:
self.is_temp = 0
else:
self.is_temp = 1
if self.is_used_as_rvalue:
entry = self.entry
if entry.is_builtin:
- if not Options.cache_builtins: # cached builtins are ok
+ if not entry.is_const: # cached builtins are ok
self.gil_error()
elif entry.is_pyglobal:
self.gil_error()
entry = self.entry
if entry is None:
return # There was an error earlier
- if entry.is_builtin and Options.cache_builtins:
+ if entry.is_builtin and entry.is_const:
return # Lookup already cached
elif entry.is_pyclass_attr:
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
if self.outer_scope is not None:
return self.outer_scope.declare_builtin(name, pos)
else:
- error(pos, "undeclared name not builtin: %s"%name)
+ warning(pos, "undeclared name not builtin: %s" % name, 2)
def declare_builtin_cfunction(self, name, type, cname, python_equiv = None,
utility_code = None):
if self.has_import_star:
entry = self.declare_var(name, py_object_type, pos)
return entry
- elif self.outer_scope is not None:
- return self.outer_scope.declare_builtin(name, pos)
+ ## elif self.outer_scope is not None:
+ ## entry = self.outer_scope.declare_builtin(name, pos)
+ ## print entry
+ ## return entry
else:
- error(pos, "undeclared name not builtin: %s"%name)
+ # unknown - assume it's builtin and look it up at runtime
+ warning(pos, "undeclared name not builtin: %s" % name, 2)
+ entry = self.declare(name, None, py_object_type, pos, 'private')
+ entry.is_builtin = 1
+ return entry
if Options.cache_builtins:
for entry in self.cached_builtins:
if entry.name == name: