forked from pixie-lang/pixie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduced.py
More file actions
27 lines (21 loc) · 667 Bytes
/
reduced.py
File metadata and controls
27 lines (21 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pixie.vm.object as object
from pixie.vm.code import extend, as_var, returns
from pixie.vm.primitives import true, false
import pixie.vm.stdlib as proto
class Reduced(object.Object):
_type = object.Type(u"pixie.stdlib.Reduced")
def type(self):
return Reduced._type
def __init__(self, boxed_value):
self._boxed_value = boxed_value
@extend(proto._deref, Reduced._type)
def _deref(self):
assert isinstance(self, Reduced)
return self._boxed_value
@as_var("reduced")
def reduced(val):
return Reduced(val)
@returns(bool)
@as_var("reduced?")
def reduced_QMARK_(val):
return true if isinstance(val, Reduced) else false