goodguide-gibbon 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/goodguide/gibbon/version.rb +1 -1
- data/lib/goodguide/gibbon.rb +22 -11
- data/vendor/gibbon/lib/gibbon.browser.dev.js +154 -178
- data/vendor/gibbon/lib/gibbon.browser.js +150 -178
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1cfc211611af030db79283ed6f89abec9957553
|
4
|
+
data.tar.gz: dbdfcd341d94df018b8c3a6b8c56598e11860415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3d7d5ace0c22e100983b29887c572e6bb88178dbee10c8b3710860b3ae782556dd1fa9f22035630e2a0403218b11ce12f82669b1d62736697657258ba8ccb3
|
7
|
+
data.tar.gz: 620680f65d6a32b9b29592a1bf8225441f040184e62a25d6151a91a4886ec0999df8c22b6a7b1953b6571712b4208f7ae2a93125f69b85c289578112c4e49679
|
data/Gemfile
CHANGED
data/lib/goodguide/gibbon.rb
CHANGED
@@ -120,8 +120,9 @@ module GoodGuide
|
|
120
120
|
class SemanticError < StandardError
|
121
121
|
include Util
|
122
122
|
|
123
|
-
def initialize(errors)
|
123
|
+
def initialize(errors, context)
|
124
124
|
@errors = errors
|
125
|
+
@context = context
|
125
126
|
end
|
126
127
|
|
127
128
|
def messages
|
@@ -129,9 +130,8 @@ module GoodGuide
|
|
129
130
|
end
|
130
131
|
|
131
132
|
private
|
132
|
-
# needed for obj_to_js
|
133
133
|
def gibbon
|
134
|
-
|
134
|
+
@context.gibbon
|
135
135
|
end
|
136
136
|
|
137
137
|
def inspect_expr(expr)
|
@@ -197,7 +197,7 @@ module GoodGuide
|
|
197
197
|
syntax = context.parse(source)
|
198
198
|
semantics, errors = context.analyze(syntax, global, client.to_js)
|
199
199
|
|
200
|
-
raise SemanticError.new(errors) if errors
|
200
|
+
raise SemanticError.new(errors, context) if errors
|
201
201
|
|
202
202
|
compiled = context.compile(semantics)
|
203
203
|
|
@@ -222,7 +222,10 @@ module GoodGuide
|
|
222
222
|
def as_json
|
223
223
|
@as_json ||= {
|
224
224
|
'syntax' => @context.send(:obj_to_ruby, @syntax),
|
225
|
-
'compiled' =>
|
225
|
+
'compiled' => {
|
226
|
+
'semantics' => @context.send(:obj_to_ruby, @compiled.semantics),
|
227
|
+
'blocks' => @context.send(:obj_to_ruby, @compiled.blocks)
|
228
|
+
}
|
226
229
|
}
|
227
230
|
end
|
228
231
|
|
@@ -352,7 +355,7 @@ module GoodGuide
|
|
352
355
|
def parse(str)
|
353
356
|
obj_to_ruby self.gibbon.parse(str)
|
354
357
|
rescue JSError => e
|
355
|
-
raise SemanticError.new([{'_tag' => 'parse', 'message' => e.value}])
|
358
|
+
raise SemanticError.new([{'_tag' => 'parse', 'message' => e.value}], self)
|
356
359
|
end
|
357
360
|
|
358
361
|
def compile(semantics)
|
@@ -379,12 +382,18 @@ module GoodGuide
|
|
379
382
|
def capture(&b)
|
380
383
|
output = nil
|
381
384
|
error = nil
|
385
|
+
callback_called = false
|
386
|
+
|
382
387
|
b.call do |*args|
|
388
|
+
callback_called = true
|
389
|
+
|
383
390
|
# Rhino doesn't get "this", but V8 does.
|
384
391
|
args.shift unless defined?(JRUBY_VERSION)
|
385
392
|
error, output = args[0..1]
|
386
393
|
end
|
387
394
|
|
395
|
+
raise "callback never called" unless callback_called
|
396
|
+
|
388
397
|
[output, error]
|
389
398
|
end
|
390
399
|
end
|
@@ -395,11 +404,13 @@ module GoodGuide
|
|
395
404
|
end
|
396
405
|
|
397
406
|
class Console
|
398
|
-
|
399
|
-
|
400
|
-
proc { |*a| puts a.map(&:to_s).join(' ') }
|
401
|
-
|
402
|
-
|
407
|
+
if defined?(JRUBY_VERSION)
|
408
|
+
def log
|
409
|
+
@log ||= proc { |*a| puts a.map(&:to_s).join(' ') }
|
410
|
+
end
|
411
|
+
else
|
412
|
+
def log
|
413
|
+
@log ||= proc { |_, *a| puts a.map(&:to_s).join(' ') }
|
403
414
|
end
|
404
415
|
end
|
405
416
|
end
|
@@ -420,7 +420,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
|
|
420
420
|
return Parsimmon;
|
421
421
|
})()
|
422
422
|
// Generated by CoffeeScript 1.6.3
|
423
|
-
var AST, CachingPromise,
|
423
|
+
var AST, CachingPromise, CompiledCode, ContinuationTrace, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, Promise, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, UnitPromise, Value, VarTrace, Variant, allocate, analyze, applyOp1, applyOp2, asyncMap, catLists, contIter, contMap, equalArrays, eval_, genId, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
|
424
424
|
__slice = [].slice,
|
425
425
|
__hasProp = {}.hasOwnProperty,
|
426
426
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
@@ -807,6 +807,15 @@ Map = (function() {
|
|
807
807
|
});
|
808
808
|
};
|
809
809
|
|
810
|
+
Map.prototype.size = function() {
|
811
|
+
var out;
|
812
|
+
out = 0;
|
813
|
+
this.each(function() {
|
814
|
+
return out += 1;
|
815
|
+
});
|
816
|
+
return out;
|
817
|
+
};
|
818
|
+
|
810
819
|
Map.prototype.keys = function() {
|
811
820
|
var out;
|
812
821
|
out = [];
|
@@ -825,6 +834,25 @@ Map = (function() {
|
|
825
834
|
return out;
|
826
835
|
};
|
827
836
|
|
837
|
+
Map.prototype.eachAsync = function(f, cb) {
|
838
|
+
var isAsync, output, remaining, responder;
|
839
|
+
output = null;
|
840
|
+
remaining = this.size();
|
841
|
+
responder = function(k) {
|
842
|
+
return function() {
|
843
|
+
remaining -= 1;
|
844
|
+
if (remaining <= 0) {
|
845
|
+
return output = cb();
|
846
|
+
}
|
847
|
+
};
|
848
|
+
};
|
849
|
+
this.each(function(k, v) {
|
850
|
+
return f(k, v, responder(k));
|
851
|
+
});
|
852
|
+
isAsync = true;
|
853
|
+
return output;
|
854
|
+
};
|
855
|
+
|
828
856
|
return Map;
|
829
857
|
|
830
858
|
})();
|
@@ -873,9 +901,7 @@ Gibbon.Hash = Hash = (function(_super) {
|
|
873
901
|
for (k in this) {
|
874
902
|
if (!__hasProp.call(this, k)) continue;
|
875
903
|
v = this[k];
|
876
|
-
|
877
|
-
_results.push(f(k.slice(saltLen), v));
|
878
|
-
}
|
904
|
+
_results.push(f(k.slice(saltLen), v));
|
879
905
|
}
|
880
906
|
return _results;
|
881
907
|
};
|
@@ -921,124 +947,6 @@ Gibbon.ObjHash = ObjHash = (function(_super) {
|
|
921
947
|
|
922
948
|
return ObjHash;
|
923
949
|
|
924
|
-
})(Hash);
|
925
|
-
|
926
|
-
CompMap = (function(_super) {
|
927
|
-
__extends(CompMap, _super);
|
928
|
-
|
929
|
-
function CompMap(fn) {
|
930
|
-
if (fn == null) {
|
931
|
-
fn = (function(x, y) {
|
932
|
-
return x === y;
|
933
|
-
});
|
934
|
-
}
|
935
|
-
CompMap.__super__.constructor.apply(this, arguments);
|
936
|
-
this.compare = fn;
|
937
|
-
this.keys = [];
|
938
|
-
this.values = [];
|
939
|
-
}
|
940
|
-
|
941
|
-
CompMap.prototype.addBinding = function(k, v) {
|
942
|
-
this.keys.push(k);
|
943
|
-
this.values.push(v);
|
944
|
-
return v;
|
945
|
-
};
|
946
|
-
|
947
|
-
CompMap.prototype.keyIndex = function(k) {
|
948
|
-
var i, key, _i, _len, _ref2;
|
949
|
-
_ref2 = this.keys;
|
950
|
-
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
951
|
-
key = _ref2[i];
|
952
|
-
if (this.compare(key, k)) {
|
953
|
-
return i;
|
954
|
-
}
|
955
|
-
}
|
956
|
-
return null;
|
957
|
-
};
|
958
|
-
|
959
|
-
CompMap.prototype.has = function(k) {
|
960
|
-
return this.keyIndex(k) != null;
|
961
|
-
};
|
962
|
-
|
963
|
-
CompMap.prototype.get = function(k) {
|
964
|
-
var index;
|
965
|
-
index = this.keyIndex(k);
|
966
|
-
return (index != null) && this.values[index];
|
967
|
-
};
|
968
|
-
|
969
|
-
CompMap.prototype.set = function(k, v) {
|
970
|
-
var index;
|
971
|
-
index = this.keyIndex(k);
|
972
|
-
if (index != null) {
|
973
|
-
return this.values[index] = v;
|
974
|
-
} else {
|
975
|
-
return this.addBinding(k, v);
|
976
|
-
}
|
977
|
-
};
|
978
|
-
|
979
|
-
CompMap.prototype.each = function(f) {
|
980
|
-
var i, k, _i, _len, _ref2, _results;
|
981
|
-
_ref2 = this.keys;
|
982
|
-
_results = [];
|
983
|
-
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
984
|
-
k = _ref2[i];
|
985
|
-
_results.push(f(k, this.values[i]));
|
986
|
-
}
|
987
|
-
return _results;
|
988
|
-
};
|
989
|
-
|
990
|
-
CompMap.prototype.eachAsync = function(f, cb) {
|
991
|
-
var i, k, keys, output, responder, seen, _i, _len;
|
992
|
-
keys = this.keys;
|
993
|
-
if (keys.length === 0) {
|
994
|
-
return;
|
995
|
-
}
|
996
|
-
output = null;
|
997
|
-
seen = 0;
|
998
|
-
responder = function(i) {
|
999
|
-
return function() {
|
1000
|
-
seen += 1;
|
1001
|
-
if (seen >= keys.length) {
|
1002
|
-
return output = cb();
|
1003
|
-
}
|
1004
|
-
};
|
1005
|
-
};
|
1006
|
-
for (i = _i = 0, _len = keys.length; _i < _len; i = ++_i) {
|
1007
|
-
k = keys[i];
|
1008
|
-
f(k, this.values[i], responder(i));
|
1009
|
-
}
|
1010
|
-
return output;
|
1011
|
-
};
|
1012
|
-
|
1013
|
-
CompMap.prototype.fetch = function(k, f) {
|
1014
|
-
var index;
|
1015
|
-
index = this.keyIndex(k);
|
1016
|
-
if (index != null) {
|
1017
|
-
return this.values[index];
|
1018
|
-
} else {
|
1019
|
-
return f();
|
1020
|
-
}
|
1021
|
-
};
|
1022
|
-
|
1023
|
-
CompMap.prototype.fetchAsync = function(k, f, cb) {
|
1024
|
-
var index;
|
1025
|
-
index = this.keyIndex(k);
|
1026
|
-
if (index != null) {
|
1027
|
-
return cb(this.values[index]);
|
1028
|
-
} else {
|
1029
|
-
return f(cb);
|
1030
|
-
}
|
1031
|
-
};
|
1032
|
-
|
1033
|
-
CompMap.prototype.cache = function(k, f) {
|
1034
|
-
var _this = this;
|
1035
|
-
return this.fetch(k, function() {
|
1036
|
-
return _this.addBinding(k, f());
|
1037
|
-
});
|
1038
|
-
};
|
1039
|
-
|
1040
|
-
return CompMap;
|
1041
|
-
|
1042
950
|
})(Map);
|
1043
951
|
|
1044
952
|
List = (function(_super) {
|
@@ -1123,6 +1031,10 @@ Gibbon.AST = AST = (function(_super) {
|
|
1123
1031
|
return out.join('');
|
1124
1032
|
};
|
1125
1033
|
|
1034
|
+
AST.prototype.hash = function() {
|
1035
|
+
return "" + this.loc.start + "-" + this.loc.end;
|
1036
|
+
};
|
1037
|
+
|
1126
1038
|
AST.prototype.inspect = function() {
|
1127
1039
|
var useValue;
|
1128
1040
|
useValue = function(_, x) {
|
@@ -1708,6 +1620,8 @@ Gibbon.Type = Type = (function(_super) {
|
|
1708
1620
|
})(Variant);
|
1709
1621
|
|
1710
1622
|
Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
1623
|
+
var uniqError;
|
1624
|
+
|
1711
1625
|
__extends(TypeExpr, _super);
|
1712
1626
|
|
1713
1627
|
function TypeExpr() {
|
@@ -1717,7 +1631,7 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1717
1631
|
|
1718
1632
|
TypeExpr.variants({
|
1719
1633
|
expr: ['expr'],
|
1720
|
-
variable: ['name'],
|
1634
|
+
variable: ['name', 'uniq'],
|
1721
1635
|
query: ['input', 'scope', 'query'],
|
1722
1636
|
destructure: ['constraint', 'name', 'argnum'],
|
1723
1637
|
"native": ['id'],
|
@@ -1766,8 +1680,8 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1766
1680
|
return _results;
|
1767
1681
|
})()).join(' ')) + ")";
|
1768
1682
|
},
|
1769
|
-
variable: function(name) {
|
1770
|
-
return "%" + name;
|
1683
|
+
variable: function(name, uniq) {
|
1684
|
+
return "%" + name + uniq;
|
1771
1685
|
},
|
1772
1686
|
query: function(input, _, query) {
|
1773
1687
|
return "" + (input.inspect()) + "[" + (query.inspect()) + "]";
|
@@ -1813,7 +1727,6 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1813
1727
|
};
|
1814
1728
|
|
1815
1729
|
TypeExpr.prototype.equals = function(other) {
|
1816
|
-
var _this = this;
|
1817
1730
|
if (this._tag !== other._tag) {
|
1818
1731
|
return false;
|
1819
1732
|
}
|
@@ -1855,46 +1768,94 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1855
1768
|
}
|
1856
1769
|
return constraint.equals(other.constraint);
|
1857
1770
|
},
|
1858
|
-
|
1859
|
-
return
|
1771
|
+
any: function() {
|
1772
|
+
return true;
|
1773
|
+
},
|
1774
|
+
variable: function(_, uniq) {
|
1775
|
+
return uniq === other.uniq;
|
1860
1776
|
}
|
1861
1777
|
});
|
1862
1778
|
};
|
1863
1779
|
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1780
|
+
uniqError = 0;
|
1781
|
+
|
1782
|
+
TypeExpr.prototype.hash = function() {
|
1783
|
+
var recurse;
|
1784
|
+
return this.__hash__ || (this.__hash__ = (recurse = function(texpr) {
|
1785
|
+
return texpr.cases({
|
1786
|
+
expr: function(e) {
|
1787
|
+
return "<" + (e.hash()) + ">";
|
1788
|
+
},
|
1789
|
+
query: function(input, scope, query) {
|
1790
|
+
return "" + (query.inspect()) + ":" + scope.uniq + "[" + (recurse(input)) + "]";
|
1791
|
+
},
|
1792
|
+
"native": function(id) {
|
1793
|
+
return "!" + id;
|
1794
|
+
},
|
1795
|
+
param: function(name, constraints) {
|
1796
|
+
var c;
|
1797
|
+
return "(" + name + " " + (((function() {
|
1798
|
+
var _i, _len, _results;
|
1799
|
+
_results = [];
|
1800
|
+
for (_i = 0, _len = constraints.length; _i < _len; _i++) {
|
1801
|
+
c = constraints[_i];
|
1802
|
+
_results.push(recurse(c));
|
1803
|
+
}
|
1804
|
+
return _results;
|
1805
|
+
})()).join(' ')) + ")";
|
1806
|
+
},
|
1807
|
+
destructure: function(constraint, name, argnum) {
|
1808
|
+
return "" + (recurse(constraint)) + "/" + name + "[" + argnum + "]";
|
1809
|
+
},
|
1810
|
+
any: function() {
|
1811
|
+
return '*';
|
1812
|
+
},
|
1813
|
+
variable: function(name, uniq) {
|
1814
|
+
return "%" + uniq;
|
1815
|
+
},
|
1816
|
+
error: function() {
|
1817
|
+
return "!" + (uniqError += 1);
|
1874
1818
|
}
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1819
|
+
});
|
1820
|
+
})(this));
|
1821
|
+
};
|
1822
|
+
|
1823
|
+
TypeExpr.fromAST = function(typeAST, scope, genUniq) {
|
1824
|
+
var r;
|
1825
|
+
return (r = function(typeAST) {
|
1826
|
+
var e;
|
1827
|
+
e = TypeExpr;
|
1828
|
+
return typeAST.cases({
|
1829
|
+
concrete: function(name) {
|
1830
|
+
DEBUG(function() {
|
1831
|
+
if (typeof Type[name] !== 'function') {
|
1832
|
+
throw new Error("unknown type " + name);
|
1833
|
+
}
|
1834
|
+
});
|
1835
|
+
return TypeExpr.param(name, []);
|
1836
|
+
},
|
1837
|
+
variable: function(name) {
|
1838
|
+
return scope.cache(name, function() {
|
1839
|
+
return TypeExpr.variable(name, genUniq());
|
1840
|
+
});
|
1841
|
+
},
|
1842
|
+
"native": function(id) {
|
1843
|
+
return TypeExpr["native"](id);
|
1844
|
+
},
|
1845
|
+
wildcard: function() {
|
1846
|
+
return TypeExpr.any();
|
1847
|
+
},
|
1848
|
+
list: function(el) {
|
1849
|
+
return e.param('list', [r(el)]);
|
1850
|
+
},
|
1851
|
+
block: function(el) {
|
1852
|
+
return e.param('block', [r(el.from), r(el.to)]);
|
1853
|
+
},
|
1854
|
+
pair: function(first, second) {
|
1855
|
+
return e.param('pair', [r(first), r(second)]);
|
1856
|
+
}
|
1857
|
+
});
|
1858
|
+
})(typeAST);
|
1898
1859
|
};
|
1899
1860
|
|
1900
1861
|
TypeExpr.fromType = function(t) {
|
@@ -1975,15 +1936,28 @@ analyze = Gibbon.analyze = (function() {
|
|
1975
1936
|
function NativeContext(globalID, externalLookup) {
|
1976
1937
|
this.globalID = globalID;
|
1977
1938
|
this.externalLookup = externalLookup;
|
1939
|
+
this.queryCache = new Hash;
|
1940
|
+
this.genUniq = (function() {
|
1941
|
+
var i;
|
1942
|
+
i = 0;
|
1943
|
+
return function() {
|
1944
|
+
return i += 1;
|
1945
|
+
};
|
1946
|
+
})();
|
1978
1947
|
}
|
1979
1948
|
|
1980
1949
|
NativeContext.prototype.query = function(id, query, cb) {
|
1950
|
+
var cacheKey,
|
1951
|
+
_this = this;
|
1952
|
+
cacheKey = "" + id + "/" + query.type + " " + (query.args.join(' '));
|
1953
|
+
if (this.queryCache.has(cacheKey)) {
|
1954
|
+
return Thunk.trampoline(cb(this.queryCache.get(cacheKey)));
|
1955
|
+
}
|
1981
1956
|
return this.externalLookup.call(null, id, query, Type, function(err, analysis) {
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
}
|
1957
|
+
var result;
|
1958
|
+
result = err ? TypeLookup.error(err) : TypeLookup.response(query, analysis);
|
1959
|
+
_this.queryCache.set(cacheKey, result);
|
1960
|
+
return Thunk.trampoline(cb(result));
|
1987
1961
|
});
|
1988
1962
|
};
|
1989
1963
|
|
@@ -2003,6 +1977,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2003
1977
|
this.frame = frame;
|
2004
1978
|
this.context = context;
|
2005
1979
|
this.bindings = new Hash;
|
1980
|
+
this.uniq = this.context.genUniq();
|
2006
1981
|
}
|
2007
1982
|
|
2008
1983
|
Scope.prototype.extend = function(name, frame) {
|
@@ -2087,7 +2062,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2087
2062
|
return push(TypeExpr.expr(flow), TypeExpr.param('pair', [TypeExpr.expr(first), TypeExpr.expr(second)]));
|
2088
2063
|
},
|
2089
2064
|
func: function(_, name, args) {
|
2090
|
-
var arg, ast, func, i, input, scope, _i, _len, _results;
|
2065
|
+
var arg, ast, func, genUniq, i, input, scope, _i, _len, _results;
|
2091
2066
|
if (!stdlib.hasOwnProperty(name)) {
|
2092
2067
|
push(TypeExpr.expr(flow.head), TypeExpr.error('func', [flow.head]));
|
2093
2068
|
return;
|
@@ -2096,17 +2071,18 @@ analyze = Gibbon.analyze = (function() {
|
|
2096
2071
|
ast = func.type;
|
2097
2072
|
scope = new Hash;
|
2098
2073
|
flow.head.__scope__ = scope;
|
2099
|
-
|
2074
|
+
genUniq = _this.context.genUniq;
|
2075
|
+
input = TypeExpr.fromAST(ast.input, scope, genUniq);
|
2100
2076
|
if (flow.tail) {
|
2101
2077
|
push(TypeExpr.expr(flow.tail), input);
|
2102
2078
|
} else {
|
2103
2079
|
push(input, global);
|
2104
2080
|
}
|
2105
|
-
push(TypeExpr.expr(flow), TypeExpr.fromAST(ast.output, scope));
|
2081
|
+
push(TypeExpr.expr(flow), TypeExpr.fromAST(ast.output, scope, genUniq));
|
2106
2082
|
_results = [];
|
2107
2083
|
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
|
2108
2084
|
arg = args[i];
|
2109
|
-
push(TypeExpr.expr(arg), TypeExpr.fromAST(ast.args[i], scope));
|
2085
|
+
push(TypeExpr.expr(arg), TypeExpr.fromAST(ast.args[i], scope, genUniq));
|
2110
2086
|
_results.push(_this.analyzeFlow(arg, global, push));
|
2111
2087
|
}
|
2112
2088
|
return _results;
|
@@ -2126,7 +2102,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2126
2102
|
},
|
2127
2103
|
list: function(_, elements) {
|
2128
2104
|
var el, elVar, _i, _len, _results;
|
2129
|
-
elVar = TypeExpr.variable('el');
|
2105
|
+
elVar = TypeExpr.variable('el', _this.context.genUniq());
|
2130
2106
|
push(TypeExpr.expr(flow), TypeExpr.param('list', [elVar]));
|
2131
2107
|
_results = [];
|
2132
2108
|
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
@@ -2138,7 +2114,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2138
2114
|
},
|
2139
2115
|
block: function(_, subFlow) {
|
2140
2116
|
var input;
|
2141
|
-
input = TypeExpr.variable('.input');
|
2117
|
+
input = TypeExpr.variable('.input', _this.context.genUniq());
|
2142
2118
|
push(TypeExpr.expr(flow), TypeExpr.param('block', [input, TypeExpr.expr(subFlow)]));
|
2143
2119
|
return _this.analyzeFlow(subFlow, input, push);
|
2144
2120
|
},
|
@@ -2236,9 +2212,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2236
2212
|
return function(constraintMap, finish) {
|
2237
2213
|
var errors, frameTypes, initialCrumbs, k, locks, semantics, solutions, solveEntry;
|
2238
2214
|
errors = [];
|
2239
|
-
solutions = new
|
2240
|
-
return x.equals(y);
|
2241
|
-
});
|
2215
|
+
solutions = new ObjHash;
|
2242
2216
|
semantics = new Hash;
|
2243
2217
|
frameTypes = new Hash;
|
2244
2218
|
locks = new Hash;
|
@@ -2252,7 +2226,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2252
2226
|
_ref10 = constraintMap.get(key), frame = _ref10.frame, constraints = _ref10.constraints;
|
2253
2227
|
DEBUG.log('locking', key);
|
2254
2228
|
locks.set(key, true);
|
2255
|
-
semanticAccessors = new
|
2229
|
+
semanticAccessors = new ObjHash;
|
2256
2230
|
dependencies = [];
|
2257
2231
|
DEBUG(function() {
|
2258
2232
|
var lhs, rhs, _i, _len, _ref11, _results;
|
@@ -2264,9 +2238,11 @@ analyze = Gibbon.analyze = (function() {
|
|
2264
2238
|
return _results;
|
2265
2239
|
});
|
2266
2240
|
substitute = function(texpr, cb) {
|
2267
|
-
|
2241
|
+
if (solutions.has(texpr)) {
|
2242
|
+
return cb(solutions.get(texpr));
|
2243
|
+
} else {
|
2268
2244
|
return texpr.mapAsync(substitute, cb);
|
2269
|
-
}
|
2245
|
+
}
|
2270
2246
|
};
|
2271
2247
|
fullSubstitute = function(texpr, cb) {
|
2272
2248
|
return substitute(texpr, function(substituted) {
|
@@ -420,7 +420,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
|
|
420
420
|
return Parsimmon;
|
421
421
|
})()
|
422
422
|
// Generated by CoffeeScript 1.6.3
|
423
|
-
var AST, CachingPromise,
|
423
|
+
var AST, CachingPromise, CompiledCode, ContinuationTrace, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, Promise, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, UnitPromise, Value, VarTrace, Variant, allocate, analyze, applyOp1, applyOp2, asyncMap, catLists, contIter, contMap, equalArrays, eval_, genId, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
|
424
424
|
__slice = [].slice,
|
425
425
|
__hasProp = {}.hasOwnProperty,
|
426
426
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
@@ -797,6 +797,15 @@ Map = (function() {
|
|
797
797
|
});
|
798
798
|
};
|
799
799
|
|
800
|
+
Map.prototype.size = function() {
|
801
|
+
var out;
|
802
|
+
out = 0;
|
803
|
+
this.each(function() {
|
804
|
+
return out += 1;
|
805
|
+
});
|
806
|
+
return out;
|
807
|
+
};
|
808
|
+
|
800
809
|
Map.prototype.keys = function() {
|
801
810
|
var out;
|
802
811
|
out = [];
|
@@ -815,6 +824,25 @@ Map = (function() {
|
|
815
824
|
return out;
|
816
825
|
};
|
817
826
|
|
827
|
+
Map.prototype.eachAsync = function(f, cb) {
|
828
|
+
var isAsync, output, remaining, responder;
|
829
|
+
output = null;
|
830
|
+
remaining = this.size();
|
831
|
+
responder = function(k) {
|
832
|
+
return function() {
|
833
|
+
remaining -= 1;
|
834
|
+
if (remaining <= 0) {
|
835
|
+
return output = cb();
|
836
|
+
}
|
837
|
+
};
|
838
|
+
};
|
839
|
+
this.each(function(k, v) {
|
840
|
+
return f(k, v, responder(k));
|
841
|
+
});
|
842
|
+
isAsync = true;
|
843
|
+
return output;
|
844
|
+
};
|
845
|
+
|
818
846
|
return Map;
|
819
847
|
|
820
848
|
})();
|
@@ -863,9 +891,7 @@ Gibbon.Hash = Hash = (function(_super) {
|
|
863
891
|
for (k in this) {
|
864
892
|
if (!__hasProp.call(this, k)) continue;
|
865
893
|
v = this[k];
|
866
|
-
|
867
|
-
_results.push(f(k.slice(saltLen), v));
|
868
|
-
}
|
894
|
+
_results.push(f(k.slice(saltLen), v));
|
869
895
|
}
|
870
896
|
return _results;
|
871
897
|
};
|
@@ -911,124 +937,6 @@ Gibbon.ObjHash = ObjHash = (function(_super) {
|
|
911
937
|
|
912
938
|
return ObjHash;
|
913
939
|
|
914
|
-
})(Hash);
|
915
|
-
|
916
|
-
CompMap = (function(_super) {
|
917
|
-
__extends(CompMap, _super);
|
918
|
-
|
919
|
-
function CompMap(fn) {
|
920
|
-
if (fn == null) {
|
921
|
-
fn = (function(x, y) {
|
922
|
-
return x === y;
|
923
|
-
});
|
924
|
-
}
|
925
|
-
CompMap.__super__.constructor.apply(this, arguments);
|
926
|
-
this.compare = fn;
|
927
|
-
this.keys = [];
|
928
|
-
this.values = [];
|
929
|
-
}
|
930
|
-
|
931
|
-
CompMap.prototype.addBinding = function(k, v) {
|
932
|
-
this.keys.push(k);
|
933
|
-
this.values.push(v);
|
934
|
-
return v;
|
935
|
-
};
|
936
|
-
|
937
|
-
CompMap.prototype.keyIndex = function(k) {
|
938
|
-
var i, key, _i, _len, _ref2;
|
939
|
-
_ref2 = this.keys;
|
940
|
-
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
941
|
-
key = _ref2[i];
|
942
|
-
if (this.compare(key, k)) {
|
943
|
-
return i;
|
944
|
-
}
|
945
|
-
}
|
946
|
-
return null;
|
947
|
-
};
|
948
|
-
|
949
|
-
CompMap.prototype.has = function(k) {
|
950
|
-
return this.keyIndex(k) != null;
|
951
|
-
};
|
952
|
-
|
953
|
-
CompMap.prototype.get = function(k) {
|
954
|
-
var index;
|
955
|
-
index = this.keyIndex(k);
|
956
|
-
return (index != null) && this.values[index];
|
957
|
-
};
|
958
|
-
|
959
|
-
CompMap.prototype.set = function(k, v) {
|
960
|
-
var index;
|
961
|
-
index = this.keyIndex(k);
|
962
|
-
if (index != null) {
|
963
|
-
return this.values[index] = v;
|
964
|
-
} else {
|
965
|
-
return this.addBinding(k, v);
|
966
|
-
}
|
967
|
-
};
|
968
|
-
|
969
|
-
CompMap.prototype.each = function(f) {
|
970
|
-
var i, k, _i, _len, _ref2, _results;
|
971
|
-
_ref2 = this.keys;
|
972
|
-
_results = [];
|
973
|
-
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
974
|
-
k = _ref2[i];
|
975
|
-
_results.push(f(k, this.values[i]));
|
976
|
-
}
|
977
|
-
return _results;
|
978
|
-
};
|
979
|
-
|
980
|
-
CompMap.prototype.eachAsync = function(f, cb) {
|
981
|
-
var i, k, keys, output, responder, seen, _i, _len;
|
982
|
-
keys = this.keys;
|
983
|
-
if (keys.length === 0) {
|
984
|
-
return;
|
985
|
-
}
|
986
|
-
output = null;
|
987
|
-
seen = 0;
|
988
|
-
responder = function(i) {
|
989
|
-
return function() {
|
990
|
-
seen += 1;
|
991
|
-
if (seen >= keys.length) {
|
992
|
-
return output = cb();
|
993
|
-
}
|
994
|
-
};
|
995
|
-
};
|
996
|
-
for (i = _i = 0, _len = keys.length; _i < _len; i = ++_i) {
|
997
|
-
k = keys[i];
|
998
|
-
f(k, this.values[i], responder(i));
|
999
|
-
}
|
1000
|
-
return output;
|
1001
|
-
};
|
1002
|
-
|
1003
|
-
CompMap.prototype.fetch = function(k, f) {
|
1004
|
-
var index;
|
1005
|
-
index = this.keyIndex(k);
|
1006
|
-
if (index != null) {
|
1007
|
-
return this.values[index];
|
1008
|
-
} else {
|
1009
|
-
return f();
|
1010
|
-
}
|
1011
|
-
};
|
1012
|
-
|
1013
|
-
CompMap.prototype.fetchAsync = function(k, f, cb) {
|
1014
|
-
var index;
|
1015
|
-
index = this.keyIndex(k);
|
1016
|
-
if (index != null) {
|
1017
|
-
return cb(this.values[index]);
|
1018
|
-
} else {
|
1019
|
-
return f(cb);
|
1020
|
-
}
|
1021
|
-
};
|
1022
|
-
|
1023
|
-
CompMap.prototype.cache = function(k, f) {
|
1024
|
-
var _this = this;
|
1025
|
-
return this.fetch(k, function() {
|
1026
|
-
return _this.addBinding(k, f());
|
1027
|
-
});
|
1028
|
-
};
|
1029
|
-
|
1030
|
-
return CompMap;
|
1031
|
-
|
1032
940
|
})(Map);
|
1033
941
|
|
1034
942
|
List = (function(_super) {
|
@@ -1113,6 +1021,10 @@ Gibbon.AST = AST = (function(_super) {
|
|
1113
1021
|
return out.join('');
|
1114
1022
|
};
|
1115
1023
|
|
1024
|
+
AST.prototype.hash = function() {
|
1025
|
+
return "" + this.loc.start + "-" + this.loc.end;
|
1026
|
+
};
|
1027
|
+
|
1116
1028
|
AST.prototype.inspect = function() {
|
1117
1029
|
var useValue;
|
1118
1030
|
useValue = function(_, x) {
|
@@ -1698,6 +1610,8 @@ Gibbon.Type = Type = (function(_super) {
|
|
1698
1610
|
})(Variant);
|
1699
1611
|
|
1700
1612
|
Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
1613
|
+
var uniqError;
|
1614
|
+
|
1701
1615
|
__extends(TypeExpr, _super);
|
1702
1616
|
|
1703
1617
|
function TypeExpr() {
|
@@ -1707,7 +1621,7 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1707
1621
|
|
1708
1622
|
TypeExpr.variants({
|
1709
1623
|
expr: ['expr'],
|
1710
|
-
variable: ['name'],
|
1624
|
+
variable: ['name', 'uniq'],
|
1711
1625
|
query: ['input', 'scope', 'query'],
|
1712
1626
|
destructure: ['constraint', 'name', 'argnum'],
|
1713
1627
|
"native": ['id'],
|
@@ -1756,8 +1670,8 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1756
1670
|
return _results;
|
1757
1671
|
})()).join(' ')) + ")";
|
1758
1672
|
},
|
1759
|
-
variable: function(name) {
|
1760
|
-
return "%" + name;
|
1673
|
+
variable: function(name, uniq) {
|
1674
|
+
return "%" + name + uniq;
|
1761
1675
|
},
|
1762
1676
|
query: function(input, _, query) {
|
1763
1677
|
return "" + (input.inspect()) + "[" + (query.inspect()) + "]";
|
@@ -1803,7 +1717,6 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1803
1717
|
};
|
1804
1718
|
|
1805
1719
|
TypeExpr.prototype.equals = function(other) {
|
1806
|
-
var _this = this;
|
1807
1720
|
if (this._tag !== other._tag) {
|
1808
1721
|
return false;
|
1809
1722
|
}
|
@@ -1845,46 +1758,90 @@ Gibbon.TypeExpr = TypeExpr = (function(_super) {
|
|
1845
1758
|
}
|
1846
1759
|
return constraint.equals(other.constraint);
|
1847
1760
|
},
|
1848
|
-
|
1849
|
-
return
|
1761
|
+
any: function() {
|
1762
|
+
return true;
|
1763
|
+
},
|
1764
|
+
variable: function(_, uniq) {
|
1765
|
+
return uniq === other.uniq;
|
1850
1766
|
}
|
1851
1767
|
});
|
1852
1768
|
};
|
1853
1769
|
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1770
|
+
uniqError = 0;
|
1771
|
+
|
1772
|
+
TypeExpr.prototype.hash = function() {
|
1773
|
+
var recurse;
|
1774
|
+
return this.__hash__ || (this.__hash__ = (recurse = function(texpr) {
|
1775
|
+
return texpr.cases({
|
1776
|
+
expr: function(e) {
|
1777
|
+
return "<" + (e.hash()) + ">";
|
1778
|
+
},
|
1779
|
+
query: function(input, scope, query) {
|
1780
|
+
return "" + (query.inspect()) + ":" + scope.uniq + "[" + (recurse(input)) + "]";
|
1781
|
+
},
|
1782
|
+
"native": function(id) {
|
1783
|
+
return "!" + id;
|
1784
|
+
},
|
1785
|
+
param: function(name, constraints) {
|
1786
|
+
var c;
|
1787
|
+
return "(" + name + " " + (((function() {
|
1788
|
+
var _i, _len, _results;
|
1789
|
+
_results = [];
|
1790
|
+
for (_i = 0, _len = constraints.length; _i < _len; _i++) {
|
1791
|
+
c = constraints[_i];
|
1792
|
+
_results.push(recurse(c));
|
1793
|
+
}
|
1794
|
+
return _results;
|
1795
|
+
})()).join(' ')) + ")";
|
1796
|
+
},
|
1797
|
+
destructure: function(constraint, name, argnum) {
|
1798
|
+
return "" + (recurse(constraint)) + "/" + name + "[" + argnum + "]";
|
1799
|
+
},
|
1800
|
+
any: function() {
|
1801
|
+
return '*';
|
1802
|
+
},
|
1803
|
+
variable: function(name, uniq) {
|
1804
|
+
return "%" + uniq;
|
1805
|
+
},
|
1806
|
+
error: function() {
|
1807
|
+
return "!" + (uniqError += 1);
|
1864
1808
|
}
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1809
|
+
});
|
1810
|
+
})(this));
|
1811
|
+
};
|
1812
|
+
|
1813
|
+
TypeExpr.fromAST = function(typeAST, scope, genUniq) {
|
1814
|
+
var r;
|
1815
|
+
return (r = function(typeAST) {
|
1816
|
+
var e;
|
1817
|
+
e = TypeExpr;
|
1818
|
+
return typeAST.cases({
|
1819
|
+
concrete: function(name) {
|
1820
|
+
|
1821
|
+
return TypeExpr.param(name, []);
|
1822
|
+
},
|
1823
|
+
variable: function(name) {
|
1824
|
+
return scope.cache(name, function() {
|
1825
|
+
return TypeExpr.variable(name, genUniq());
|
1826
|
+
});
|
1827
|
+
},
|
1828
|
+
"native": function(id) {
|
1829
|
+
return TypeExpr["native"](id);
|
1830
|
+
},
|
1831
|
+
wildcard: function() {
|
1832
|
+
return TypeExpr.any();
|
1833
|
+
},
|
1834
|
+
list: function(el) {
|
1835
|
+
return e.param('list', [r(el)]);
|
1836
|
+
},
|
1837
|
+
block: function(el) {
|
1838
|
+
return e.param('block', [r(el.from), r(el.to)]);
|
1839
|
+
},
|
1840
|
+
pair: function(first, second) {
|
1841
|
+
return e.param('pair', [r(first), r(second)]);
|
1842
|
+
}
|
1843
|
+
});
|
1844
|
+
})(typeAST);
|
1888
1845
|
};
|
1889
1846
|
|
1890
1847
|
TypeExpr.fromType = function(t) {
|
@@ -1965,15 +1922,28 @@ analyze = Gibbon.analyze = (function() {
|
|
1965
1922
|
function NativeContext(globalID, externalLookup) {
|
1966
1923
|
this.globalID = globalID;
|
1967
1924
|
this.externalLookup = externalLookup;
|
1925
|
+
this.queryCache = new Hash;
|
1926
|
+
this.genUniq = (function() {
|
1927
|
+
var i;
|
1928
|
+
i = 0;
|
1929
|
+
return function() {
|
1930
|
+
return i += 1;
|
1931
|
+
};
|
1932
|
+
})();
|
1968
1933
|
}
|
1969
1934
|
|
1970
1935
|
NativeContext.prototype.query = function(id, query, cb) {
|
1936
|
+
var cacheKey,
|
1937
|
+
_this = this;
|
1938
|
+
cacheKey = "" + id + "/" + query.type + " " + (query.args.join(' '));
|
1939
|
+
if (this.queryCache.has(cacheKey)) {
|
1940
|
+
return Thunk.trampoline(cb(this.queryCache.get(cacheKey)));
|
1941
|
+
}
|
1971
1942
|
return this.externalLookup.call(null, id, query, Type, function(err, analysis) {
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
}
|
1943
|
+
var result;
|
1944
|
+
result = err ? TypeLookup.error(err) : TypeLookup.response(query, analysis);
|
1945
|
+
_this.queryCache.set(cacheKey, result);
|
1946
|
+
return Thunk.trampoline(cb(result));
|
1977
1947
|
});
|
1978
1948
|
};
|
1979
1949
|
|
@@ -1993,6 +1963,7 @@ analyze = Gibbon.analyze = (function() {
|
|
1993
1963
|
this.frame = frame;
|
1994
1964
|
this.context = context;
|
1995
1965
|
this.bindings = new Hash;
|
1966
|
+
this.uniq = this.context.genUniq();
|
1996
1967
|
}
|
1997
1968
|
|
1998
1969
|
Scope.prototype.extend = function(name, frame) {
|
@@ -2077,7 +2048,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2077
2048
|
return push(TypeExpr.expr(flow), TypeExpr.param('pair', [TypeExpr.expr(first), TypeExpr.expr(second)]));
|
2078
2049
|
},
|
2079
2050
|
func: function(_, name, args) {
|
2080
|
-
var arg, ast, func, i, input, scope, _i, _len, _results;
|
2051
|
+
var arg, ast, func, genUniq, i, input, scope, _i, _len, _results;
|
2081
2052
|
if (!stdlib.hasOwnProperty(name)) {
|
2082
2053
|
push(TypeExpr.expr(flow.head), TypeExpr.error('func', [flow.head]));
|
2083
2054
|
return;
|
@@ -2086,17 +2057,18 @@ analyze = Gibbon.analyze = (function() {
|
|
2086
2057
|
ast = func.type;
|
2087
2058
|
scope = new Hash;
|
2088
2059
|
flow.head.__scope__ = scope;
|
2089
|
-
|
2060
|
+
genUniq = _this.context.genUniq;
|
2061
|
+
input = TypeExpr.fromAST(ast.input, scope, genUniq);
|
2090
2062
|
if (flow.tail) {
|
2091
2063
|
push(TypeExpr.expr(flow.tail), input);
|
2092
2064
|
} else {
|
2093
2065
|
push(input, global);
|
2094
2066
|
}
|
2095
|
-
push(TypeExpr.expr(flow), TypeExpr.fromAST(ast.output, scope));
|
2067
|
+
push(TypeExpr.expr(flow), TypeExpr.fromAST(ast.output, scope, genUniq));
|
2096
2068
|
_results = [];
|
2097
2069
|
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
|
2098
2070
|
arg = args[i];
|
2099
|
-
push(TypeExpr.expr(arg), TypeExpr.fromAST(ast.args[i], scope));
|
2071
|
+
push(TypeExpr.expr(arg), TypeExpr.fromAST(ast.args[i], scope, genUniq));
|
2100
2072
|
_results.push(_this.analyzeFlow(arg, global, push));
|
2101
2073
|
}
|
2102
2074
|
return _results;
|
@@ -2116,7 +2088,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2116
2088
|
},
|
2117
2089
|
list: function(_, elements) {
|
2118
2090
|
var el, elVar, _i, _len, _results;
|
2119
|
-
elVar = TypeExpr.variable('el');
|
2091
|
+
elVar = TypeExpr.variable('el', _this.context.genUniq());
|
2120
2092
|
push(TypeExpr.expr(flow), TypeExpr.param('list', [elVar]));
|
2121
2093
|
_results = [];
|
2122
2094
|
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
@@ -2128,7 +2100,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2128
2100
|
},
|
2129
2101
|
block: function(_, subFlow) {
|
2130
2102
|
var input;
|
2131
|
-
input = TypeExpr.variable('.input');
|
2103
|
+
input = TypeExpr.variable('.input', _this.context.genUniq());
|
2132
2104
|
push(TypeExpr.expr(flow), TypeExpr.param('block', [input, TypeExpr.expr(subFlow)]));
|
2133
2105
|
return _this.analyzeFlow(subFlow, input, push);
|
2134
2106
|
},
|
@@ -2224,9 +2196,7 @@ analyze = Gibbon.analyze = (function() {
|
|
2224
2196
|
return function(constraintMap, finish) {
|
2225
2197
|
var errors, frameTypes, initialCrumbs, k, locks, semantics, solutions, solveEntry;
|
2226
2198
|
errors = [];
|
2227
|
-
solutions = new
|
2228
|
-
return x.equals(y);
|
2229
|
-
});
|
2199
|
+
solutions = new ObjHash;
|
2230
2200
|
semantics = new Hash;
|
2231
2201
|
frameTypes = new Hash;
|
2232
2202
|
locks = new Hash;
|
@@ -2240,13 +2210,15 @@ analyze = Gibbon.analyze = (function() {
|
|
2240
2210
|
_ref10 = constraintMap.get(key), frame = _ref10.frame, constraints = _ref10.constraints;
|
2241
2211
|
|
2242
2212
|
locks.set(key, true);
|
2243
|
-
semanticAccessors = new
|
2213
|
+
semanticAccessors = new ObjHash;
|
2244
2214
|
dependencies = [];
|
2245
2215
|
|
2246
2216
|
substitute = function(texpr, cb) {
|
2247
|
-
|
2217
|
+
if (solutions.has(texpr)) {
|
2218
|
+
return cb(solutions.get(texpr));
|
2219
|
+
} else {
|
2248
2220
|
return texpr.mapAsync(substitute, cb);
|
2249
|
-
}
|
2221
|
+
}
|
2250
2222
|
};
|
2251
2223
|
fullSubstitute = function(texpr, cb) {
|
2252
2224
|
return substitute(texpr, function(substituted) {
|
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.7.
|
4
|
+
version: 0.7.1
|
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-02-
|
11
|
+
date: 2014-02-18 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:
|
@@ -50,3 +50,4 @@ signing_key:
|
|
50
50
|
specification_version: 4
|
51
51
|
summary: Ruby bindings for the gibbon data language
|
52
52
|
test_files: []
|
53
|
+
has_rdoc:
|