Commit 38323671 authored by Xavier Thompson's avatar Xavier Thompson

Rename 'consume' as 'recover'

parent 608c29a9
......@@ -11369,8 +11369,8 @@ class SizeofVarNode(SizeofNode):
pass
class ConsumeNode(ExprNode):
# Consume expression
class RecoverNode(ExprNode):
# Recover expression
#
# operand ExprNode
#
......@@ -11396,7 +11396,7 @@ class ConsumeNode(ExprNode):
self.operand = self.operand.analyse_types(env)
operand_type = self.operand.type
if not operand_type.is_cyp_class:
error(self.pos, "Can only consume cypclass (not '%s')" % operand_type)
error(self.pos, "Can only recover cypclass (not '%s')" % operand_type)
self.type = PyrexTypes.error_type
return self
if operand_type.is_qualified_cyp_class:
......@@ -11419,7 +11419,7 @@ class ConsumeNode(ExprNode):
self.is_temp = self.operand_is_named or (self.generate_runtime_check and not solid_operand.is_temp)
self.solid_operand = solid_operand
if self.operand_is_named:
solid_operand.entry.is_consumed = True
solid_operand.entry.is_recovered = True
return self
def may_be_none(self):
......@@ -11429,7 +11429,7 @@ class ConsumeNode(ExprNode):
return self.operand.is_simple()
def make_owned_reference(self, code):
# We steal the reference of the consumed operand.
# We steal the reference of the recovered operand.
pass
def calculate_result_code(self):
......@@ -11451,7 +11451,7 @@ class ConsumeNode(ExprNode):
code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
code.putln("#endif")
code.putln("PyErr_SetString(PyExc_TypeError, \"'consume' operand is not isolated\");")
code.putln("PyErr_SetString(PyExc_TypeError, \"'recover' operand is not isolated\");")
if self.nogil:
code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_Release(_save);")
......
......@@ -2199,7 +2199,7 @@ class FuncDefNode(StatNode, BlockNode):
if entry.type.is_cyp_class:
# CyObjects use another refcounting convention.
# Except for the 'self' argument.
if entry.is_self_arg and (entry.is_consumed or entry.cf_is_reassigned) and not entry.in_closure:
if entry.is_self_arg and (entry.is_recovered or entry.cf_is_reassigned) and not entry.in_closure:
code.put_var_incref(entry)
elif (acquire_gil or entry.cf_is_reassigned) and not entry.in_closure:
code.put_var_incref(entry)
......@@ -2419,8 +2419,8 @@ class FuncDefNode(StatNode, BlockNode):
continue
elif entry.type.is_cyp_class:
# CyObject arguments are systematically decrefed.
# Except for the 'self' argument when it has not been reassigned or consumed.
if entry.is_self_arg and not (entry.is_consumed or entry.cf_is_reassigned):
# Except for the 'self' argument when it has not been reassigned or recovered.
if entry.is_self_arg and not (entry.is_recovered or entry.cf_is_reassigned):
continue
else:
if entry.in_closure:
......
......@@ -309,8 +309,8 @@ def _p_factor(s):
return p_typecast(s)
elif sy == 'IDENT' and s.systring == "sizeof":
return p_sizeof(s)
elif sy == 'IDENT' and s.systring == "consume":
return p_consume(s)
elif sy == 'IDENT' and s.systring == "recover":
return p_recover(s)
return p_power(s)
def p_typecast(s):
......@@ -360,12 +360,12 @@ def p_sizeof(s):
s.expect(')')
return node
def p_consume(s):
# s.sy == ident "consume"
def p_recover(s):
# s.sy == ident "recover"
pos = s.position()
s.next()
operand = p_factor(s)
return ExprNodes.ConsumeNode(pos, operand = operand)
return ExprNodes.RecoverNode(pos, operand = operand)
def p_yield_expression(s):
......
......@@ -181,7 +181,7 @@ class Entry(object):
#
# active_entry Entry Entry for the active version of an asyncable cypclass method
#
# is_consumed boolean The entry is the operand of a 'consume' expression.
# is_recovered boolean The entry is the operand of a 'recover' expression.
#
# is_specialised boolean The entry is a template specialisation.
......@@ -262,7 +262,7 @@ class Entry(object):
static_cname = None
original_name = None
active_entry = None
is_consumed = False
is_recovered = False
is_specialised = False
def __init__(self, name, cname, type, pos = None, init = None):
......
......@@ -34,21 +34,21 @@ def test_aliasing():
active_b = A()
cdef active A active_c
active_c = consume A()
active_c = recover A()
cdef active A active_d
active_d = <lock A> consume A()
active_d = <lock A> recover A()
def test_calling():
a = activate(consume A())
a = activate(recover A())
a.f(NULL, A())
a.f(NULL, consume A())
a.f(NULL, recover A())
cdef iso A iso_a
a.f_iso(NULL, consume iso_a)
a.f_iso(NULL, recover iso_a)
cdef lock A lock_a
a.f_lock(NULL, lock_a)
......@@ -62,7 +62,7 @@ def test_typecast():
# Casting from active
cdef iso A iso_a
iso_a = consume <iso A> active_a
iso_a = recover <iso A> active_a
cdef lock A lock_a
lock_a = <lock A> active_a
......@@ -75,10 +75,10 @@ def test_typecast():
active_b = <active A> A()
cdef active A active_c
active_c = <active A> <iso A> consume A()
active_c = <active A> <iso A> recover A()
cdef active A active_d
active_d = <active A> <lock A> consume A()
active_d = <active A> <lock A> recover A()
_ERRORS = u'''
......
......@@ -7,7 +7,7 @@ cdef cypclass A activable:
def test_name_aliasing():
cdef iso A iso_a
iso_a = consume A()
iso_a = recover A()
# Aliasing to iso
cdef iso A iso_b
......@@ -17,7 +17,7 @@ def test_name_aliasing():
iso_c = A()
cdef iso A iso_d
iso_d = activate(consume A())
iso_d = activate(recover A())
cdef iso A iso_e
iso_e = <object> A()
......@@ -50,11 +50,11 @@ cdef cypclass Origin:
return other
def test_field_aliasing():
cdef iso Origin o = consume Origin()
cdef iso Origin o = recover Origin()
cdef object py_field
# OK - can pass consumed arguments
o.bar(consume Field()).foo(consume Field())
# OK - can pass recovered arguments
o.bar(recover Field()).foo(recover Field())
# ERR - aliasing field of iso to pyobject
py_field = o.field
......@@ -66,25 +66,25 @@ def test_field_aliasing():
field = o.field
# ERR - consuming field of iso
field2 = consume o.field
field2 = recover o.field
# ERR - non_consumed argument
# ERR - non_recovered argument
o.bar(Field())
# ERR - aliasing the returned reference
c = o.bar(consume Field())
c = o.bar(recover Field())
def test_typecast():
cdef iso A iso_a
iso_a = consume A()
iso_a = recover A()
# Casting to iso
cdef iso A iso_b
iso_b = <iso A> A()
cdef iso A iso_c
iso_c = <iso A> activate(consume A())
iso_c = <iso A> activate(recover A())
cdef iso A iso_d
iso_d = <iso A> <object> A()
......@@ -103,7 +103,7 @@ def test_typecast():
iso_e = <iso A> iso_a
cdef iso A iso_f
iso_f = consume <iso A> iso_a
iso_f = recover <iso A> iso_a
_ERRORS = u'''
......
......@@ -40,10 +40,10 @@ def test_aliasing():
lock_b = A()
cdef lock A lock_c
lock_c = consume A()
lock_c = recover A()
cdef lock A lock_d
lock_d = <lock A> consume A()
lock_d = <lock A> recover A()
cdef lock A lock_e
cdef locked A locked_b
......@@ -55,12 +55,12 @@ def test_calling():
a.f(A())
a.f(consume A())
a.f(recover A())
a.f_locked_self()
cdef iso A iso_a
a.f_iso(consume iso_a)
a.f_iso(recover iso_a)
cdef lock A lock_a
a.f_lock(lock_a)
......@@ -74,7 +74,7 @@ def test_typecast():
# Casting from lock
cdef iso A iso_a
iso_a = consume <iso A> lock_a
iso_a = recover <iso A> lock_a
cdef active A active_a
active_a = <active A> lock_a
......@@ -90,10 +90,10 @@ def test_typecast():
lock_b = <lock A> A()
cdef lock A lock_c
lock_c = <lock A> <iso A> consume A()
lock_c = <lock A> <iso A> recover A()
cdef lock A lock_d
lock_d = <lock A> activate(consume A())
lock_d = <lock A> activate(recover A())
cdef lock A lock_e
cdef locked A locked_b
......
......@@ -134,7 +134,7 @@ cdef cypclass A activable:
__init__(self):
self.a = 0
self._active_result_class = WaitResult.construct
self._active_queue_class = consume BasicQueue()
self._active_queue_class = recover BasicQueue()
int getter(const self):
return self.a
void setter(self, int a):
......@@ -147,12 +147,12 @@ def test_acthon_chain(n):
"""
cdef ActhonResultInterface res
cdef lock ActhonQueueInterface queue
sync1 = <lock ActivityCounterSync> consume ActivityCounterSync()
after_sync1 = <lock ActivityCounterSync> consume ActivityCounterSync(sync1)
sync1 = <lock ActivityCounterSync> recover ActivityCounterSync()
after_sync1 = <lock ActivityCounterSync> recover ActivityCounterSync(sync1)
obj = A()
queue = obj._active_queue_class
obj_actor = activate(consume obj)
obj_actor = activate(recover obj)
# Pushing things in the queue
obj_actor.setter(sync1, n)
......
......@@ -139,16 +139,16 @@ cdef object cyobject_to_pyobject(Refcounted r):
cdef Refcounted pyobject_to_cyobject(object o):
return o
cdef void consume_cyobject(Refcounted r):
cdef void recover_cyobject(Refcounted r):
pass
def consume_wrapped_cyobject(Refcounted r):
def recover_wrapped_cyobject(Refcounted r):
pass
def wrapped_cyobject_to_pyobject(Refcounted r):
return r
def consume_wrapped_cyobject_with_generic_args(Refcounted r, **kwargs):
def recover_wrapped_cyobject_with_generic_args(Refcounted r, **kwargs):
pass
def wrapped_cyobject_to_pyobject_with_generic_args(Refcounted r, dummy=2, unused="unused"):
......@@ -169,39 +169,39 @@ def test_recfcount_round_trip_conversions():
return Cy_GETREF(r)
def test_recfcount_consume_cyobject():
def test_recfcount_recover_cyobject():
"""
>>> test_recfcount_consume_cyobject()
>>> test_recfcount_recover_cyobject()
2
"""
cdef Refcounted r = Refcounted()
for i in range(10):
consume_cyobject(r)
recover_cyobject(r)
return Cy_GETREF(r)
def test_recfcount_consume_converted_cyobject():
def test_recfcount_recover_converted_cyobject():
"""
>>> test_recfcount_consume_converted_cyobject()
>>> test_recfcount_recover_converted_cyobject()
2
"""
cdef Refcounted r = Refcounted()
for i in range(10):
consume_cyobject(<object> r)
recover_cyobject(<object> r)
return Cy_GETREF(r)
def test_recfcount_consume_wrapped_cyobject():
def test_recfcount_recover_wrapped_cyobject():
"""
>>> test_recfcount_consume_wrapped_cyobject()
>>> test_recfcount_recover_wrapped_cyobject()
2
"""
cdef Refcounted r = Refcounted()
for i in range(10):
consume_wrapped_cyobject(r)
recover_wrapped_cyobject(r)
return Cy_GETREF(r)
......@@ -217,15 +217,15 @@ def test_recfcount_convert_wrapped_cyobject():
return Cy_GETREF(r)
def test_recfcount_consume_wrapped_cyobject_with_generic_args():
def test_recfcount_recover_wrapped_cyobject_with_generic_args():
"""
>>> test_recfcount_consume_wrapped_cyobject_with_generic_args()
>>> test_recfcount_recover_wrapped_cyobject_with_generic_args()
2
"""
cdef Refcounted r = Refcounted()
for i in range(10):
consume_wrapped_cyobject_with_generic_args(r)
recover_wrapped_cyobject_with_generic_args(r)
return Cy_GETREF(r)
......
......@@ -8,9 +8,9 @@ cdef cypclass Refcounted:
print("Refcounted destroyed")
def test_consume_name():
def test_recover_name():
"""
>>> test_consume_name()
>>> test_recover_name()
Refcounted destroyed
0
"""
......@@ -18,7 +18,7 @@ def test_consume_name():
if Cy_GETREF(r0) != 2:
return -1
cdef Refcounted r1 = consume r0
cdef Refcounted r1 = recover r0
if r0 is not NULL:
return -2
if Cy_GETREF(r1) != 2:
......@@ -26,15 +26,15 @@ def test_consume_name():
return 0
def test_consume_iso_name():
def test_recover_iso_name():
"""
>>> test_consume_iso_name()
>>> test_recover_iso_name()
Refcounted destroyed
0
"""
cdef iso Refcounted r0 = consume Refcounted()
cdef iso Refcounted r0 = recover Refcounted()
cdef Refcounted r1 = consume r0
cdef Refcounted r1 = recover r0
if r0 is not NULL:
return -2
if Cy_GETREF(r1) != 2:
......@@ -42,58 +42,58 @@ def test_consume_iso_name():
return 0
def test_consume_and_drop_name():
def test_recover_and_drop_name():
"""
>>> test_consume_and_drop_name()
>>> test_recover_and_drop_name()
Refcounted destroyed
consumed
recovered
0
"""
r = Refcounted()
if Cy_GETREF(r) != 2:
return -1
consume r
print("consumed")
recover r
print("recovered")
if r is not NULL:
return -2
return 0
def test_consume_constructed():
def test_recover_constructed():
"""
>>> test_consume_constructed()
>>> test_recover_constructed()
Refcounted destroyed
0
"""
cdef Refcounted r = consume Refcounted()
cdef Refcounted r = recover Refcounted()
if Cy_GETREF(r) != 2:
return -1
return 0
def test_consume_iso_constructed():
def test_recover_iso_constructed():
"""
>>> test_consume_iso_constructed()
>>> test_recover_iso_constructed()
Refcounted destroyed
0
"""
cdef Refcounted r = consume new Refcounted()
cdef Refcounted r = recover new Refcounted()
if Cy_GETREF(r) != 2:
return -1
return 0
def test_consume_and_drop_constructed():
def test_recover_and_drop_constructed():
"""
>>> test_consume_and_drop_constructed()
>>> test_recover_and_drop_constructed()
Refcounted destroyed
consumed
recovered
0
"""
consume Refcounted()
print("consumed")
recover Refcounted()
print("recovered")
return 0
......@@ -107,47 +107,47 @@ cdef cypclass OriginIso:
iso Refcounted field
__init__(self):
self.field = consume Refcounted()
self.field = recover Refcounted()
def test_consume_field():
def test_recover_field():
"""
>>> test_consume_field()
>>> test_recover_field()
Refcounted destroyed
0
"""
cdef Refcounted r = consume Origin().field
cdef Refcounted r = recover Origin().field
if Cy_GETREF(r) != 2:
return -1
return 0
def test_consume_iso_field():
def test_recover_iso_field():
"""
>>> test_consume_iso_field()
>>> test_recover_iso_field()
Refcounted destroyed
0
"""
cdef Refcounted r = consume OriginIso().field
cdef Refcounted r = recover OriginIso().field
if Cy_GETREF(r) != 2:
return -1
return 0
def test_consume_and_drop_field():
def test_recover_and_drop_field():
"""
>>> test_consume_and_drop_field()
>>> test_recover_and_drop_field()
Refcounted destroyed
consumed
recovered
0
"""
consume Origin().field
print("consumed")
recover Origin().field
print("recovered")
return 0
def test_consume_cast_name():
def test_recover_cast_name():
"""
>>> test_consume_cast_name()
>>> test_recover_cast_name()
Refcounted destroyed
0
"""
......@@ -155,7 +155,7 @@ def test_consume_cast_name():
if Cy_GETREF(r0) != 2:
return -1
cdef Refcounted r1 = consume <Refcounted> r0
cdef Refcounted r1 = recover <Refcounted> r0
if r0 is not NULL:
return -2
if Cy_GETREF(r1) != 2:
......@@ -163,25 +163,25 @@ def test_consume_cast_name():
return 0
def test_consume_cast_constructed():
def test_recover_cast_constructed():
"""
>>> test_consume_cast_constructed()
>>> test_recover_cast_constructed()
Refcounted destroyed
0
"""
cdef Refcounted r = consume <Refcounted> Refcounted()
cdef Refcounted r = recover <Refcounted> Refcounted()
if Cy_GETREF(r) != 2:
return -1
return 0
def test_consume_cast_field():
def test_recover_cast_field():
"""
>>> test_consume_cast_field()
>>> test_recover_cast_field()
Refcounted destroyed
0
"""
cdef Refcounted r = consume <Refcounted> Origin().field
cdef Refcounted r = recover <Refcounted> Origin().field
if Cy_GETREF(r) != 2:
return -1
......@@ -193,9 +193,9 @@ cdef cypclass Convertible:
__dealloc__(self) with gil:
print("Convertible destroyed")
def test_consume_converted_name():
def test_recover_converted_name():
"""
>>> test_consume_converted_name()
>>> test_recover_converted_name()
Convertible destroyed
Refcounted destroyed
0
......@@ -204,7 +204,7 @@ def test_consume_converted_name():
if Cy_GETREF(c) != 2:
return -1
cdef Refcounted r = consume <Refcounted> c
cdef Refcounted r = recover <Refcounted> c
if c is NULL:
return -2
if Cy_GETREF(c) != 2:
......@@ -215,14 +215,14 @@ def test_consume_converted_name():
del c
return 0
def test_consume_converted_constructed():
def test_recover_converted_constructed():
"""
>>> test_consume_converted_constructed()
>>> test_recover_converted_constructed()
Convertible destroyed
Refcounted destroyed
0
"""
cdef Refcounted r = consume <Refcounted> Convertible()
cdef Refcounted r = recover <Refcounted> Convertible()
if Cy_GETREF(r) != 2:
return -1
......@@ -235,9 +235,9 @@ cdef cypclass OriginConvertible:
self.field = Convertible()
def test_consume_converted_field():
def test_recover_converted_field():
"""
>>> test_consume_converted_field()
>>> test_recover_converted_field()
Convertible destroyed
Refcounted destroyed
0
......@@ -246,7 +246,7 @@ def test_consume_converted_field():
if Cy_GETREF(o.field) != 2:
return -1
cdef Refcounted r = consume <Refcounted> o.field
cdef Refcounted r = recover <Refcounted> o.field
if o.field is NULL:
return -2
if Cy_GETREF(o.field) != 2:
......
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