Commit be208c84 authored by Boxiang Sun's avatar Boxiang Sun

Test

parent 21ffc32a
...@@ -1971,12 +1971,15 @@ class CCodeWriter(object): ...@@ -1971,12 +1971,15 @@ class CCodeWriter(object):
def put_temp_declarations(self, func_context): def put_temp_declarations(self, func_context):
for name, type, manage_ref, static in func_context.temps_allocated: for name, type, manage_ref, static in func_context.temps_allocated:
decl = type.declaration_code(name) decl = type.declaration_code(name)
if type.is_pyobject: if type.is_pyobject:
self.putln("%s = NULL;" % decl) self.putln("%s = NULL;" % decl)
elif type.is_memoryviewslice: elif type.is_memoryviewslice:
from . import MemoryView from . import MemoryView
self.putln("%s = %s;" % (decl, MemoryView.memslice_entry_init)) self.putln("%s = %s;" % (decl, MemoryView.memslice_entry_init))
elif type.is_struct and type.is_extension_type and type.nogil:
self.putln("%s; // Fuck!" % decl)
else: else:
self.putln("%s%s;" % (static and "static " or "", decl)) self.putln("%s%s;" % (static and "static " or "", decl))
......
...@@ -6,10 +6,10 @@ debug_coercion = 0 ...@@ -6,10 +6,10 @@ debug_coercion = 0
# Write comments into the C code that show where temporary variables # Write comments into the C code that show where temporary variables
# are allocated and released. # are allocated and released.
debug_temp_code_comments = 0 debug_temp_code_comments = 1
# Write a call trace of the code generation phase into the C code. # Write a call trace of the code generation phase into the C code.
debug_trace_code_generation = 0 debug_trace_code_generation = 1
# Do not replace exceptions with user-friendly error messages. # Do not replace exceptions with user-friendly error messages.
debug_no_exception_intercept = 0 debug_no_exception_intercept = 0
......
...@@ -1034,6 +1034,7 @@ class ExprNode(Node): ...@@ -1034,6 +1034,7 @@ class ExprNode(Node):
def coerce_to_temp(self, env): def coerce_to_temp(self, env):
# Ensure that the result is in a temporary. # Ensure that the result is in a temporary.
import pdb; pdb.set_trace()
if self.result_in_temp(): if self.result_in_temp():
return self return self
else: else:
...@@ -5852,6 +5853,7 @@ class SimpleCallNode(CallNode): ...@@ -5852,6 +5853,7 @@ class SimpleCallNode(CallNode):
code.mark_pos(self.pos) code.mark_pos(self.pos)
assert self.is_temp assert self.is_temp
import pdb; pdb.set_trace()
self.allocate_temp_result(code) self.allocate_temp_result(code)
if arg is None: if arg is None:
...@@ -8775,6 +8777,7 @@ class DictNode(ExprNode): ...@@ -8775,6 +8777,7 @@ class DictNode(ExprNode):
# Custom method used here because key-value # Custom method used here because key-value
# pairs are evaluated and used one at a time. # pairs are evaluated and used one at a time.
code.mark_pos(self.pos) code.mark_pos(self.pos)
import pdb; pdb.set_trace()
self.allocate_temp_result(code) self.allocate_temp_result(code)
is_dict = self.type.is_pyobject is_dict = self.type.is_pyobject
...@@ -8834,6 +8837,7 @@ class DictNode(ExprNode): ...@@ -8834,6 +8837,7 @@ class DictNode(ExprNode):
if self.exclude_null_values: if self.exclude_null_values:
code.putln('}') code.putln('}')
elif self.type.nogil: elif self.type.nogil:
import pdb; pdb.set_trace()
code.putln("%s->%s = %s;" % ( code.putln("%s->%s = %s;" % (
self.result(), self.result(),
item.key.value, item.key.value,
......
...@@ -375,7 +375,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -375,7 +375,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_lambda_definitions(env, code) self.generate_lambda_definitions(env, code)
# generate normal variable and function definitions # generate normal variable and function definitions
self.generate_variable_definitions(env, code) self.generate_variable_definitions(env, code)
import pdb; pdb.set_trace()
self.body.generate_function_definitions(env, code) self.body.generate_function_definitions(env, code)
code.mark_pos(None) code.mark_pos(None)
......
...@@ -5171,6 +5171,7 @@ class AssignmentNode(StatNode): ...@@ -5171,6 +5171,7 @@ class AssignmentNode(StatNode):
def generate_execution_code(self, code): def generate_execution_code(self, code):
code.mark_pos(self.pos) code.mark_pos(self.pos)
import pdb; pdb.set_trace()
self.generate_rhs_evaluation_code(code) self.generate_rhs_evaluation_code(code)
self.generate_assignment_code(code) self.generate_assignment_code(code)
...@@ -5523,6 +5524,7 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -5523,6 +5524,7 @@ class CascadedAssignmentNode(AssignmentNode):
else: else:
rhs = rhs.coerce_to(lhs_types.pop(), env) rhs = rhs.coerce_to(lhs_types.pop(), env)
import pdb; pdb.set_trace()
if not rhs.is_name and not rhs.is_literal and ( if not rhs.is_name and not rhs.is_literal and (
use_temp or rhs.is_attribute or rhs.type.is_pyobject): use_temp or rhs.is_attribute or rhs.type.is_pyobject):
rhs = rhs.coerce_to_temp(env) rhs = rhs.coerce_to_temp(env)
......
...@@ -1349,6 +1349,7 @@ class CythonExtensionType(CythonObjectType): ...@@ -1349,6 +1349,7 @@ class CythonExtensionType(CythonObjectType):
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0, deref = 0): for_display = 0, dll_linkage = None, pyrex = 0, deref = 0):
import pdb; pdb.set_trace()
if pyrex or for_display: if pyrex or for_display:
base_code = self.name base_code = self.name
else: else:
......
#error Do not use this file, it is the result of a failed Cython compilation.
...@@ -62,12 +62,6 @@ cdef class SomeMemory nogil: ...@@ -62,12 +62,6 @@ cdef class SomeMemory nogil:
""" """
self.a = a self.a = a
cdef void foo3(self) nogil:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
"""
pass
# Not allowed to define pure Python function in the extension type with nogil option now # Not allowed to define pure Python function in the extension type with nogil option now
# since we want this extension type is CPython free # since we want this extension type is CPython free
# def baz(self): # def baz(self):
...@@ -85,11 +79,16 @@ cdef double bar() nogil: # yet this is what we would like to ...@@ -85,11 +79,16 @@ cdef double bar() nogil: # yet this is what we would like to
be able to declare with nogil option but this requires be able to declare with nogil option but this requires
to first introduce the concept of nogil in cdef class to first introduce the concept of nogil in cdef class
""" """
cdef SomeMemory o = SomeMemory(42.0, 3.14) # for this we need class allocation to handle memory without libpython # cdef SomeMemory o = SomeMemory(42.0, 3.14) # for this we need class allocation to handle memory without libpython
o.foo() # and we need method selection to be independent of libpython cdef SomeMemory o1 = SomeMemory(1, 1.0), o2 = SomeMemory(2, 2.0)
o.foo1(2) o1.foo()
o.a = 2.732 o2.foo()
return o.a # o.foo() # and we need method selection to be independent of libpython
# o.foo1(2)
# o.a = 2.732
# o.fact(100)
return o1.a
cpdef baz(): cpdef baz():
""" """
......
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