goodguide-gibbon 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cabd835978ce48079cb610786bd50119555d75f3
4
- data.tar.gz: f58c19cfbadc8ea11b5300aa8a135085d33c73a2
3
+ metadata.gz: 5c5e884ceb34d20830bd23d03ba92bf99469da19
4
+ data.tar.gz: a76825e187c534ea27d6e87b1fc5c0b2d2aed79c
5
5
  SHA512:
6
- metadata.gz: a32bfa7fb568d4ef0a17b16acf51319125cd89f8c93770859b936cf2fc7175f8b7c939dc1199e3682aa543003d73ac5a143a7a5b05197d8563b19db2251d4e4b
7
- data.tar.gz: 38c21a1b41fd85bf1700d3739911a132c7fe1b0a46f943787f434797e357f6f121e203133b6c9e17f2a80abf131c92f5334fa22fd79233d026f9bcf2b54b4763
6
+ metadata.gz: 8b376e02bd42b7a66e90cc625ddc3f3c496305bad92916f6d2166fdcdf16d4b484535f35549f6d8c805a53b7b4a844757013cb51df449a841024d480cc3d9c1a
7
+ data.tar.gz: a73558879b836d5eb0a8df2e036a09edfad92f3cb6f766802e706afb20ed69377da9cf232ecb7b43e5ae2b0b455c958f9a03096fad7fef8c88aeeaeede6dcfc2
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  'goodguide-gibbon.gemspec',
18
18
  'lib/**/*.rb',
19
19
  'vendor/gibbon/package.json',
20
- 'vendor/gibbon/lib/gibbon.browser.js',
21
- 'vendor/gibbon/lib/gibbon.browser.dev.js',
20
+ 'vendor/gibbon/gibbon.browser.js',
21
+ 'vendor/gibbon/gibbon.browser.dev.js',
22
22
  ]
23
23
 
24
24
  # see ext/mkrf_conf.rb for therubyracer/therubyrhino dependency
@@ -1,7 +1,9 @@
1
+ require 'json' # stdlib
2
+
1
3
  module GoodGuide
2
4
  module Gibbon
3
5
  def self.version
4
- '0.10.3'
6
+ JSON.load(File.read('vendor/gibbon/package.json'))['version']
5
7
  end
6
8
  end
7
9
  end
@@ -108,11 +108,11 @@ module GoodGuide
108
108
  end
109
109
 
110
110
  def self.js_lib
111
- root.join('vendor/gibbon/lib/gibbon.browser.js')
111
+ root.join('vendor/gibbon/gibbon.browser.js')
112
112
  end
113
113
 
114
114
  def self.dev_js_lib
115
- root.join('vendor/gibbon/lib/gibbon.browser.dev.js')
115
+ root.join('vendor/gibbon/gibbon.browser.dev.js')
116
116
  end
117
117
 
118
118
  def self.js_source
@@ -2787,6 +2787,18 @@ Gibbon.Core = Core = (function(_super) {
2787
2787
  squishList: function() {
2788
2788
  return false;
2789
2789
  },
2790
+ foldList: function(list, out, arg, accumArg, idxArg, body) {
2791
+ if (list.alwaysFails()) {
2792
+ return true;
2793
+ }
2794
+ if (body.alwaysFails()) {
2795
+ return true;
2796
+ }
2797
+ if (body.isStrictIn(Core.variable(accumArg)) && out.alwaysFails()) {
2798
+ return true;
2799
+ }
2800
+ return false;
2801
+ },
2790
2802
  other: function() {
2791
2803
  var subtree, _i, _len, _ref10;
2792
2804
  _ref10 = this.subtrees();
@@ -3150,7 +3162,7 @@ Gibbon.Core = Core = (function(_super) {
3150
3162
  return "(LET " + (r(val)) + " " + (r(expr)) + ")";
3151
3163
  },
3152
3164
  variable: function(name) {
3153
- return name;
3165
+ return "v:" + name;
3154
3166
  },
3155
3167
  delist: function(e, i) {
3156
3168
  return "([" + (r(i)) + "] " + (r(e)) + ")";
@@ -3328,7 +3340,7 @@ Gibbon.optimize = (function() {
3328
3340
  depair: function(expr, key) {
3329
3341
  return recurse(expr).cases({
3330
3342
  pair: function() {
3331
- DEBUG.log("inlining lookup " + key + " of " + (this.inspect()));
3343
+ DEBUG.log("> inlining lookup " + key + " of " + (this.inspect()));
3332
3344
  return this[key];
3333
3345
  },
3334
3346
  other: function() {
@@ -3339,7 +3351,7 @@ Gibbon.optimize = (function() {
3339
3351
  delist: function(expr, index) {
3340
3352
  return recurse(expr).cases({
3341
3353
  list: function(els) {
3342
- DEBUG.log("inlining lookup " + index + " of " + (this.inspect()));
3354
+ DEBUG.log("> inlining lookup " + index + " of " + (this.inspect()));
3343
3355
  return els[index];
3344
3356
  },
3345
3357
  other: function() {
@@ -3354,7 +3366,7 @@ Gibbon.optimize = (function() {
3354
3366
  ifTrue = recurse(ifTrue);
3355
3367
  ifFalse = recurse(ifFalse);
3356
3368
  if (ifTrue.equals(ifFalse)) {
3357
- DEBUG.log("eliminating condition in equivalent branches: " + (this.inspect()));
3369
+ DEBUG.log("> eliminating condition in equivalent branches: " + (this.inspect()));
3358
3370
  return ifTrue;
3359
3371
  }
3360
3372
  return cond.branch(ifTrue, ifFalse);
@@ -3362,21 +3374,21 @@ Gibbon.optimize = (function() {
3362
3374
  return cond.cases({
3363
3375
  constant: function(value) {
3364
3376
  if (value) {
3365
- DEBUG.log("eliminating dead false branch " + (ifFalse.inspect()));
3377
+ DEBUG.log("> eliminating dead false branch " + (ifFalse.inspect()));
3366
3378
  return recurse(ifTrue);
3367
3379
  } else {
3368
- DEBUG.log("eliminating dead true branch " + (ifTrue.inspect()));
3380
+ DEBUG.log("> eliminating dead true branch " + (ifTrue.inspect()));
3369
3381
  return recurse(ifFalse);
3370
3382
  }
3371
3383
  },
3372
3384
  branch: function(innerCond, innerTrue, innerFalse) {
3373
3385
  debugger;
3374
- DEBUG.log("flattening nested branch " + (this.inspect()));
3386
+ DEBUG.log("> flattening nested branch " + (this.inspect()));
3375
3387
  return recurse(innerCond.branch(innerTrue.branch(ifTrue, ifFalse), innerFalse.branch(ifTrue, ifFalse)));
3376
3388
  },
3377
3389
  op1: function(name, arg) {
3378
3390
  if (name === '!') {
3379
- DEBUG.log("eliminating if negation in condition " + (this.inspect()));
3391
+ DEBUG.log("> eliminating if negation in condition " + (this.inspect()));
3380
3392
  return recurse(arg.branch(ifFalse, ifTrue));
3381
3393
  } else {
3382
3394
  return abort();
@@ -3388,7 +3400,7 @@ Gibbon.optimize = (function() {
3388
3400
  app: function(block, arg) {
3389
3401
  return recurse(block).cases({
3390
3402
  block: function(argName, body) {
3391
- DEBUG.log("inlining application of " + (this.inspect()) + " to " + (arg.inspect()));
3403
+ DEBUG.log("> inlining application of " + (this.inspect()) + " to " + (arg.inspect()));
3392
3404
  return recurse(body.subst(argName, arg));
3393
3405
  },
3394
3406
  other: function() {
@@ -3400,13 +3412,13 @@ Gibbon.optimize = (function() {
3400
3412
  return recurse(list).cases({
3401
3413
  list: function(elements) {
3402
3414
  var el, i, mapped;
3403
- DEBUG.log("inlining MAP");
3415
+ DEBUG.log("> inlining MAP");
3404
3416
  mapped = (function() {
3405
3417
  var _i, _len, _results;
3406
3418
  _results = [];
3407
3419
  for (i = _i = 0, _len = elements.length; _i < _len; i = ++_i) {
3408
3420
  el = elements[i];
3409
- DEBUG.log(("subst " + arg + "=" + (el.inspect()) + " ") + ("" + ixName + "=" + i + " " + (body.inspect())));
3421
+ DEBUG.log(("> subst " + arg + "=" + (el.inspect()) + " ") + ("" + ixName + "=" + i + " " + (body.inspect())));
3410
3422
  _results.push(recurse(body.subst(arg, el).subst(ixName, Core.constant(i))));
3411
3423
  }
3412
3424
  return _results;
@@ -3415,7 +3427,7 @@ Gibbon.optimize = (function() {
3415
3427
  },
3416
3428
  mapList: function(innerList, innerArg, innerIdxArg, innerBody) {
3417
3429
  var newBody;
3418
- DEBUG.log("fusing MAP of " + (this.inspect()));
3430
+ DEBUG.log("> fusing MAP of " + (this.inspect()));
3419
3431
  newBody = body.subst(arg, innerBody).subst(ixName, Core.variable(innerIdxArg));
3420
3432
  return recurse(Core.mapList(innerList, innerArg, innerIdxArg, newBody));
3421
3433
  },
@@ -3428,20 +3440,20 @@ Gibbon.optimize = (function() {
3428
3440
  return recurse(list).cases({
3429
3441
  list: function(elements) {
3430
3442
  var _loop;
3431
- DEBUG.log("inlining FOLDR");
3443
+ DEBUG.log("> inlining FOLDR");
3432
3444
  return recurse((_loop = function(i) {
3433
3445
  var next;
3434
3446
  if (i >= elements.length) {
3435
3447
  return recurse(out);
3436
3448
  }
3437
3449
  next = _loop(i + 1);
3438
- DEBUG.log(("subst " + arg + "=" + (elements[i].inspect()) + " ") + ("" + accum + "=" + (next.inspect()) + " ") + ("" + ixName + "=i " + (body.inspect())));
3450
+ DEBUG.log(("> subst " + arg + "=" + (elements[i].inspect()) + " ") + ("" + accum + "=" + (next.inspect()) + " ") + ("" + ixName + "=i " + (body.inspect())));
3439
3451
  return body.subst(arg, elements[i]).subst(accum, next).subst(ixName, Core.constant(i));
3440
3452
  })(0));
3441
3453
  },
3442
3454
  mapList: function(innerList, innerArg, innerIdxArg, mapBody) {
3443
3455
  var newBody;
3444
- DEBUG.log("fusing FOLDR of " + (this.inspect()));
3456
+ DEBUG.log("> fusing FOLDR of " + (this.inspect()));
3445
3457
  newBody = body.subst(arg, mapBody).subst(ixName, Core.variable(innerIdxArg));
3446
3458
  return Core.foldList(innerList, out, innerArg, accum, innerIdxArg, newBody);
3447
3459
  },
@@ -3453,15 +3465,15 @@ Gibbon.optimize = (function() {
3453
3465
  len: function(list) {
3454
3466
  return recurse(list).cases({
3455
3467
  list: function(elements) {
3456
- DEBUG.log("optimizing out len from " + (this.inspect()));
3468
+ DEBUG.log("> optimizing out len from " + (this.inspect()));
3457
3469
  return Core.constant(elements.length);
3458
3470
  },
3459
3471
  mapList: function(list) {
3460
- DEBUG.log("optimizing MAP out of len");
3472
+ DEBUG.log("> optimizing MAP out of len");
3461
3473
  return recurse(list.len());
3462
3474
  },
3463
3475
  zipLists: function(l, r) {
3464
- DEBUG.log("optimizing ZIP out of len");
3476
+ DEBUG.log("> optimizing ZIP out of len");
3465
3477
  return recurse(l.len());
3466
3478
  },
3467
3479
  other: function() {
@@ -3508,12 +3520,12 @@ Gibbon.optimize = (function() {
3508
3520
  if (checkConst(left, function(x) {
3509
3521
  return !isFinite(x);
3510
3522
  })) {
3511
- DEBUG.log("reducing comparison with infinite values");
3523
+ DEBUG.log("> reducing comparison with infinite values");
3512
3524
  right = Core.constant(0);
3513
3525
  } else if (checkConst(right, function(x) {
3514
3526
  return !isFinite(x);
3515
3527
  })) {
3516
- DEBUG.log("reducing comparison with infinite values");
3528
+ DEBUG.log("> reducing comparison with infinite values");
3517
3529
  left = Core.constant(0);
3518
3530
  }
3519
3531
  } else {
@@ -3524,24 +3536,24 @@ Gibbon.optimize = (function() {
3524
3536
  };
3525
3537
  identFold = checkIdent('*', right, 1, left) || checkIdent('*', left, 1, right) || checkIdent('*', right, 0, Core.constant(0)) || checkIdent('*', left, 0, Core.constant(0)) || checkIdent('+', left, 0, right) || checkIdent('+', right, 0, left) || checkIdent('/', right, 1, left);
3526
3538
  if (identFold) {
3527
- DEBUG.log("identity-folding " + (this.inspect()) + " to " + (identFold.inspect()));
3539
+ DEBUG.log("> identity-folding " + (this.inspect()) + " to " + (identFold.inspect()));
3528
3540
  return identFold;
3529
3541
  }
3530
3542
  }
3531
3543
  if (!(left._tag === 'constant' && right._tag === 'constant')) {
3532
3544
  return Core.op2(op, left, right);
3533
3545
  }
3534
- DEBUG.log("constant-folding " + (left.op2(op, right).inspect()));
3546
+ DEBUG.log("> constant-folding " + (left.op2(op, right).inspect()));
3535
3547
  _ref10 = [left.value, right.value], l = _ref10[0], r = _ref10[1];
3536
3548
  return Core.constant(applyOp2(op, left.value, right.value));
3537
3549
  },
3538
3550
  rescue: function(expr, default_) {
3539
3551
  expr = recurse(expr);
3540
3552
  if (expr.alwaysSucceeds()) {
3541
- DEBUG.log("eliminating dead default branch of " + (this.inspect()));
3553
+ DEBUG.log("> eliminating dead default branch of " + (this.inspect()));
3542
3554
  return expr;
3543
3555
  } else if (expr.alwaysFails()) {
3544
- DEBUG.log("eliminating dead main branch of " + (this.inspect()));
3556
+ DEBUG.log("> eliminating dead main branch of " + (this.inspect()));
3545
3557
  return recurse(default_);
3546
3558
  } else {
3547
3559
  return Core.rescue(expr, recurse(default_));
@@ -3604,7 +3616,7 @@ Gibbon.optimize = (function() {
3604
3616
  };
3605
3617
 
3606
3618
  SubstTree.prototype.substituteWith = function(names, bindableExprs) {
3607
- var bindable, core, hash, i, _i, _len;
3619
+ var bindable, core, hash, i, _i, _len, _ref11;
3608
3620
  core = this.toCore();
3609
3621
  hash = core.hash();
3610
3622
  for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
@@ -3613,6 +3625,9 @@ Gibbon.optimize = (function() {
3613
3625
  return SubstTree.unit(Core.variable(names[i]));
3614
3626
  }
3615
3627
  }
3628
+ if ((_ref11 = this.expr._tag) === 'rescue' || _ref11 === 'squishList') {
3629
+ return this;
3630
+ }
3616
3631
  return this.map(function(x) {
3617
3632
  return x.substituteWith(names, bindableExprs);
3618
3633
  });
@@ -3636,29 +3651,44 @@ Gibbon.optimize = (function() {
3636
3651
  return SubstTree.unit(Core.squishList(SubstTree.unit(list.map(insertSubstitutions))));
3637
3652
  },
3638
3653
  other: function() {
3639
- var bindable, i, names, out, substituted, _, _i, _len;
3640
- substituted = expr.map(function(t) {
3641
- return t.simplify();
3642
- });
3643
- names = (function() {
3644
- var _i, _len, _results;
3645
- _results = [];
3646
- for (_i = 0, _len = bindableExprs.length; _i < _len; _i++) {
3647
- _ = bindableExprs[_i];
3648
- _results.push(nameGen('b'));
3654
+ var bindable, i, names, out, _, _i, _len;
3655
+ if (bindableExprs.length) {
3656
+ names = (function() {
3657
+ var _i, _len, _results;
3658
+ _results = [];
3659
+ for (_i = 0, _len = bindableExprs.length; _i < _len; _i++) {
3660
+ _ = bindableExprs[_i];
3661
+ _results.push(nameGen('b'));
3662
+ }
3663
+ return _results;
3664
+ })();
3665
+ DEBUG(function() {
3666
+ var e, _bindableExprs, _expr, _names;
3667
+ _names = names.join(', ');
3668
+ _bindableExprs = ((function() {
3669
+ var _i, _len, _results;
3670
+ _results = [];
3671
+ for (_i = 0, _len = bindableExprs.length; _i < _len; _i++) {
3672
+ e = bindableExprs[_i];
3673
+ _results.push(e.inspect());
3674
+ }
3675
+ return _results;
3676
+ })()).join(', ');
3677
+ _expr = expr.inspect();
3678
+ return DEBUG.log("> binding " + _names + " as " + _bindableExprs + " in " + _expr);
3679
+ });
3680
+ out = SubstTree.unit(expr).substituteWith(names, bindableExprs);
3681
+ for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
3682
+ bindable = bindableExprs[i];
3683
+ out = SubstTree.unit(Core.bind(names[i], bindable, out));
3649
3684
  }
3650
- return _results;
3651
- })();
3652
- if (!bindableExprs.length) {
3653
- return SubstTree.unit(substituted);
3654
- }
3655
- out = SubstTree.unit(substituted).substituteWith(names, bindableExprs);
3656
- for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
3657
- bindable = bindableExprs[i];
3658
- out = SubstTree.unit(Core.bind(names[i], bindable, out));
3685
+ DEBUG.log("==> " + (out.inspect()));
3686
+ } else {
3687
+ out = SubstTree.unit(expr);
3659
3688
  }
3660
- DEBUG.log("=> " + (out.inspect()));
3661
- return out;
3689
+ return out.map(function(t) {
3690
+ return t.simplify();
3691
+ });
3662
3692
  }
3663
3693
  });
3664
3694
  };
@@ -3671,14 +3701,12 @@ Gibbon.optimize = (function() {
3671
3701
 
3672
3702
  })(Variant);
3673
3703
  makeCrumbs = function(trace) {
3674
- return trace.mapArray(function(e) {
3675
- return e.hash();
3676
- }).reverse();
3704
+ return trace.toArray().reverse();
3677
3705
  };
3678
3706
  genSubstitutions = function(expr) {
3679
3707
  var occurrences, queue, recurse, substitutions;
3680
3708
  occurrences = new ObjHash;
3681
- substitutions = new Hash;
3709
+ substitutions = new ObjHash;
3682
3710
  queue = [[expr, List.empty()]];
3683
3711
  while (queue.length) {
3684
3712
  (function(_arg) {
@@ -3710,6 +3738,24 @@ Gibbon.optimize = (function() {
3710
3738
  if (!(crumbs.length >= 2)) {
3711
3739
  return;
3712
3740
  }
3741
+ DEBUG(function() {
3742
+ var c, crumbList, _i, _len, _results;
3743
+ DEBUG.log("> found duplicate " + (expr.inspect()) + " at");
3744
+ _results = [];
3745
+ for (_i = 0, _len = crumbs.length; _i < _len; _i++) {
3746
+ crumbList = crumbs[_i];
3747
+ _results.push(DEBUG.log(((function() {
3748
+ var _j, _len1, _results1;
3749
+ _results1 = [];
3750
+ for (_j = 0, _len1 = crumbList.length; _j < _len1; _j++) {
3751
+ c = crumbList[_j];
3752
+ _results1.push(c.inspect());
3753
+ }
3754
+ return _results1;
3755
+ })()).reverse().join(' -> ')));
3756
+ }
3757
+ return _results;
3758
+ });
3713
3759
  insertionPoint = findLastCommon(crumbs);
3714
3760
  substitutions.cache(insertionPoint, function() {
3715
3761
  return [];
@@ -3718,7 +3764,7 @@ Gibbon.optimize = (function() {
3718
3764
  });
3719
3765
  return (recurse = function(expr) {
3720
3766
  var bindableExprs, e;
3721
- bindableExprs = substitutions.get(expr.hash());
3767
+ bindableExprs = substitutions.get(expr);
3722
3768
  if (!bindableExprs) {
3723
3769
  return SubstTree.unit(expr.map(recurse));
3724
3770
  }
@@ -3741,7 +3787,7 @@ Gibbon.optimize = (function() {
3741
3787
  refCrumb = reference[i];
3742
3788
  for (_j = 0, _len1 = rest.length; _j < _len1; _j++) {
3743
3789
  testCrumbs = rest[_j];
3744
- if (refCrumb !== testCrumbs[i]) {
3790
+ if (!refCrumb.equals(testCrumbs[i])) {
3745
3791
  return last;
3746
3792
  }
3747
3793
  }
@@ -3750,7 +3796,10 @@ Gibbon.optimize = (function() {
3750
3796
  return refCrumb;
3751
3797
  };
3752
3798
  insertSubstitutions = function(expr) {
3753
- return genSubstitutions(expr).simplify();
3799
+ var substitutions;
3800
+ substitutions = genSubstitutions(expr);
3801
+ DEBUG.log("=> generated " + (substitutions.inspect()));
3802
+ return substitutions.simplify();
3754
3803
  };
3755
3804
  return function(expr) {
3756
3805
  return insertSubstitutions(expr).toCore();
@@ -2755,6 +2755,18 @@ Gibbon.Core = Core = (function(_super) {
2755
2755
  squishList: function() {
2756
2756
  return false;
2757
2757
  },
2758
+ foldList: function(list, out, arg, accumArg, idxArg, body) {
2759
+ if (list.alwaysFails()) {
2760
+ return true;
2761
+ }
2762
+ if (body.alwaysFails()) {
2763
+ return true;
2764
+ }
2765
+ if (body.isStrictIn(Core.variable(accumArg)) && out.alwaysFails()) {
2766
+ return true;
2767
+ }
2768
+ return false;
2769
+ },
2758
2770
  other: function() {
2759
2771
  var subtree, _i, _len, _ref10;
2760
2772
  _ref10 = this.subtrees();
@@ -3118,7 +3130,7 @@ Gibbon.Core = Core = (function(_super) {
3118
3130
  return "(LET " + (r(val)) + " " + (r(expr)) + ")";
3119
3131
  },
3120
3132
  variable: function(name) {
3121
- return name;
3133
+ return "v:" + name;
3122
3134
  },
3123
3135
  delist: function(e, i) {
3124
3136
  return "([" + (r(i)) + "] " + (r(e)) + ")";
@@ -3572,7 +3584,7 @@ Gibbon.optimize = (function() {
3572
3584
  };
3573
3585
 
3574
3586
  SubstTree.prototype.substituteWith = function(names, bindableExprs) {
3575
- var bindable, core, hash, i, _i, _len;
3587
+ var bindable, core, hash, i, _i, _len, _ref11;
3576
3588
  core = this.toCore();
3577
3589
  hash = core.hash();
3578
3590
  for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
@@ -3581,6 +3593,9 @@ Gibbon.optimize = (function() {
3581
3593
  return SubstTree.unit(Core.variable(names[i]));
3582
3594
  }
3583
3595
  }
3596
+ if ((_ref11 = this.expr._tag) === 'rescue' || _ref11 === 'squishList') {
3597
+ return this;
3598
+ }
3584
3599
  return this.map(function(x) {
3585
3600
  return x.substituteWith(names, bindableExprs);
3586
3601
  });
@@ -3604,29 +3619,30 @@ Gibbon.optimize = (function() {
3604
3619
  return SubstTree.unit(Core.squishList(SubstTree.unit(list.map(insertSubstitutions))));
3605
3620
  },
3606
3621
  other: function() {
3607
- var bindable, i, names, out, substituted, _, _i, _len;
3608
- substituted = expr.map(function(t) {
3609
- return t.simplify();
3610
- });
3611
- names = (function() {
3612
- var _i, _len, _results;
3613
- _results = [];
3614
- for (_i = 0, _len = bindableExprs.length; _i < _len; _i++) {
3615
- _ = bindableExprs[_i];
3616
- _results.push(nameGen('b'));
3622
+ var bindable, i, names, out, _, _i, _len;
3623
+ if (bindableExprs.length) {
3624
+ names = (function() {
3625
+ var _i, _len, _results;
3626
+ _results = [];
3627
+ for (_i = 0, _len = bindableExprs.length; _i < _len; _i++) {
3628
+ _ = bindableExprs[_i];
3629
+ _results.push(nameGen('b'));
3630
+ }
3631
+ return _results;
3632
+ })();
3633
+
3634
+ out = SubstTree.unit(expr).substituteWith(names, bindableExprs);
3635
+ for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
3636
+ bindable = bindableExprs[i];
3637
+ out = SubstTree.unit(Core.bind(names[i], bindable, out));
3617
3638
  }
3618
- return _results;
3619
- })();
3620
- if (!bindableExprs.length) {
3621
- return SubstTree.unit(substituted);
3622
- }
3623
- out = SubstTree.unit(substituted).substituteWith(names, bindableExprs);
3624
- for (i = _i = 0, _len = bindableExprs.length; _i < _len; i = ++_i) {
3625
- bindable = bindableExprs[i];
3626
- out = SubstTree.unit(Core.bind(names[i], bindable, out));
3639
+
3640
+ } else {
3641
+ out = SubstTree.unit(expr);
3627
3642
  }
3628
-
3629
- return out;
3643
+ return out.map(function(t) {
3644
+ return t.simplify();
3645
+ });
3630
3646
  }
3631
3647
  });
3632
3648
  };
@@ -3639,14 +3655,12 @@ Gibbon.optimize = (function() {
3639
3655
 
3640
3656
  })(Variant);
3641
3657
  makeCrumbs = function(trace) {
3642
- return trace.mapArray(function(e) {
3643
- return e.hash();
3644
- }).reverse();
3658
+ return trace.toArray().reverse();
3645
3659
  };
3646
3660
  genSubstitutions = function(expr) {
3647
3661
  var occurrences, queue, recurse, substitutions;
3648
3662
  occurrences = new ObjHash;
3649
- substitutions = new Hash;
3663
+ substitutions = new ObjHash;
3650
3664
  queue = [[expr, List.empty()]];
3651
3665
  while (queue.length) {
3652
3666
  (function(_arg) {
@@ -3678,6 +3692,7 @@ Gibbon.optimize = (function() {
3678
3692
  if (!(crumbs.length >= 2)) {
3679
3693
  return;
3680
3694
  }
3695
+
3681
3696
  insertionPoint = findLastCommon(crumbs);
3682
3697
  substitutions.cache(insertionPoint, function() {
3683
3698
  return [];
@@ -3686,7 +3701,7 @@ Gibbon.optimize = (function() {
3686
3701
  });
3687
3702
  return (recurse = function(expr) {
3688
3703
  var bindableExprs, e;
3689
- bindableExprs = substitutions.get(expr.hash());
3704
+ bindableExprs = substitutions.get(expr);
3690
3705
  if (!bindableExprs) {
3691
3706
  return SubstTree.unit(expr.map(recurse));
3692
3707
  }
@@ -3709,7 +3724,7 @@ Gibbon.optimize = (function() {
3709
3724
  refCrumb = reference[i];
3710
3725
  for (_j = 0, _len1 = rest.length; _j < _len1; _j++) {
3711
3726
  testCrumbs = rest[_j];
3712
- if (refCrumb !== testCrumbs[i]) {
3727
+ if (!refCrumb.equals(testCrumbs[i])) {
3713
3728
  return last;
3714
3729
  }
3715
3730
  }
@@ -3718,7 +3733,10 @@ Gibbon.optimize = (function() {
3718
3733
  return refCrumb;
3719
3734
  };
3720
3735
  insertSubstitutions = function(expr) {
3721
- return genSubstitutions(expr).simplify();
3736
+ var substitutions;
3737
+ substitutions = genSubstitutions(expr);
3738
+
3739
+ return substitutions.simplify();
3722
3740
  };
3723
3741
  return function(expr) {
3724
3742
  return insertSubstitutions(expr).toCore();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gibbon",
3
- "version": "0.0.1",
3
+ "version": "0.11.0",
4
4
  "description": "A data language",
5
5
  "keywords": ["language"],
6
6
  "author": "Jay Adkisson <jjmadkisson at gmail dot com>",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodguide-gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Run and analyze gibbon code from ruby or a browser (via a ruby app).
14
14
  email:
@@ -23,8 +23,8 @@ files:
23
23
  - goodguide-gibbon.gemspec
24
24
  - lib/goodguide/gibbon.rb
25
25
  - lib/goodguide/gibbon/version.rb
26
- - vendor/gibbon/lib/gibbon.browser.dev.js
27
- - vendor/gibbon/lib/gibbon.browser.js
26
+ - vendor/gibbon/gibbon.browser.dev.js
27
+ - vendor/gibbon/gibbon.browser.js
28
28
  - vendor/gibbon/package.json
29
29
  homepage: http://github.com/GoodGuide/goodguide-gibbon
30
30
  licenses: []
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project: goodguide-gibbon
48
- rubygems_version: 2.2.0
48
+ rubygems_version: 2.2.2
49
49
  signing_key:
50
50
  specification_version: 4
51
51
  summary: Ruby bindings for the gibbon data language