ember_script-source 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/dist/ember-script.js CHANGED
@@ -262,7 +262,7 @@
262
262
  'ember.js'
263
263
  ],
264
264
  'author': 'Gordon Hempton/Michael Ficarra',
265
- 'version': '0.0.1',
265
+ 'version': '0.0.5',
266
266
  'main': './lib/module',
267
267
  'bin': { 'ember-script': './bin/ember-script' },
268
268
  'homepage': 'https://github.com/ghempton/ember-script',
@@ -11103,7 +11103,7 @@
11103
11103
  }
11104
11104
  };
11105
11105
  return function (param$) {
11106
- var alternate, ancestry, block, body, cache$2, consequent, i, index, last, newThis, numArgs, numParams, p, parameters, parameters_, paramName, performedRewrite, pIndex, reassignments, rewriteThis, test;
11106
+ var alternate, ancestry, block, body, cache$2, chains, consequent, i, index, last, newThis, numArgs, numParams, p, parameters, parameters_, paramName, performedRewrite, pIndex, reassignments, rewriteThis, test;
11107
11107
  {
11108
11108
  cache$2 = param$;
11109
11109
  parameters = cache$2.parameters;
@@ -11182,7 +11182,10 @@
11182
11182
  fn
11183
11183
  ]);
11184
11184
  if (this['instanceof'](CS.ComputedProperty)) {
11185
- return emberComputedProperty(fn, this.chains);
11185
+ chains = Ember.A(this.dependentKeys().map(function (c) {
11186
+ return c.join('.');
11187
+ })).uniq();
11188
+ return emberComputedProperty(fn, chains);
11186
11189
  } else {
11187
11190
  return fn;
11188
11191
  }
@@ -12225,50 +12228,13 @@
12225
12228
  return this;
12226
12229
  };
12227
12230
  Compiler.prototype.compile = function () {
12228
- var computePropertyChains, defaultRule, generateSymbols, walk;
12229
- computePropertyChains = function () {
12230
- var chains, child, childChains, childName, member, memberName;
12231
- chains = [];
12232
- if (this['instanceof'](CS.MemberAccessOps) && this.expression['instanceof'](CS.This))
12233
- return [this.memberName];
12234
- for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
12235
- childName = this.childNodes[i$];
12236
- if (!(null != this[childName]))
12237
- continue;
12238
- if (in$(childName, this.listMembers)) {
12239
- for (var i$1 = 0, length$1 = this[childName].length; i$1 < length$1; ++i$1) {
12240
- member = this[childName][i$1];
12241
- childChains = computePropertyChains.call(member);
12242
- if (this['instanceof'](CS.MemberAccessOps)) {
12243
- memberName = this.memberName;
12244
- childChains = childChains.map(function (c) {
12245
- return '' + c + '.' + memberName;
12246
- });
12247
- }
12248
- chains = chains.concat(childChains);
12249
- }
12250
- } else {
12251
- child = this[childName];
12252
- childChains = computePropertyChains.call(child);
12253
- if (this['instanceof'](CS.MemberAccessOps)) {
12254
- memberName = this.memberName;
12255
- childChains = childChains.map(function (c) {
12256
- return '' + c + '.' + memberName;
12257
- });
12258
- }
12259
- chains = chains.concat(childChains);
12260
- }
12261
- }
12262
- return chains;
12263
- };
12231
+ var defaultRule, generateSymbols, walk;
12264
12232
  walk = function (fn, inScope, ancestry, options) {
12265
12233
  var child, childName, children, jsNode;
12266
12234
  if ((null != ancestry[0] ? ancestry[0]['instanceof'](CS.Function, CS.BoundFunction, CS.ComputedProperty) : void 0) && this === ancestry[0].body)
12267
12235
  inScope = union(inScope, concatMap(ancestry[0].parameters, beingDeclared));
12268
12236
  ancestry.unshift(this);
12269
12237
  children = {};
12270
- if (this['instanceof'](CS.ComputedProperty))
12271
- this.chains = computePropertyChains.call(this);
12272
12238
  for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
12273
12239
  childName = this.childNodes[i$];
12274
12240
  if (!(null != this[childName]))
@@ -13046,7 +13012,7 @@
13046
13012
  }
13047
13013
  });
13048
13014
  require.define('/src/nodes.coffee', function (module, exports, __dirname, __filename) {
13049
- var Annotations, ArrayInitialiser, Block, Bool, Class, CompoundAssignOp, ComputedProperty, concat, concatMap, Conditional, createNodes, difference, exports, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, Mixin, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, ObjectInitialiserMember, PostDecrementOp, PostIncrementOp, Primitives, Range, RegExp, RegExps, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, union, While;
13015
+ var Annotations, ArrayInitialiser, AssignOp, Block, Bool, Class, CompoundAssignOp, ComputedProperty, concat, concatMap, Conditional, createNodes, difference, enumerableMethods, exports, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, MemberAccessOp, Mixin, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, ObjectInitialiserMember, PostDecrementOp, PostIncrementOp, Primitives, Range, RegExp, RegExps, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, This, union, While;
13050
13016
  cache$ = require('/src/functional-helpers.coffee', module);
13051
13017
  map = cache$.map;
13052
13018
  concat = cache$.concat;
@@ -13432,6 +13398,9 @@
13432
13398
  Annotations = cache$1.Annotations;
13433
13399
  PostIncrementOp = cache$1.PostIncrementOp;
13434
13400
  PostDecrementOp = cache$1.PostDecrementOp;
13401
+ MemberAccessOp = cache$1.MemberAccessOp;
13402
+ This = cache$1.This;
13403
+ AssignOp = cache$1.AssignOp;
13435
13404
  Nodes.fromBasicObject = function (obj) {
13436
13405
  return exports[obj.type].fromBasicObject(obj);
13437
13406
  };
@@ -13637,6 +13606,127 @@
13637
13606
  PostDecrementOp.prototype.initialise = function () {
13638
13607
  return this.expression.isAssignment = true;
13639
13608
  };
13609
+ Nodes.prototype.dependentKeys = function (scope) {
13610
+ var chains, child, childName, member;
13611
+ if (null == scope)
13612
+ scope = {};
13613
+ chains = [];
13614
+ for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
13615
+ childName = this.childNodes[i$];
13616
+ if (!(null != this[childName]))
13617
+ continue;
13618
+ if (in$(childName, this.listMembers)) {
13619
+ for (var i$1 = 0, length$1 = this[childName].length; i$1 < length$1; ++i$1) {
13620
+ member = this[childName][i$1];
13621
+ chains = chains.concat(member.dependentKeys(scope));
13622
+ }
13623
+ } else {
13624
+ child = this[childName];
13625
+ chains = chains.concat(child.dependentKeys(scope));
13626
+ }
13627
+ }
13628
+ return chains;
13629
+ };
13630
+ This.prototype.dependentKeys = function (scope) {
13631
+ if (null == scope)
13632
+ scope = {};
13633
+ return [[]];
13634
+ };
13635
+ MemberAccessOp.prototype.dependentKeys = function (scope) {
13636
+ var memberName;
13637
+ if (null == scope)
13638
+ scope = {};
13639
+ memberName = this.memberName;
13640
+ return this.expression.dependentKeys(scope).map(function (c) {
13641
+ c.push(memberName);
13642
+ return c;
13643
+ });
13644
+ };
13645
+ enumerableMethods = [
13646
+ 'isEnumerable',
13647
+ 'nextObject',
13648
+ 'firstObject',
13649
+ 'lastObject',
13650
+ 'contains',
13651
+ 'forEach',
13652
+ 'getEach',
13653
+ 'setEach',
13654
+ 'map',
13655
+ 'mapProperty',
13656
+ 'filter',
13657
+ 'reject',
13658
+ 'filterProperty',
13659
+ 'rejectProperty',
13660
+ 'find',
13661
+ 'findProperty',
13662
+ 'every',
13663
+ 'everyProperty',
13664
+ 'some',
13665
+ 'someProperty',
13666
+ 'reduce',
13667
+ 'invoke',
13668
+ 'toArray',
13669
+ 'compact',
13670
+ 'without',
13671
+ 'uniq',
13672
+ '[]',
13673
+ 'addEnumerableObserver',
13674
+ 'removeEnumerableObserver',
13675
+ 'hasEnumerableObservers',
13676
+ 'enumerableContentWillChange',
13677
+ 'enumerableContentDidChange'
13678
+ ];
13679
+ FunctionApplications.prototype.dependentKeys = function (scope) {
13680
+ var res;
13681
+ if (null == scope)
13682
+ scope = {};
13683
+ res = this['function'].dependentKeys(scope);
13684
+ if (this['function']['instanceof'](MemberAccessOp)) {
13685
+ res = res.map(function (c) {
13686
+ c.pop();
13687
+ return c;
13688
+ });
13689
+ if (in$(this['function'].memberName, enumerableMethods))
13690
+ res = res.map(function (c) {
13691
+ c.push('@each');
13692
+ return c;
13693
+ });
13694
+ }
13695
+ return res;
13696
+ };
13697
+ Block.prototype.dependentKeys = function (scope) {
13698
+ var key, newScope, res;
13699
+ if (null == scope)
13700
+ scope = {};
13701
+ res = [];
13702
+ newScope = Ember.copy(scope);
13703
+ for (var i$ = 0, length$ = newScope.length; i$ < length$; ++i$) {
13704
+ key = newScope[i$];
13705
+ newScope[key] = Ember.copy(newScope[key]);
13706
+ }
13707
+ this.statements.forEach(function (s) {
13708
+ return res = res.concat(s.dependentKeys(scope));
13709
+ });
13710
+ for (var i$1 = 0, length$1 = scope.length; i$1 < length$1; ++i$1) {
13711
+ key = scope[i$1];
13712
+ scope[key] = scope[key].concat(newScope[key]);
13713
+ }
13714
+ return res;
13715
+ };
13716
+ AssignOp.prototype.dependentKeys = function (scope) {
13717
+ var res;
13718
+ if (null == scope)
13719
+ scope = {};
13720
+ res = this.expression.dependentKeys(scope);
13721
+ if (this.assignee['instanceof'](Identifier))
13722
+ scope[this.assignee.data] = (scope[this.assignee.data] || []).concat(res);
13723
+ return res;
13724
+ };
13725
+ Identifier.prototype.dependentKeys = function (scope) {
13726
+ if (null == scope)
13727
+ scope = {};
13728
+ return Ember.copy(scope[this.data]) || [];
13729
+ };
13640
13730
  exports.NegatedConditional = function (super$) {
13641
13731
  extends$(NegatedConditional, super$);
13642
13732
  function NegatedConditional() {
@@ -35615,7 +35705,7 @@
35615
35705
  }();
35616
35706
  });
35617
35707
  require.define('/lib/nodes.js', function (module, exports, __dirname, __filename) {
35618
- var Annotations, ArrayInitialiser, Block, Bool, Class, CompoundAssignOp, ComputedProperty, concat, concatMap, Conditional, createNodes, difference, exports, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, Mixin, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, ObjectInitialiserMember, PostDecrementOp, PostIncrementOp, Primitives, Range, RegExp, RegExps, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, union, While;
35708
+ var Annotations, ArrayInitialiser, AssignOp, Block, Bool, Class, CompoundAssignOp, ComputedProperty, concat, concatMap, Conditional, createNodes, difference, enumerableMethods, exports, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, MemberAccessOp, Mixin, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, ObjectInitialiserMember, PostDecrementOp, PostIncrementOp, Primitives, Range, RegExp, RegExps, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, This, union, While;
35619
35709
  cache$ = require('/lib/functional-helpers.js', module);
35620
35710
  map = cache$.map;
35621
35711
  concat = cache$.concat;
@@ -36001,6 +36091,9 @@
36001
36091
  Annotations = cache$1.Annotations;
36002
36092
  PostIncrementOp = cache$1.PostIncrementOp;
36003
36093
  PostDecrementOp = cache$1.PostDecrementOp;
36094
+ MemberAccessOp = cache$1.MemberAccessOp;
36095
+ This = cache$1.This;
36096
+ AssignOp = cache$1.AssignOp;
36004
36097
  Nodes.fromBasicObject = function (obj) {
36005
36098
  return exports[obj.type].fromBasicObject(obj);
36006
36099
  };
@@ -36206,6 +36299,127 @@
36206
36299
  PostDecrementOp.prototype.initialise = function () {
36207
36300
  return this.expression.isAssignment = true;
36208
36301
  };
36302
+ Nodes.prototype.dependentKeys = function (scope) {
36303
+ var chains, child, childName, member;
36304
+ if (null == scope)
36305
+ scope = {};
36306
+ chains = [];
36307
+ for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
36308
+ childName = this.childNodes[i$];
36309
+ if (!(null != this[childName]))
36310
+ continue;
36311
+ if (in$(childName, this.listMembers)) {
36312
+ for (var i$1 = 0, length$1 = this[childName].length; i$1 < length$1; ++i$1) {
36313
+ member = this[childName][i$1];
36314
+ chains = chains.concat(member.dependentKeys(scope));
36315
+ }
36316
+ } else {
36317
+ child = this[childName];
36318
+ chains = chains.concat(child.dependentKeys(scope));
36319
+ }
36320
+ }
36321
+ return chains;
36322
+ };
36323
+ This.prototype.dependentKeys = function (scope) {
36324
+ if (null == scope)
36325
+ scope = {};
36326
+ return [[]];
36327
+ };
36328
+ MemberAccessOp.prototype.dependentKeys = function (scope) {
36329
+ var memberName;
36330
+ if (null == scope)
36331
+ scope = {};
36332
+ memberName = this.memberName;
36333
+ return this.expression.dependentKeys(scope).map(function (c) {
36334
+ c.push(memberName);
36335
+ return c;
36336
+ });
36337
+ };
36338
+ enumerableMethods = [
36339
+ 'isEnumerable',
36340
+ 'nextObject',
36341
+ 'firstObject',
36342
+ 'lastObject',
36343
+ 'contains',
36344
+ 'forEach',
36345
+ 'getEach',
36346
+ 'setEach',
36347
+ 'map',
36348
+ 'mapProperty',
36349
+ 'filter',
36350
+ 'reject',
36351
+ 'filterProperty',
36352
+ 'rejectProperty',
36353
+ 'find',
36354
+ 'findProperty',
36355
+ 'every',
36356
+ 'everyProperty',
36357
+ 'some',
36358
+ 'someProperty',
36359
+ 'reduce',
36360
+ 'invoke',
36361
+ 'toArray',
36362
+ 'compact',
36363
+ 'without',
36364
+ 'uniq',
36365
+ '[]',
36366
+ 'addEnumerableObserver',
36367
+ 'removeEnumerableObserver',
36368
+ 'hasEnumerableObservers',
36369
+ 'enumerableContentWillChange',
36370
+ 'enumerableContentDidChange'
36371
+ ];
36372
+ FunctionApplications.prototype.dependentKeys = function (scope) {
36373
+ var res;
36374
+ if (null == scope)
36375
+ scope = {};
36376
+ res = this['function'].dependentKeys(scope);
36377
+ if (this['function']['instanceof'](MemberAccessOp)) {
36378
+ res = res.map(function (c) {
36379
+ c.pop();
36380
+ return c;
36381
+ });
36382
+ if (in$(this['function'].memberName, enumerableMethods))
36383
+ res = res.map(function (c) {
36384
+ c.push('@each');
36385
+ return c;
36386
+ });
36387
+ }
36388
+ return res;
36389
+ };
36390
+ Block.prototype.dependentKeys = function (scope) {
36391
+ var key, newScope, res;
36392
+ if (null == scope)
36393
+ scope = {};
36394
+ res = [];
36395
+ newScope = Ember.copy(scope);
36396
+ for (var i$ = 0, length$ = newScope.length; i$ < length$; ++i$) {
36397
+ key = newScope[i$];
36398
+ newScope[key] = Ember.copy(newScope[key]);
36399
+ }
36400
+ this.statements.forEach(function (s) {
36401
+ return res = res.concat(s.dependentKeys(scope));
36402
+ });
36403
+ for (var i$1 = 0, length$1 = scope.length; i$1 < length$1; ++i$1) {
36404
+ key = scope[i$1];
36405
+ scope[key] = scope[key].concat(newScope[key]);
36406
+ }
36407
+ return res;
36408
+ };
36409
+ AssignOp.prototype.dependentKeys = function (scope) {
36410
+ var res;
36411
+ if (null == scope)
36412
+ scope = {};
36413
+ res = this.expression.dependentKeys(scope);
36414
+ if (this.assignee['instanceof'](Identifier))
36415
+ scope[this.assignee.data] = (scope[this.assignee.data] || []).concat(res);
36416
+ return res;
36417
+ };
36418
+ Identifier.prototype.dependentKeys = function (scope) {
36419
+ if (null == scope)
36420
+ scope = {};
36421
+ return Ember.copy(scope[this.data]) || [];
36422
+ };
36209
36423
  exports.NegatedConditional = function (super$) {
36210
36424
  extends$(NegatedConditional, super$);
36211
36425
  function NegatedConditional() {