Skip to content

Commit df3b2a0

Browse files
make typing less verbose
Object's type method is now used by default so all subtypes can use the inherited implementation
1 parent ba28b85 commit df3b2a0

26 files changed

+8
-170
lines changed

pixie/vm/array.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
class Array(object.Object):
1515
_type = object.Type(u"pixie.stdlib.Array")
1616
_immutable_fields_ = ["_list"]
17-
def type(self):
18-
return Array._type
1917

2018
def __init__(self, lst):
2119
self._list = lst
@@ -98,9 +96,6 @@ def reduce(self, f, init):
9896
init = f.invoke([init, rt.nth(self._w_array, rt.wrap(x))])
9997
return init
10098

101-
def type(self):
102-
return self._type
103-
10499
@extend(proto._first, ArraySeq)
105100
def _first(self):
106101
assert isinstance(self, ArraySeq)
@@ -174,9 +169,6 @@ def __init__(self, size):
174169
for x in range(size):
175170
self._buffer[x] = chr(0)
176171

177-
def type(self):
178-
return ByteArray._type
179-
180172

181173
def __del__(self):
182174
lltype.free(self._buffer, flavor="raw")

pixie/vm/atom.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
class Atom(object.Object):
88
_type = object.Type(u"pixie.stdlib.Atom")
99

10-
def type(self):
11-
return Atom._type
12-
1310
def with_meta(self, meta):
1411
return Atom(self._boxed_value, meta)
1512

pixie/vm/code.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ class MultiArityFn(BaseCode):
148148

149149
_immutable_fields_ = ["_arities[*]", "_required_arity", "_rest_fn"]
150150

151-
def type(self):
152-
return MultiArityFn._type
153-
154151
def __init__(self, name, arities, required_arity=0, rest_fn=None, meta=nil):
155152
BaseCode.__init__(self)
156153
self._name = name
@@ -199,9 +196,6 @@ class NativeFn(BaseCode):
199196
def __init__(self, doc=None):
200197
BaseCode.__init__(self)
201198

202-
def type(self):
203-
return NativeFn._type
204-
205199
def invoke(self, args):
206200
return self.inner_invoke(args)
207201

@@ -217,9 +211,6 @@ class Code(BaseCode):
217211
_type = object.Type(u"pixie.stdlib.Code")
218212
_immutable_fields_ = ["_arity", "_consts[*]", "_bytecode", "_stack_size", "_meta", "_debug_points"]
219213

220-
def type(self):
221-
return Code._type
222-
223214
def __init__(self, name, arity, bytecode, consts, stack_size, debug_points, meta=nil):
224215
BaseCode.__init__(self)
225216
self._arity = arity
@@ -277,9 +268,6 @@ class VariadicCode(BaseCode):
277268
_immutable_fields_ = ["_required_arity", "_code", "_meta"]
278269
_type = object.Type(u"pixie.stdlib.VariadicCode")
279270

280-
def type(self):
281-
return VariadicCode._type
282-
283271
def __init__(self, code, required_arity, meta=nil):
284272
BaseCode.__init__(self)
285273
self._required_arity = r_uint(required_arity)
@@ -319,9 +307,6 @@ class Closure(BaseCode):
319307
_type = object.Type(u"pixie.stdlib.Closure")
320308
_immutable_fields_ = ["_closed_overs[*]", "_code", "_meta"]
321309

322-
def type(self):
323-
return Closure._type
324-
325310
def __init__(self, code, closed_overs, meta=nil):
326311
BaseCode.__init__(self)
327312
affirm(isinstance(code, Code), u"Code argument to Closure must be an instance of Code")
@@ -373,9 +358,6 @@ def get_debug_points(self):
373358
class Undefined(object.Object):
374359
_type = object.Type(u"pixie.stdlib.Undefined")
375360

376-
def type(self):
377-
return Undefined._type
378-
379361
undefined = Undefined()
380362

381363

@@ -413,9 +395,6 @@ class Var(BaseCode):
413395
_type = object.Type(u"pixie.stdlib.Var")
414396
_immutable_fields_ = ["_ns_ref"]
415397

416-
def type(self):
417-
return Var._type
418-
419398
def __init__(self, ns_ref, ns, name):
420399
BaseCode.__init__(self)
421400
self._ns_ref = ns_ref
@@ -497,9 +476,6 @@ class Namespace(object.Object):
497476

498477
_immutable_fields_ = ["_rev?"]
499478

500-
def type(self):
501-
return Namespace._type
502-
503479
def __init__(self, name):
504480
self._rev = 0
505481
self._registry = {}
@@ -636,9 +612,6 @@ class Protocol(object.Object):
636612

637613
_immutable_fields_ = ["_rev?"]
638614

639-
def type(self):
640-
return Protocol._type
641-
642615
def __init__(self, name):
643616
self._name = name
644617
self._polyfns = {}
@@ -663,9 +636,6 @@ def satisfies(self, tp):
663636
class PolymorphicFn(BaseCode):
664637
_type = object.Type(u"pixie.stdlib.PolymorphicFn")
665638

666-
def type(self):
667-
return PolymorphicFn._type
668-
669639
_immutable_fields_ = ["_rev?"]
670640

671641
def __init__(self, name, protocol):
@@ -745,9 +715,6 @@ class DoublePolymorphicFn(BaseCode):
745715
"""A function that is polymorphic on the first two arguments"""
746716
_type = object.Type(u"pixie.stdlib.DoublePolymorphicFn")
747717

748-
def type(self):
749-
return DefaultProtocolFn._type
750-
751718
_immutable_fields_ = ["_rev?"]
752719

753720
def __init__(self, name, protocol):

pixie/vm/cons.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
class Cons(object.Object):
88
_type = object.Type(u"pixie.stdlib.Cons")
99

10-
def type(self):
11-
return Cons._type
12-
1310
def __init__(self, head, tail, meta=nil):
1411
self._first = head
1512
self._next = tail

pixie/vm/custom_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ def get_field(inst, field):
216216

217217
class AbstractMutableCell(Object):
218218
_type = Type(u"pixie.stdlib.AbstractMutableCell")
219-
def type(self):
220-
return self._type
221219

222220
def set_mutable_cell_value(self, ct, fields, nm, idx, value):
223221
pass

pixie/vm/interpreter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ def __init__(self, frame, val):
159159
self._frame = frame
160160
self._val = val
161161

162-
def type(self):
163-
return ShallowContinuation._type
164-
165-
166162
def is_finished(self):
167163
return self._frame.finished
168164

pixie/vm/lazy_seq.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
class LazySeq(object.Object):
1010
_type = object.Type(u"pixie.stdlib.LazySeq")
1111

12-
def type(self):
13-
return LazySeq._type
14-
1512
def __init__(self, fn, meta=nil):
1613
self._fn = fn
1714
self._meta = meta

pixie/vm/libs/env.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
class Environment(Object):
1111
_type = Type(u"pixie.stdlib.Environment")
1212

13-
def type(self):
14-
return Environment._type
15-
1613
def val_at(self, key, not_found):
1714
if not isinstance(key, String):
1815
runtime_error(u"Environment variables are strings ")

pixie/vm/libs/ffi.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ def __init__(self, name):
4141
class ExternalLib(object.Object):
4242
_type = object.Type(u"pixie.stdlib.ExternalLib")
4343

44-
def type(self):
45-
return ExternalLib._type
46-
4744
def __init__(self, nm):
4845
assert isinstance(nm, unicode)
4946
self._name = nm
@@ -94,9 +91,6 @@ class FFIFn(object.Object):
9491
_type = object.Type(u"pixie.stdlib.FFIFn")
9592
_immutable_fields_ = ["_name", "_f_ptr", "_c_fn_type"]
9693

97-
def type(self):
98-
return FFIFn._type
99-
10094
def __init__(self, name, fn_ptr, c_fn_type):
10195
assert isinstance(c_fn_type, CFunctionType)
10296
self._rev = 0
@@ -219,9 +213,6 @@ class Buffer(PointerType):
219213
"""
220214
_type = object.Type(u"pixie.stdlib.Buffer")
221215

222-
def type(self):
223-
return Buffer._type
224-
225216
def __init__(self, size):
226217
self._size = size
227218
self._used_size = 0
@@ -502,8 +493,6 @@ def ffi_type(self):
502493

503494
class VoidP(PointerType):
504495
_type = cvoidp
505-
def type(self):
506-
return VoidP._type
507496

508497
def __init__(self, raw_data):
509498
self._raw_data = raw_data
@@ -604,9 +593,6 @@ def __init__(self, cft, raw_closure, id, fn):
604593
self._is_invoked = False
605594
self._unique_id = id
606595

607-
def type(self):
608-
return CCallback._type
609-
610596
def get_raw_closure(self):
611597
return self._raw_closure
612598

pixie/vm/libs/path.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
class Path(Object):
99
_type = Type(u"pixie.path.Path")
1010

11-
def type(self):
12-
return Path._type
13-
1411
def __init__(self, top):
1512
self._path = rt.name(top)
1613

0 commit comments

Comments
 (0)