Misc little fixes. Sage now builds and passes all tests.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 4 Apr 2008 05:07:13 +0000 (22:07 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 4 Apr 2008 05:07:13 +0000 (22:07 -0700)
Cython/Compiler/Code.py
Cython/Compiler/ExprNodes.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/Options.py
Cython/Compiler/Parsing.py
Cython/Compiler/Symtab.py

index 557a6043ae5e75da3f59dada3edb753093404253..c1f51de1036d1bf5f043cde8174bca9085c64fc0 100644 (file)
@@ -330,10 +330,10 @@ class CCodeWriter:
         lbl = self.error_label
         self.use_label(lbl)
         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:
             cinfo = ""
-        return "{%s = %s[%s]; %s = %s; %s goto %s;}" % (
+        return "{%s = %s[%s]; %s = %s;%s goto %s;}" % (
             Naming.filename_cname,
             Naming.filetable_cname,
             self.lookup_filename(pos[0]),
index 57c8a30016fefc800e1c7a8f2629a696012dc686..bec4b82665f1b2c6a21575f2abed1607ed591121 100644 (file)
@@ -2361,7 +2361,9 @@ class ListComprehensionAppendNode(ExprNode):
 class DictNode(ExprNode):
     #  Dictionary constructor.
     #
-    #  key_value_pairs  [(ExprNode, ExprNode)]
+    #  key_value_pairs  [DictItemNode]
+    
+    subexprs = ['key_value_pairs']
     
     def compile_time_value(self, denv):
         pairs = [(item.key.compile_time_value(denv), item.value.compile_time_value(denv))
index 48740706483b2797a2f0515b0abfd6bc75ce93c7..f0e59f9f5e763d36c7cbb11443a99c9a6526a643 100644 (file)
@@ -20,23 +20,27 @@ from PyrexTypes import py_object_type
 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
     while base is not None:
         if base.type.base_type is None or base.type.base_type.vtabstruct_cname is None:
             return False
         if base.type.base_type.vtabstruct_cname == b.type.vtabstruct_cname:
             return True
+        if base.type.base_type.typedef_flag:
+            return True
         base = dict[base.type.base_type.vtabstruct_cname]
     return False
     
-def recurse_vtabslot_check_inheritance(entry,b, dict):
+def recurse_vtabslot_check_inheritance(entry, b, dict):
     base = entry
     while base is not None:
         if base.type.base_type is None:
             return False
         if base.type.base_type.objstruct_cname == b.type.objstruct_cname:
             return True
+        if base.type.base_type.typedef_flag:
+            return True
         base = dict[base.type.base_type.objstruct_cname]
     return False
     
@@ -319,7 +323,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         if Options.pre_import is not None:
             code.putln('static PyObject *%s;' % Naming.preimport_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;' % Naming.filename_cname)
         code.putln('static char **%s;' % Naming.filetable_cname)
@@ -404,6 +408,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                     scope = type.scope
                     vtab_dict[type.objstruct_cname]=entry
         return vtab_dict
+        
     def generate_vtabslot_list(self, vtab_dict):
         vtab_list = list()
         for entry in vtab_dict.itervalues():
@@ -1381,8 +1386,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         header = "PyMODINIT_FUNC init%s(void)" % env.module_name
         code.putln("%s; /*proto*/" % header)
         code.putln("%s {" % header)
-        code.putln("PyObject* __pyx_internal1;")
-        code.putln("PyObject* __pyx_internal2;")
+        # do we need any of these here, or just in init2?
         code.put_var_declarations(env.temp_entries)
 
         code.putln("/*--- Libary function declarations ---*/")
index eaf74f5e29093bdcf5dfc1b9a5552438d1284a20..76a14ee6432a358b178074b57e317e675a016e10 100644 (file)
@@ -182,7 +182,10 @@ class Node:
                         flat += child
                     else:
                         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
 
 
@@ -3290,9 +3293,8 @@ class ExceptClauseNode(Node):
                 "if (%s) {" %
                     self.match_flag)
         else:
-            code.putln(
-                "/*except:*/ {")
-            code.putln('__Pyx_AddTraceback("%s");' % self.function_name)
+            code.putln("/*except:*/ {")
+        code.putln('__Pyx_AddTraceback("%s");' % self.function_name)
         # We always have to fetch the exception value even if
         # there is no target, because this also normalises the 
         # exception and stores it in the thread state.
index 3a999d5d99d18f2da955382a007f132184565d4e..0f409cea66fad17eb63b3e9f3e101c913626f62e 100644 (file)
@@ -52,4 +52,4 @@ init_local_none = 1
 optimize_simple_methods = 1
 
 # Append the c file and line number to the traceback for exceptions. 
-c_line_in_traceback = 1
+c_line_in_traceback = 0
index 9b5775f261a36d978c3e59f1f417454eda2c53a4..93491c9e0a382e00b02c2c22a17e36f85de87de6 100644 (file)
@@ -323,6 +323,8 @@ def p_call(s, function):
             else:
                 arg_tuple = star_arg_tuple
         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,
                 key_value_pairs = keyword_args)
         return ExprNodes.GeneralCallNode(pos, 
index f414830faf8dd0cc233dda12e8c2d3be3ce57515..0a6e429364a46203fe604e6d0fd357c4e571f098 100644 (file)
@@ -1070,6 +1070,8 @@ class StructOrUnionScope(Scope):
         # Add an entry for an attribute.
         if not cname:
             cname = name
+        if type.is_cfunction:
+            type = CPtrType(type)
         entry = self.declare(name, cname, type, pos)
         entry.is_variable = 1
         self.var_entries.append(entry)