Commit 8ae1a362 authored by Robert Bradshaw's avatar Robert Bradshaw

Misc little fixes. Sage now builds and passes all tests.

parent 96945dd7
...@@ -330,10 +330,10 @@ class CCodeWriter: ...@@ -330,10 +330,10 @@ class CCodeWriter:
lbl = self.error_label lbl = self.error_label
self.use_label(lbl) self.use_label(lbl)
if Options.c_line_in_traceback: if Options.c_line_in_traceback:
cinfo = "%s = %s;" % (Naming.clineno_cname, Naming.line_c_macro) cinfo = " %s = %s;" % (Naming.clineno_cname, Naming.line_c_macro)
else: else:
cinfo = "" cinfo = ""
return "{%s = %s[%s]; %s = %s; %s goto %s;}" % ( return "{%s = %s[%s]; %s = %s;%s goto %s;}" % (
Naming.filename_cname, Naming.filename_cname,
Naming.filetable_cname, Naming.filetable_cname,
self.lookup_filename(pos[0]), self.lookup_filename(pos[0]),
......
...@@ -2361,7 +2361,9 @@ class ListComprehensionAppendNode(ExprNode): ...@@ -2361,7 +2361,9 @@ class ListComprehensionAppendNode(ExprNode):
class DictNode(ExprNode): class DictNode(ExprNode):
# Dictionary constructor. # Dictionary constructor.
# #
# key_value_pairs [(ExprNode, ExprNode)] # key_value_pairs [DictItemNode]
subexprs = ['key_value_pairs']
def compile_time_value(self, denv): def compile_time_value(self, denv):
pairs = [(item.key.compile_time_value(denv), item.value.compile_time_value(denv)) pairs = [(item.key.compile_time_value(denv), item.value.compile_time_value(denv))
......
...@@ -20,23 +20,27 @@ from PyrexTypes import py_object_type ...@@ -20,23 +20,27 @@ from PyrexTypes import py_object_type
from Cython.Utils import open_new_file, replace_suffix from Cython.Utils import open_new_file, replace_suffix
def recurse_vtab_check_inheritance(entry,b, dict): def recurse_vtab_check_inheritance(entry, b, dict):
base = entry base = entry
while base is not None: while base is not None:
if base.type.base_type is None or base.type.base_type.vtabstruct_cname is None: if base.type.base_type is None or base.type.base_type.vtabstruct_cname is None:
return False return False
if base.type.base_type.vtabstruct_cname == b.type.vtabstruct_cname: if base.type.base_type.vtabstruct_cname == b.type.vtabstruct_cname:
return True return True
if base.type.base_type.typedef_flag:
return True
base = dict[base.type.base_type.vtabstruct_cname] base = dict[base.type.base_type.vtabstruct_cname]
return False return False
def recurse_vtabslot_check_inheritance(entry,b, dict): def recurse_vtabslot_check_inheritance(entry, b, dict):
base = entry base = entry
while base is not None: while base is not None:
if base.type.base_type is None: if base.type.base_type is None:
return False return False
if base.type.base_type.objstruct_cname == b.type.objstruct_cname: if base.type.base_type.objstruct_cname == b.type.objstruct_cname:
return True return True
if base.type.base_type.typedef_flag:
return True
base = dict[base.type.base_type.objstruct_cname] base = dict[base.type.base_type.objstruct_cname]
return False return False
...@@ -319,7 +323,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -319,7 +323,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if Options.pre_import is not None: if Options.pre_import is not None:
code.putln('static PyObject *%s;' % Naming.preimport_cname) code.putln('static PyObject *%s;' % Naming.preimport_cname)
code.putln('static int %s;' % Naming.lineno_cname) code.putln('static int %s;' % Naming.lineno_cname)
code.putln('static int %s;' % Naming.clineno_cname) code.putln('static int %s = 0;' % Naming.clineno_cname)
code.putln('static char * %s= %s;' % (Naming.cfilenm_cname, Naming.file_c_macro)) code.putln('static char * %s= %s;' % (Naming.cfilenm_cname, Naming.file_c_macro))
code.putln('static char *%s;' % Naming.filename_cname) code.putln('static char *%s;' % Naming.filename_cname)
code.putln('static char **%s;' % Naming.filetable_cname) code.putln('static char **%s;' % Naming.filetable_cname)
...@@ -404,6 +408,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -404,6 +408,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
scope = type.scope scope = type.scope
vtab_dict[type.objstruct_cname]=entry vtab_dict[type.objstruct_cname]=entry
return vtab_dict return vtab_dict
def generate_vtabslot_list(self, vtab_dict): def generate_vtabslot_list(self, vtab_dict):
vtab_list = list() vtab_list = list()
for entry in vtab_dict.itervalues(): for entry in vtab_dict.itervalues():
...@@ -1381,8 +1386,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1381,8 +1386,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
header = "PyMODINIT_FUNC init%s(void)" % env.module_name header = "PyMODINIT_FUNC init%s(void)" % env.module_name
code.putln("%s; /*proto*/" % header) code.putln("%s; /*proto*/" % header)
code.putln("%s {" % header) code.putln("%s {" % header)
code.putln("PyObject* __pyx_internal1;") # do we need any of these here, or just in init2?
code.putln("PyObject* __pyx_internal2;")
code.put_var_declarations(env.temp_entries) code.put_var_declarations(env.temp_entries)
code.putln("/*--- Libary function declarations ---*/") code.putln("/*--- Libary function declarations ---*/")
......
...@@ -182,7 +182,10 @@ class Node: ...@@ -182,7 +182,10 @@ class Node:
flat += child flat += child
else: else:
flat.append(child) flat.append(child)
self._end_pos = max([child.end_pos() for child in flat]) if len(flat) == 0:
self._end_pos = self.pos
else:
self._end_pos = max([child.end_pos() for child in flat])
return self._end_pos return self._end_pos
...@@ -3290,9 +3293,8 @@ class ExceptClauseNode(Node): ...@@ -3290,9 +3293,8 @@ class ExceptClauseNode(Node):
"if (%s) {" % "if (%s) {" %
self.match_flag) self.match_flag)
else: else:
code.putln( code.putln("/*except:*/ {")
"/*except:*/ {") code.putln('__Pyx_AddTraceback("%s");' % self.function_name)
code.putln('__Pyx_AddTraceback("%s");' % self.function_name)
# We always have to fetch the exception value even if # We always have to fetch the exception value even if
# there is no target, because this also normalises the # there is no target, because this also normalises the
# exception and stores it in the thread state. # exception and stores it in the thread state.
......
...@@ -52,4 +52,4 @@ init_local_none = 1 ...@@ -52,4 +52,4 @@ init_local_none = 1
optimize_simple_methods = 1 optimize_simple_methods = 1
# Append the c file and line number to the traceback for exceptions. # Append the c file and line number to the traceback for exceptions.
c_line_in_traceback = 1 c_line_in_traceback = 0
...@@ -323,6 +323,8 @@ def p_call(s, function): ...@@ -323,6 +323,8 @@ def p_call(s, function):
else: else:
arg_tuple = star_arg_tuple arg_tuple = star_arg_tuple
if keyword_args: if keyword_args:
keyword_args = [ExprNodes.DictItemNode(pos=key.pos, key=key, value=value)
for key, value in keyword_args]
keyword_dict = ExprNodes.DictNode(pos, keyword_dict = ExprNodes.DictNode(pos,
key_value_pairs = keyword_args) key_value_pairs = keyword_args)
return ExprNodes.GeneralCallNode(pos, return ExprNodes.GeneralCallNode(pos,
......
...@@ -1070,6 +1070,8 @@ class StructOrUnionScope(Scope): ...@@ -1070,6 +1070,8 @@ class StructOrUnionScope(Scope):
# Add an entry for an attribute. # Add an entry for an attribute.
if not cname: if not cname:
cname = name cname = name
if type.is_cfunction:
type = CPtrType(type)
entry = self.declare(name, cname, type, pos) entry = self.declare(name, cname, type, pos)
entry.is_variable = 1 entry.is_variable = 1
self.var_entries.append(entry) self.var_entries.append(entry)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment