OSDN Git Service

42104545a76f86b9b04a84f30da660a37d620b5a
[joypy/Thun.git] / joy / utils / polytypes.py
1 # -*- coding: utf_8
2
3
4
5
6
7
8
9
10
11
12
13 pop = FUNCTIONS['pop']
14
15 def loop_true(stack, expression, dictionary):
16     quote, (flag, stack) = stack
17     return stack, CONCAT(quote, (pop, expression)), dictionary
18
19 def loop_two_true(stack, expression, dictionary):
20     quote, (flag, stack) = stack
21     return stack, CONCAT(quote, (pop, CONCAT(quote, (pop, expression)))), dictionary
22
23 def loop_false(stack, expression, dictionary):
24     quote, (flag, stack) = stack
25     return stack, expression, dictionary
26
27 FUNCTIONS['loop'] = CombinatorJoyType('loop', [loop_two_true, loop_true, loop_false], 101)
28
29
30
31
32
33
34
35
36
37
38
39
40 # joy.library.add_aliases(FUNCTIONS, joy.library.ALIASES)
41
42
43 # def set_expectations_of_definition(cjt):
44 #     if len(cjt.stack_effects) != 1:
45 #         raise ValueError
46 #     defi = cjt.stack_effects[0]
47 #     if not isinstance(defi, joy.library.DefinitionWrapper):
48 #         raise ValueError
49 #     F = infer_expression(defi.body)
50 #     assert len(F) == 1, repr(F)
51 #     fi, fo = F[0]
52 #     cjt.expect = fi
53
54
55
56     
57     average = 
58     loop.expect = s6, (b1, s5)
59     disenstacken.expect = (As[1], s1), s0
60     joy.library._dictionary['disenstacken'],
61   
62
63 # scope = globals().copy()
64 # scope.update(FUNCTIONS)
65 # eval(set_expectations.func_code, scope)
66 # del scope
67
68