• R/O
  • SSH

Joypy: Commit

Main interpreter and library.


Commit MetaInfo

Revisionbed68cfd631979ac8a11bdc07f3b695862abfd75 (tree)
Time2018-07-17 12:28:53
AuthorSimon Forman <sforman@hush...>
CommiterSimon Forman

Log Message

A few more stack effects.

Change Summary

Incremental Difference

diff -r 5884b2e0384e -r bed68cfd6319 joy/utils/polytypes.py
--- a/joy/utils/polytypes.py Mon Jul 16 19:10:16 2018 -0700
+++ b/joy/utils/polytypes.py Mon Jul 16 20:28:53 2018 -0700
@@ -417,35 +417,7 @@
417417 '''
418418
419419 average = sum_ = product = min_ = max_ = [(((Ns[1], s1), s0), (n0, s0))]
420-
421- clear = [(s0, s1)]
422-
423-## add = mul = sub = floordiv = modulus = [
424-## ((i2, (i1, s0)), (i3, s0)),
425-## ((f2, (i1, s0)), (f3, s0)),
426-## ((i2, (f1, s0)), (f3, s0)),
427-## ((f2, (f1, s0)), (f3, s0)),
428-## ]
429-
430-## div = truediv = pow_ = [
431-## ((i2, (i1, s0)), (f3, s0)),
432-## ((f2, (i1, s0)), (f3, s0)),
433-## ((i2, (f1, s0)), (f3, s0)),
434-## ((f2, (f1, s0)), (f3, s0)),
435-## ]
436-
437- lshift = rshift = [((i2, (i1, s0)), (i3, s0))]
438-
439-## neg = pred = succ = [((n1, s0), (n2, s0))]
440-
441- sqrt = [((n1, s0), (f2, s0))]
442-
443-## pm = divmod_ = [
444-## ((i2, (i1, s0)), (i3, (i4, s0))),
445-## ((f2, (i1, s0)), (f3, (f4, s0))),
446-## ((i2, (f1, s0)), (f3, (f4, s0))),
447-## ((f2, (f1, s0)), (f3, (f4, s0))),
448-## ]
420+ flatten = [(((Ss[1], s1), s0), (s2, s0))]
449421
450422 return {
451423 name.rstrip('_'): stack_effect
@@ -472,6 +444,10 @@
472444 joy.library._dictionary['unary'],
473445 joy.library._dictionary['binary'],
474446 joy.library._dictionary['ternary'],
447+ joy.library._dictionary['quoted'],
448+ joy.library._dictionary['unquoted'],
449+ joy.library._dictionary['enstacken'],
450+ joy.library._dictionary['disenstacken'],
475451 joy.library.x,
476452 ))
477453 })
@@ -505,7 +481,7 @@
505481 joy.library.add_aliases(FUNCTIONS, joy.library.ALIASES)
506482
507483
508-def expectations_of_definition(cjt):
484+def set_expectations_of_definition(cjt):
509485 if len(cjt.stack_effects) != 1:
510486 raise ValueError
511487 defi = cjt.stack_effects[0]
@@ -526,9 +502,13 @@
526502 dipd.expect = s8, (a8, (a7, s7))
527503 dipdd.expect = s8, (a8, (a7, (a6, s7)))
528504 b.expect = concat_.expect = infra.expect = s8, (s7, s6)
529- expectations_of_definition(unary)
530- expectations_of_definition(binary)
531- expectations_of_definition(ternary)
505+ set_expectations_of_definition(unary)
506+ set_expectations_of_definition(binary)
507+ set_expectations_of_definition(ternary)
508+ set_expectations_of_definition(quoted)
509+ set_expectations_of_definition(unquoted)
510+ set_expectations_of_definition(enstacken)
511+ disenstacken.expect = (As[1], s1), s0
532512 scope = globals().copy()
533513 scope.update(FUNCTIONS)
534514 eval(set_expectations.func_code, scope)
diff -r 5884b2e0384e -r bed68cfd6319 joy/utils/types.py
--- a/joy/utils/types.py Mon Jul 16 19:10:16 2018 -0700
+++ b/joy/utils/types.py Mon Jul 16 20:28:53 2018 -0700
@@ -320,6 +320,8 @@
320320 stuncons = compose(stack, uncons)
321321 stununcons = compose(stack, uncons, uncons)
322322 unit = __(a1), __((a1, ()))
323+ of = compose(swap, at)
324+ clear = s0, s1
323325
324326 eq = ge = gt = le = lt = ne = __(n1, n2), __(b1)
325327
@@ -330,7 +332,7 @@
330332 add = div = floordiv = mod = mul = pow_ = sub = truediv = \
331333 lshift = rshift = __(n1, n2), __(n3,)
332334 sqr = compose(dup, mul)
333- abs_ = floor = succ = pred = neg = __(n1,), __(n2,)
335+ abs_ = floor = sqrt = succ = pred = neg = __(n1,), __(n2,)
334336 divmod_ = pm = __(n2, n1), __(n4, n3)
335337
336338 first_two = compose(uncons, uncons, pop)
Show on old repository browser