ember-source 5.7.0-alpha.2 → 5.7.0-alpha.4
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.
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/debug.js +8 -25
- package/dist/dependencies/@glimmer/destroyable.js +2 -4
- package/dist/dependencies/@glimmer/encoder.js +1 -4
- package/dist/dependencies/@glimmer/manager.js +36 -47
- package/dist/dependencies/@glimmer/node.js +1 -2
- package/dist/dependencies/@glimmer/opcode-compiler.js +124 -188
- package/dist/dependencies/@glimmer/program.js +5 -7
- package/dist/dependencies/@glimmer/reference.js +2 -4
- package/dist/dependencies/@glimmer/runtime.js +355 -544
- package/dist/dependencies/@glimmer/util.js +9 -32
- package/dist/dependencies/@glimmer/validator.js +9 -15
- package/dist/ember-template-compiler.js +399 -336
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +552 -873
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +2 -0
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1 -1
- package/package.json +18 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EMPTY_STRING_ARRAY, isSmallInt, encodeImmediate, unwrap, reverse, assert as assert$1, Stack, isPresentArray, encodeHandle, expect, assign, dict, enumerate, EMPTY_ARRAY, debugToString } from '@glimmer/util';
|
|
2
2
|
import '@glimmer/debug';
|
|
3
|
-
import { Op, MachineOp, $v0, $fp, $sp, InternalComponentCapabilities, $s0, ContentType, TYPE_SIZE, isMachineOp, MACHINE_MASK, $s1
|
|
3
|
+
import { Op, MachineOp, $v0, $fp, $sp, InternalComponentCapabilities, $s0, ContentType, TYPE_SIZE, isMachineOp, MACHINE_MASK, ARG_SHIFT, $s1 } from '@glimmer/vm';
|
|
4
4
|
import { DEBUG } from '@glimmer/env';
|
|
5
5
|
import { InstructionEncoderImpl } from '@glimmer/encoder';
|
|
6
6
|
import { SexpOpcodes } from '@glimmer/wire-format';
|
|
@@ -45,8 +45,7 @@ function assertResolverInvariants(meta) {
|
|
|
45
45
|
* <Foo></Foo>
|
|
46
46
|
* <Foo @arg={{true}} />
|
|
47
47
|
*/
|
|
48
|
-
function resolveComponent(resolver, constants, meta,
|
|
49
|
-
let [, expr, then] = _ref;
|
|
48
|
+
function resolveComponent(resolver, constants, meta, [, expr, then]) {
|
|
50
49
|
assert$1(isGetFreeComponent(expr), 'Attempted to resolve a component with incorrect opcode');
|
|
51
50
|
let type = expr[0];
|
|
52
51
|
if (DEBUG && expr[0] === SexpOpcodes.GetStrictKeyword) {
|
|
@@ -77,8 +76,7 @@ function resolveComponent(resolver, constants, meta, _ref) {
|
|
|
77
76
|
* (helper)
|
|
78
77
|
* (helper arg)
|
|
79
78
|
*/
|
|
80
|
-
function resolveHelper(resolver, constants, meta,
|
|
81
|
-
let [, expr, then] = _ref2;
|
|
79
|
+
function resolveHelper(resolver, constants, meta, [, expr, then]) {
|
|
82
80
|
assert$1(isGetFreeHelper(expr), 'Attempted to resolve a helper with incorrect opcode');
|
|
83
81
|
let type = expr[0];
|
|
84
82
|
if (type === SexpOpcodes.GetLexicalSymbol) {
|
|
@@ -108,8 +106,7 @@ function resolveHelper(resolver, constants, meta, _ref2) {
|
|
|
108
106
|
* <div {{modifier arg}}/>
|
|
109
107
|
* <Foo {{modifier}}/>
|
|
110
108
|
*/
|
|
111
|
-
function resolveModifier(resolver, constants, meta,
|
|
112
|
-
let [, expr, then] = _ref3;
|
|
109
|
+
function resolveModifier(resolver, constants, meta, [, expr, then]) {
|
|
113
110
|
assert$1(isGetFreeModifier(expr), 'Attempted to resolve a modifier with incorrect opcode');
|
|
114
111
|
let type = expr[0];
|
|
115
112
|
if (type === SexpOpcodes.GetLexicalSymbol) {
|
|
@@ -145,11 +142,10 @@ function resolveModifier(resolver, constants, meta, _ref3) {
|
|
|
145
142
|
/**
|
|
146
143
|
* {{component-or-helper arg}}
|
|
147
144
|
*/
|
|
148
|
-
function resolveComponentOrHelper(resolver, constants, meta,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}] = _ref4;
|
|
145
|
+
function resolveComponentOrHelper(resolver, constants, meta, [, expr, {
|
|
146
|
+
ifComponent,
|
|
147
|
+
ifHelper
|
|
148
|
+
}]) {
|
|
153
149
|
assert$1(isGetFreeComponentOrHelper(expr), 'Attempted to resolve a component or helper with incorrect opcode');
|
|
154
150
|
let type = expr[0];
|
|
155
151
|
if (type === SexpOpcodes.GetLexicalSymbol) {
|
|
@@ -192,10 +188,9 @@ function resolveComponentOrHelper(resolver, constants, meta, _ref4) {
|
|
|
192
188
|
/**
|
|
193
189
|
* <Foo @arg={{helper}}>
|
|
194
190
|
*/
|
|
195
|
-
function resolveOptionalHelper(resolver, constants, meta,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}] = _ref5;
|
|
191
|
+
function resolveOptionalHelper(resolver, constants, meta, [, expr, {
|
|
192
|
+
ifHelper
|
|
193
|
+
}]) {
|
|
199
194
|
assert$1(isGetFreeOptionalHelper(expr) || isGetFreeDeprecatedHelper(expr), 'Attempted to resolve a helper with incorrect opcode');
|
|
200
195
|
let {
|
|
201
196
|
upvars,
|
|
@@ -211,12 +206,11 @@ function resolveOptionalHelper(resolver, constants, meta, _ref5) {
|
|
|
211
206
|
/**
|
|
212
207
|
* {{maybeHelperOrComponent}}
|
|
213
208
|
*/
|
|
214
|
-
function resolveOptionalComponentOrHelper(resolver, constants, meta,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}] = _ref6;
|
|
209
|
+
function resolveOptionalComponentOrHelper(resolver, constants, meta, [, expr, {
|
|
210
|
+
ifComponent,
|
|
211
|
+
ifHelper,
|
|
212
|
+
ifValue
|
|
213
|
+
}]) {
|
|
220
214
|
assert$1(isGetFreeOptionalComponentOrHelper(expr), 'Attempted to resolve an optional component or helper with incorrect opcode');
|
|
221
215
|
let type = expr[0];
|
|
222
216
|
if (type === SexpOpcodes.GetLexicalSymbol) {
|
|
@@ -459,7 +453,7 @@ class EncoderImpl {
|
|
|
459
453
|
return handle;
|
|
460
454
|
}
|
|
461
455
|
}
|
|
462
|
-
push(constants, type) {
|
|
456
|
+
push(constants, type, ...args) {
|
|
463
457
|
let {
|
|
464
458
|
heap
|
|
465
459
|
} = this;
|
|
@@ -467,10 +461,10 @@ class EncoderImpl {
|
|
|
467
461
|
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
|
|
468
462
|
}
|
|
469
463
|
let machine = isMachineOp(type) ? MACHINE_MASK : 0;
|
|
470
|
-
let first = type | machine |
|
|
464
|
+
let first = type | machine | args.length << ARG_SHIFT;
|
|
471
465
|
heap.pushRaw(first);
|
|
472
|
-
for (let i = 0; i <
|
|
473
|
-
let op =
|
|
466
|
+
for (let i = 0; i < args.length; i++) {
|
|
467
|
+
let op = args[i];
|
|
474
468
|
heap.pushRaw(this.operand(constants, op));
|
|
475
469
|
}
|
|
476
470
|
}
|
|
@@ -695,15 +689,13 @@ class Compilers {
|
|
|
695
689
|
}
|
|
696
690
|
|
|
697
691
|
const EXPRESSIONS = new Compilers();
|
|
698
|
-
EXPRESSIONS.add(SexpOpcodes.Concat, (op,
|
|
699
|
-
let [, parts] = _ref;
|
|
692
|
+
EXPRESSIONS.add(SexpOpcodes.Concat, (op, [, parts]) => {
|
|
700
693
|
for (let part of parts) {
|
|
701
694
|
expr(op, part);
|
|
702
695
|
}
|
|
703
696
|
op(Op.Concat, parts.length);
|
|
704
697
|
});
|
|
705
|
-
EXPRESSIONS.add(SexpOpcodes.Call, (op,
|
|
706
|
-
let [, expression, positional, named] = _ref2;
|
|
698
|
+
EXPRESSIONS.add(SexpOpcodes.Call, (op, [, expression, positional, named]) => {
|
|
707
699
|
if (isGetFreeHelper(expression)) {
|
|
708
700
|
op(HighLevelResolutionOpcodes.Helper, expression, handle => {
|
|
709
701
|
Call(op, handle, positional, named);
|
|
@@ -713,24 +705,20 @@ EXPRESSIONS.add(SexpOpcodes.Call, (op, _ref2) => {
|
|
|
713
705
|
CallDynamic(op, positional, named);
|
|
714
706
|
}
|
|
715
707
|
});
|
|
716
|
-
EXPRESSIONS.add(SexpOpcodes.Curry, (op,
|
|
717
|
-
let [, expr, type, positional, named] = _ref3;
|
|
708
|
+
EXPRESSIONS.add(SexpOpcodes.Curry, (op, [, expr, type, positional, named]) => {
|
|
718
709
|
Curry(op, type, expr, positional, named);
|
|
719
710
|
});
|
|
720
|
-
EXPRESSIONS.add(SexpOpcodes.GetSymbol, (op,
|
|
721
|
-
let [, sym, path] = _ref4;
|
|
711
|
+
EXPRESSIONS.add(SexpOpcodes.GetSymbol, (op, [, sym, path]) => {
|
|
722
712
|
op(Op.GetVariable, sym);
|
|
723
713
|
withPath(op, path);
|
|
724
714
|
});
|
|
725
|
-
EXPRESSIONS.add(SexpOpcodes.GetLexicalSymbol, (op,
|
|
726
|
-
let [, sym, path] = _ref5;
|
|
715
|
+
EXPRESSIONS.add(SexpOpcodes.GetLexicalSymbol, (op, [, sym, path]) => {
|
|
727
716
|
op(HighLevelResolutionOpcodes.TemplateLocal, sym, handle => {
|
|
728
717
|
op(Op.ConstantReference, handle);
|
|
729
718
|
withPath(op, path);
|
|
730
719
|
});
|
|
731
720
|
});
|
|
732
|
-
EXPRESSIONS.add(SexpOpcodes.GetStrictKeyword, (op,
|
|
733
|
-
let [, sym, _path] = _ref6;
|
|
721
|
+
EXPRESSIONS.add(SexpOpcodes.GetStrictKeyword, (op, [, sym, _path]) => {
|
|
734
722
|
op(HighLevelResolutionOpcodes.Free, sym, _handle => {
|
|
735
723
|
// TODO: Implement in strict mode
|
|
736
724
|
});
|
|
@@ -776,38 +764,32 @@ function withPath(op, path) {
|
|
|
776
764
|
}
|
|
777
765
|
}
|
|
778
766
|
EXPRESSIONS.add(SexpOpcodes.Undefined, op => PushPrimitiveReference(op, undefined));
|
|
779
|
-
EXPRESSIONS.add(SexpOpcodes.HasBlock, (op,
|
|
780
|
-
let [, block] = _ref7;
|
|
767
|
+
EXPRESSIONS.add(SexpOpcodes.HasBlock, (op, [, block]) => {
|
|
781
768
|
expr(op, block);
|
|
782
769
|
op(Op.HasBlock);
|
|
783
770
|
});
|
|
784
|
-
EXPRESSIONS.add(SexpOpcodes.HasBlockParams, (op,
|
|
785
|
-
let [, block] = _ref8;
|
|
771
|
+
EXPRESSIONS.add(SexpOpcodes.HasBlockParams, (op, [, block]) => {
|
|
786
772
|
expr(op, block);
|
|
787
773
|
op(Op.SpreadBlock);
|
|
788
774
|
op(Op.CompileBlock);
|
|
789
775
|
op(Op.HasBlockParams);
|
|
790
776
|
});
|
|
791
|
-
EXPRESSIONS.add(SexpOpcodes.IfInline, (op,
|
|
792
|
-
let [, condition, truthy, falsy] = _ref9;
|
|
777
|
+
EXPRESSIONS.add(SexpOpcodes.IfInline, (op, [, condition, truthy, falsy]) => {
|
|
793
778
|
// Push in reverse order
|
|
794
779
|
expr(op, falsy);
|
|
795
780
|
expr(op, truthy);
|
|
796
781
|
expr(op, condition);
|
|
797
782
|
op(Op.IfInline);
|
|
798
783
|
});
|
|
799
|
-
EXPRESSIONS.add(SexpOpcodes.Not, (op,
|
|
800
|
-
let [, value] = _ref10;
|
|
784
|
+
EXPRESSIONS.add(SexpOpcodes.Not, (op, [, value]) => {
|
|
801
785
|
expr(op, value);
|
|
802
786
|
op(Op.Not);
|
|
803
787
|
});
|
|
804
|
-
EXPRESSIONS.add(SexpOpcodes.GetDynamicVar, (op,
|
|
805
|
-
let [, expression] = _ref11;
|
|
788
|
+
EXPRESSIONS.add(SexpOpcodes.GetDynamicVar, (op, [, expression]) => {
|
|
806
789
|
expr(op, expression);
|
|
807
790
|
op(Op.GetDynamicVar);
|
|
808
791
|
});
|
|
809
|
-
EXPRESSIONS.add(SexpOpcodes.Log, (op,
|
|
810
|
-
let [, positional] = _ref12;
|
|
792
|
+
EXPRESSIONS.add(SexpOpcodes.Log, (op, [, positional]) => {
|
|
811
793
|
op(MachineOp.PushFrame);
|
|
812
794
|
SimpleArgs(op, positional, null, false);
|
|
813
795
|
op(Op.Log);
|
|
@@ -1254,15 +1236,14 @@ function InvokeDynamicComponent(op, definition, _elementBlock, positional, named
|
|
|
1254
1236
|
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1255
1237
|
});
|
|
1256
1238
|
}
|
|
1257
|
-
function InvokeStaticComponent(op,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
} = _ref;
|
|
1239
|
+
function InvokeStaticComponent(op, {
|
|
1240
|
+
capabilities,
|
|
1241
|
+
layout,
|
|
1242
|
+
elementBlock,
|
|
1243
|
+
positional,
|
|
1244
|
+
named,
|
|
1245
|
+
blocks
|
|
1246
|
+
}) {
|
|
1266
1247
|
let {
|
|
1267
1248
|
symbolTable
|
|
1268
1249
|
} = layout;
|
|
@@ -1425,16 +1406,15 @@ function InvokeStaticComponent(op, _ref) {
|
|
|
1425
1406
|
op(Op.CommitComponentTransaction);
|
|
1426
1407
|
op(Op.Load, $s0);
|
|
1427
1408
|
}
|
|
1428
|
-
function InvokeNonStaticComponent(op,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
} = _ref2;
|
|
1409
|
+
function InvokeNonStaticComponent(op, {
|
|
1410
|
+
capabilities,
|
|
1411
|
+
elementBlock,
|
|
1412
|
+
positional,
|
|
1413
|
+
named,
|
|
1414
|
+
atNames,
|
|
1415
|
+
blocks: namedBlocks,
|
|
1416
|
+
layout
|
|
1417
|
+
}) {
|
|
1438
1418
|
let bindableBlocks = !!namedBlocks;
|
|
1439
1419
|
let bindableAtNames = capabilities === true || hasCapability(capabilities, InternalComponentCapabilities.prepareArgs) || !!(named && named[0].length !== 0);
|
|
1440
1420
|
let blocks = namedBlocks.with('attrs', elementBlock);
|
|
@@ -1479,8 +1459,7 @@ function WrappedComponent(op, layout, attrsBlockNumber) {
|
|
|
1479
1459
|
op(Op.Load, $s1);
|
|
1480
1460
|
op(HighLevelBuilderOpcodes.StopLabels);
|
|
1481
1461
|
}
|
|
1482
|
-
function invokePreparedComponent(op, hasBlock, bindableBlocks, bindableAtNames) {
|
|
1483
|
-
let populateLayout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
1462
|
+
function invokePreparedComponent(op, hasBlock, bindableBlocks, bindableAtNames, populateLayout = null) {
|
|
1484
1463
|
op(Op.BeginComponentTransaction, $s0);
|
|
1485
1464
|
op(Op.PushDynamicScope);
|
|
1486
1465
|
op(Op.CreateComponent, hasBlock | 0, $s0);
|
|
@@ -1609,10 +1588,7 @@ function build(program, builder) {
|
|
|
1609
1588
|
resolver
|
|
1610
1589
|
} = program;
|
|
1611
1590
|
let encoder = new EncoderImpl(heap, STDLIB_META);
|
|
1612
|
-
function pushOp() {
|
|
1613
|
-
for (var _len = arguments.length, op = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1614
|
-
op[_key] = arguments[_key];
|
|
1615
|
-
}
|
|
1591
|
+
function pushOp(...op) {
|
|
1616
1592
|
encodeOp(encoder, constants, resolver, STDLIB_META, op);
|
|
1617
1593
|
}
|
|
1618
1594
|
builder(pushOp);
|
|
@@ -1629,11 +1605,10 @@ class CompileTimeCompilationContextImpl {
|
|
|
1629
1605
|
constants;
|
|
1630
1606
|
heap;
|
|
1631
1607
|
stdlib;
|
|
1632
|
-
constructor(
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
} = _ref;
|
|
1608
|
+
constructor({
|
|
1609
|
+
constants,
|
|
1610
|
+
heap
|
|
1611
|
+
}, resolver, createOp) {
|
|
1637
1612
|
this.resolver = resolver;
|
|
1638
1613
|
this.createOp = createOp;
|
|
1639
1614
|
this.constants = constants;
|
|
@@ -1666,8 +1641,7 @@ function inflateAttrName(attrName) {
|
|
|
1666
1641
|
STATEMENTS.add(SexpOpcodes.Comment, (op, sexp) => op(Op.Comment, sexp[1]));
|
|
1667
1642
|
STATEMENTS.add(SexpOpcodes.CloseElement, op => op(Op.CloseElement));
|
|
1668
1643
|
STATEMENTS.add(SexpOpcodes.FlushElement, op => op(Op.FlushElement));
|
|
1669
|
-
STATEMENTS.add(SexpOpcodes.Modifier, (op,
|
|
1670
|
-
let [, expression, positional, named] = _ref;
|
|
1644
|
+
STATEMENTS.add(SexpOpcodes.Modifier, (op, [, expression, positional, named]) => {
|
|
1671
1645
|
if (isGetFreeModifier(expression)) {
|
|
1672
1646
|
op(HighLevelResolutionOpcodes.Modifier, expression, handle => {
|
|
1673
1647
|
op(MachineOp.PushFrame);
|
|
@@ -1684,45 +1658,36 @@ STATEMENTS.add(SexpOpcodes.Modifier, (op, _ref) => {
|
|
|
1684
1658
|
op(MachineOp.PopFrame);
|
|
1685
1659
|
}
|
|
1686
1660
|
});
|
|
1687
|
-
STATEMENTS.add(SexpOpcodes.StaticAttr, (op,
|
|
1688
|
-
let [, name, value, namespace] = _ref2;
|
|
1661
|
+
STATEMENTS.add(SexpOpcodes.StaticAttr, (op, [, name, value, namespace]) => {
|
|
1689
1662
|
op(Op.StaticAttr, inflateAttrName(name), value, namespace ?? null);
|
|
1690
1663
|
});
|
|
1691
|
-
STATEMENTS.add(SexpOpcodes.StaticComponentAttr, (op,
|
|
1692
|
-
let [, name, value, namespace] = _ref3;
|
|
1664
|
+
STATEMENTS.add(SexpOpcodes.StaticComponentAttr, (op, [, name, value, namespace]) => {
|
|
1693
1665
|
op(Op.StaticComponentAttr, inflateAttrName(name), value, namespace ?? null);
|
|
1694
1666
|
});
|
|
1695
|
-
STATEMENTS.add(SexpOpcodes.DynamicAttr, (op,
|
|
1696
|
-
let [, name, value, namespace] = _ref4;
|
|
1667
|
+
STATEMENTS.add(SexpOpcodes.DynamicAttr, (op, [, name, value, namespace]) => {
|
|
1697
1668
|
expr(op, value);
|
|
1698
1669
|
op(Op.DynamicAttr, inflateAttrName(name), false, namespace ?? null);
|
|
1699
1670
|
});
|
|
1700
|
-
STATEMENTS.add(SexpOpcodes.TrustingDynamicAttr, (op,
|
|
1701
|
-
let [, name, value, namespace] = _ref5;
|
|
1671
|
+
STATEMENTS.add(SexpOpcodes.TrustingDynamicAttr, (op, [, name, value, namespace]) => {
|
|
1702
1672
|
expr(op, value);
|
|
1703
1673
|
op(Op.DynamicAttr, inflateAttrName(name), true, namespace ?? null);
|
|
1704
1674
|
});
|
|
1705
|
-
STATEMENTS.add(SexpOpcodes.ComponentAttr, (op,
|
|
1706
|
-
let [, name, value, namespace] = _ref6;
|
|
1675
|
+
STATEMENTS.add(SexpOpcodes.ComponentAttr, (op, [, name, value, namespace]) => {
|
|
1707
1676
|
expr(op, value);
|
|
1708
1677
|
op(Op.ComponentAttr, inflateAttrName(name), false, namespace ?? null);
|
|
1709
1678
|
});
|
|
1710
|
-
STATEMENTS.add(SexpOpcodes.TrustingComponentAttr, (op,
|
|
1711
|
-
let [, name, value, namespace] = _ref7;
|
|
1679
|
+
STATEMENTS.add(SexpOpcodes.TrustingComponentAttr, (op, [, name, value, namespace]) => {
|
|
1712
1680
|
expr(op, value);
|
|
1713
1681
|
op(Op.ComponentAttr, inflateAttrName(name), true, namespace ?? null);
|
|
1714
1682
|
});
|
|
1715
|
-
STATEMENTS.add(SexpOpcodes.OpenElement, (op,
|
|
1716
|
-
let [, tag] = _ref8;
|
|
1683
|
+
STATEMENTS.add(SexpOpcodes.OpenElement, (op, [, tag]) => {
|
|
1717
1684
|
op(Op.OpenElement, inflateTagName(tag));
|
|
1718
1685
|
});
|
|
1719
|
-
STATEMENTS.add(SexpOpcodes.OpenElementWithSplat, (op,
|
|
1720
|
-
let [, tag] = _ref9;
|
|
1686
|
+
STATEMENTS.add(SexpOpcodes.OpenElementWithSplat, (op, [, tag]) => {
|
|
1721
1687
|
op(Op.PutComponentOperations);
|
|
1722
1688
|
op(Op.OpenElement, inflateTagName(tag));
|
|
1723
1689
|
});
|
|
1724
|
-
STATEMENTS.add(SexpOpcodes.Component, (op,
|
|
1725
|
-
let [, expr, elementBlock, named, blocks] = _ref10;
|
|
1690
|
+
STATEMENTS.add(SexpOpcodes.Component, (op, [, expr, elementBlock, named, blocks]) => {
|
|
1726
1691
|
if (isGetFreeComponent(expr)) {
|
|
1727
1692
|
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1728
1693
|
InvokeComponent(op, component, elementBlock, null, named, blocks);
|
|
@@ -1733,20 +1698,10 @@ STATEMENTS.add(SexpOpcodes.Component, (op, _ref10) => {
|
|
|
1733
1698
|
InvokeDynamicComponent(op, expr, elementBlock, null, named, blocks, true, true);
|
|
1734
1699
|
}
|
|
1735
1700
|
});
|
|
1736
|
-
STATEMENTS.add(SexpOpcodes.Yield, (op,
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
STATEMENTS.add(SexpOpcodes.AttrSplat, (op, _ref12) => {
|
|
1741
|
-
let [, to] = _ref12;
|
|
1742
|
-
return YieldBlock(op, to, null);
|
|
1743
|
-
});
|
|
1744
|
-
STATEMENTS.add(SexpOpcodes.Debugger, (op, _ref13) => {
|
|
1745
|
-
let [, debugInfo] = _ref13;
|
|
1746
|
-
return op(Op.Debugger, debugSymbolsOperand(), debugInfo);
|
|
1747
|
-
});
|
|
1748
|
-
STATEMENTS.add(SexpOpcodes.Append, (op, _ref14) => {
|
|
1749
|
-
let [, value] = _ref14;
|
|
1701
|
+
STATEMENTS.add(SexpOpcodes.Yield, (op, [, to, params]) => YieldBlock(op, to, params));
|
|
1702
|
+
STATEMENTS.add(SexpOpcodes.AttrSplat, (op, [, to]) => YieldBlock(op, to, null));
|
|
1703
|
+
STATEMENTS.add(SexpOpcodes.Debugger, (op, [, debugInfo]) => op(Op.Debugger, debugSymbolsOperand(), debugInfo));
|
|
1704
|
+
STATEMENTS.add(SexpOpcodes.Append, (op, [, value]) => {
|
|
1750
1705
|
// Special case for static values
|
|
1751
1706
|
if (!Array.isArray(value)) {
|
|
1752
1707
|
op(Op.Text, value === null || value === undefined ? '' : String(value));
|
|
@@ -1813,8 +1768,7 @@ STATEMENTS.add(SexpOpcodes.Append, (op, _ref14) => {
|
|
|
1813
1768
|
op(MachineOp.PopFrame);
|
|
1814
1769
|
}
|
|
1815
1770
|
});
|
|
1816
|
-
STATEMENTS.add(SexpOpcodes.TrustingAppend, (op,
|
|
1817
|
-
let [, value] = _ref15;
|
|
1771
|
+
STATEMENTS.add(SexpOpcodes.TrustingAppend, (op, [, value]) => {
|
|
1818
1772
|
if (!Array.isArray(value)) {
|
|
1819
1773
|
op(Op.Text, value === null || value === undefined ? '' : String(value));
|
|
1820
1774
|
} else {
|
|
@@ -1824,8 +1778,7 @@ STATEMENTS.add(SexpOpcodes.TrustingAppend, (op, _ref15) => {
|
|
|
1824
1778
|
op(MachineOp.PopFrame);
|
|
1825
1779
|
}
|
|
1826
1780
|
});
|
|
1827
|
-
STATEMENTS.add(SexpOpcodes.Block, (op,
|
|
1828
|
-
let [, expr, positional, named, blocks] = _ref16;
|
|
1781
|
+
STATEMENTS.add(SexpOpcodes.Block, (op, [, expr, positional, named, blocks]) => {
|
|
1829
1782
|
if (isGetFreeComponent(expr)) {
|
|
1830
1783
|
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1831
1784
|
InvokeComponent(op, component, null, positional, hashToArgs(named), blocks);
|
|
@@ -1834,8 +1787,7 @@ STATEMENTS.add(SexpOpcodes.Block, (op, _ref16) => {
|
|
|
1834
1787
|
InvokeDynamicComponent(op, expr, null, positional, named, blocks, false, false);
|
|
1835
1788
|
}
|
|
1836
1789
|
});
|
|
1837
|
-
STATEMENTS.add(SexpOpcodes.InElement, (op,
|
|
1838
|
-
let [, block, guid, destination, insertBefore] = _ref17;
|
|
1790
|
+
STATEMENTS.add(SexpOpcodes.InElement, (op, [, block, guid, destination, insertBefore]) => {
|
|
1839
1791
|
ReplayableIf(op, () => {
|
|
1840
1792
|
expr(op, guid);
|
|
1841
1793
|
if (insertBefore === undefined) {
|
|
@@ -1852,51 +1804,44 @@ STATEMENTS.add(SexpOpcodes.InElement, (op, _ref17) => {
|
|
|
1852
1804
|
op(Op.PopRemoteElement);
|
|
1853
1805
|
});
|
|
1854
1806
|
});
|
|
1855
|
-
STATEMENTS.add(SexpOpcodes.If, (op,
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1807
|
+
STATEMENTS.add(SexpOpcodes.If, (op, [, condition, block, inverse]) => ReplayableIf(op, () => {
|
|
1808
|
+
expr(op, condition);
|
|
1809
|
+
op(Op.ToBoolean);
|
|
1810
|
+
return 1;
|
|
1811
|
+
}, () => {
|
|
1812
|
+
InvokeStaticBlock(op, block);
|
|
1813
|
+
}, inverse ? () => {
|
|
1814
|
+
InvokeStaticBlock(op, inverse);
|
|
1815
|
+
} : undefined));
|
|
1816
|
+
STATEMENTS.add(SexpOpcodes.Each, (op, [, value, key, block, inverse]) => Replayable(op, () => {
|
|
1817
|
+
if (key) {
|
|
1818
|
+
expr(op, key);
|
|
1819
|
+
} else {
|
|
1820
|
+
PushPrimitiveReference(op, null);
|
|
1821
|
+
}
|
|
1822
|
+
expr(op, value);
|
|
1823
|
+
return 2;
|
|
1824
|
+
}, () => {
|
|
1825
|
+
op(Op.EnterList, labelOperand('BODY'), labelOperand('ELSE'));
|
|
1826
|
+
op(MachineOp.PushFrame);
|
|
1827
|
+
op(Op.Dup, $fp, 1);
|
|
1828
|
+
op(MachineOp.ReturnTo, labelOperand('ITER'));
|
|
1829
|
+
op(HighLevelBuilderOpcodes.Label, 'ITER');
|
|
1830
|
+
op(Op.Iterate, labelOperand('BREAK'));
|
|
1831
|
+
op(HighLevelBuilderOpcodes.Label, 'BODY');
|
|
1832
|
+
InvokeStaticBlockWithStack(op, block, 2);
|
|
1833
|
+
op(Op.Pop, 2);
|
|
1834
|
+
op(MachineOp.Jump, labelOperand('FINALLY'));
|
|
1835
|
+
op(HighLevelBuilderOpcodes.Label, 'BREAK');
|
|
1836
|
+
op(MachineOp.PopFrame);
|
|
1837
|
+
op(Op.ExitList);
|
|
1838
|
+
op(MachineOp.Jump, labelOperand('FINALLY'));
|
|
1839
|
+
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1840
|
+
if (inverse) {
|
|
1864
1841
|
InvokeStaticBlock(op, inverse);
|
|
1865
|
-
}
|
|
1866
|
-
});
|
|
1867
|
-
STATEMENTS.add(SexpOpcodes.
|
|
1868
|
-
let [, value, key, block, inverse] = _ref19;
|
|
1869
|
-
return Replayable(op, () => {
|
|
1870
|
-
if (key) {
|
|
1871
|
-
expr(op, key);
|
|
1872
|
-
} else {
|
|
1873
|
-
PushPrimitiveReference(op, null);
|
|
1874
|
-
}
|
|
1875
|
-
expr(op, value);
|
|
1876
|
-
return 2;
|
|
1877
|
-
}, () => {
|
|
1878
|
-
op(Op.EnterList, labelOperand('BODY'), labelOperand('ELSE'));
|
|
1879
|
-
op(MachineOp.PushFrame);
|
|
1880
|
-
op(Op.Dup, $fp, 1);
|
|
1881
|
-
op(MachineOp.ReturnTo, labelOperand('ITER'));
|
|
1882
|
-
op(HighLevelBuilderOpcodes.Label, 'ITER');
|
|
1883
|
-
op(Op.Iterate, labelOperand('BREAK'));
|
|
1884
|
-
op(HighLevelBuilderOpcodes.Label, 'BODY');
|
|
1885
|
-
InvokeStaticBlockWithStack(op, block, 2);
|
|
1886
|
-
op(Op.Pop, 2);
|
|
1887
|
-
op(MachineOp.Jump, labelOperand('FINALLY'));
|
|
1888
|
-
op(HighLevelBuilderOpcodes.Label, 'BREAK');
|
|
1889
|
-
op(MachineOp.PopFrame);
|
|
1890
|
-
op(Op.ExitList);
|
|
1891
|
-
op(MachineOp.Jump, labelOperand('FINALLY'));
|
|
1892
|
-
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1893
|
-
if (inverse) {
|
|
1894
|
-
InvokeStaticBlock(op, inverse);
|
|
1895
|
-
}
|
|
1896
|
-
});
|
|
1897
|
-
});
|
|
1898
|
-
STATEMENTS.add(SexpOpcodes.With, (op, _ref20) => {
|
|
1899
|
-
let [, value, block, inverse] = _ref20;
|
|
1842
|
+
}
|
|
1843
|
+
}));
|
|
1844
|
+
STATEMENTS.add(SexpOpcodes.With, (op, [, value, block, inverse]) => {
|
|
1900
1845
|
ReplayableIf(op, () => {
|
|
1901
1846
|
expr(op, value);
|
|
1902
1847
|
op(Op.Dup, $sp, 0);
|
|
@@ -1910,13 +1855,11 @@ STATEMENTS.add(SexpOpcodes.With, (op, _ref20) => {
|
|
|
1910
1855
|
}
|
|
1911
1856
|
});
|
|
1912
1857
|
});
|
|
1913
|
-
STATEMENTS.add(SexpOpcodes.Let, (op,
|
|
1914
|
-
let [, positional, block] = _ref21;
|
|
1858
|
+
STATEMENTS.add(SexpOpcodes.Let, (op, [, positional, block]) => {
|
|
1915
1859
|
let count = CompilePositional(op, positional);
|
|
1916
1860
|
InvokeStaticBlockWithStack(op, block, count);
|
|
1917
1861
|
});
|
|
1918
|
-
STATEMENTS.add(SexpOpcodes.WithDynamicVars, (op,
|
|
1919
|
-
let [, named, block] = _ref22;
|
|
1862
|
+
STATEMENTS.add(SexpOpcodes.WithDynamicVars, (op, [, named, block]) => {
|
|
1920
1863
|
if (named) {
|
|
1921
1864
|
let [names, expressions] = named;
|
|
1922
1865
|
CompilePositional(op, expressions);
|
|
@@ -1927,8 +1870,7 @@ STATEMENTS.add(SexpOpcodes.WithDynamicVars, (op, _ref22) => {
|
|
|
1927
1870
|
InvokeStaticBlock(op, block);
|
|
1928
1871
|
}
|
|
1929
1872
|
});
|
|
1930
|
-
STATEMENTS.add(SexpOpcodes.InvokeComponent, (op,
|
|
1931
|
-
let [, expr, positional, named, blocks] = _ref23;
|
|
1873
|
+
STATEMENTS.add(SexpOpcodes.InvokeComponent, (op, [, expr, positional, named, blocks]) => {
|
|
1932
1874
|
if (isGetFreeComponent(expr)) {
|
|
1933
1875
|
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1934
1876
|
InvokeComponent(op, component, null, positional, hashToArgs(named), blocks);
|
|
@@ -1948,8 +1890,9 @@ class CompilableTemplateImpl {
|
|
|
1948
1890
|
compiled = null;
|
|
1949
1891
|
constructor(statements, meta,
|
|
1950
1892
|
// Part of CompilableTemplate
|
|
1951
|
-
symbolTable
|
|
1952
|
-
|
|
1893
|
+
symbolTable,
|
|
1894
|
+
// Used for debugging
|
|
1895
|
+
moduleName = 'plain block') {
|
|
1953
1896
|
this.statements = statements;
|
|
1954
1897
|
this.meta = meta;
|
|
1955
1898
|
this.symbolTable = symbolTable;
|
|
@@ -1989,10 +1932,7 @@ function compileStatements(statements, meta, syntaxContext) {
|
|
|
1989
1932
|
resolver
|
|
1990
1933
|
}
|
|
1991
1934
|
} = context;
|
|
1992
|
-
function pushOp() {
|
|
1993
|
-
for (var _len = arguments.length, op = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1994
|
-
op[_key] = arguments[_key];
|
|
1995
|
-
}
|
|
1935
|
+
function pushOp(...op) {
|
|
1996
1936
|
encodeOp(encoder, constants, resolver, meta, op);
|
|
1997
1937
|
}
|
|
1998
1938
|
for (const statement of statements) {
|
|
@@ -2074,10 +2014,7 @@ class WrappedBuilder {
|
|
|
2074
2014
|
resolver
|
|
2075
2015
|
}
|
|
2076
2016
|
} = context;
|
|
2077
|
-
function pushOp() {
|
|
2078
|
-
for (var _len = arguments.length, op = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2079
|
-
op[_key] = arguments[_key];
|
|
2080
|
-
}
|
|
2017
|
+
function pushOp(...op) {
|
|
2081
2018
|
encodeOp(encoder, constants, resolver, m, op);
|
|
2082
2019
|
}
|
|
2083
2020
|
WrappedComponent(pushOp, this.layout, this.attrsBlockNumber);
|
|
@@ -2103,14 +2040,13 @@ let templateCacheCounters = {
|
|
|
2103
2040
|
* that handles lazy parsing the template and to create per env singletons
|
|
2104
2041
|
* of the template.
|
|
2105
2042
|
*/
|
|
2106
|
-
function templateFactory(
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
} = _ref;
|
|
2043
|
+
function templateFactory({
|
|
2044
|
+
id: templateId,
|
|
2045
|
+
moduleName,
|
|
2046
|
+
block,
|
|
2047
|
+
scope,
|
|
2048
|
+
isStrictMode
|
|
2049
|
+
}) {
|
|
2114
2050
|
// TODO(template-refactors): This should be removed in the near future, as it
|
|
2115
2051
|
// appears that id is unused. It is currently kept for backwards compat reasons.
|
|
2116
2052
|
let id = templateId || `client-${clientId++}`;
|
|
@@ -79,8 +79,9 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
79
79
|
helperDefinitionCache = new WeakMap();
|
|
80
80
|
modifierDefinitionCache = new WeakMap();
|
|
81
81
|
componentDefinitionCache = new WeakMap();
|
|
82
|
-
helper(definitionState
|
|
83
|
-
|
|
82
|
+
helper(definitionState,
|
|
83
|
+
// TODO: Add a way to expose resolved name for debugging
|
|
84
|
+
_resolvedName = null, isOptional) {
|
|
84
85
|
let handle = this.helperDefinitionCache.get(definitionState);
|
|
85
86
|
if (handle === undefined) {
|
|
86
87
|
let managerOrHelper = getInternalHelperManager(definitionState, isOptional);
|
|
@@ -96,9 +97,7 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
96
97
|
}
|
|
97
98
|
return handle;
|
|
98
99
|
}
|
|
99
|
-
modifier(definitionState) {
|
|
100
|
-
let resolvedName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
101
|
-
let isOptional = arguments.length > 2 ? arguments[2] : undefined;
|
|
100
|
+
modifier(definitionState, resolvedName = null, isOptional) {
|
|
102
101
|
let handle = this.modifierDefinitionCache.get(definitionState);
|
|
103
102
|
if (handle === undefined) {
|
|
104
103
|
let manager = getInternalModifierManager(definitionState, isOptional);
|
|
@@ -387,8 +386,7 @@ class HeapImpl {
|
|
|
387
386
|
}
|
|
388
387
|
this.offset = this.offset - compactedSize;
|
|
389
388
|
}
|
|
390
|
-
capture() {
|
|
391
|
-
let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.offset;
|
|
389
|
+
capture(offset = this.offset) {
|
|
392
390
|
// Only called in eager mode
|
|
393
391
|
let buffer = slice(this.heap, 0, offset).buffer;
|
|
394
392
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEBUG } from '@glimmer/env';
|
|
2
|
-
import { getProp, toIterator,
|
|
2
|
+
import { setProp, getProp, toIterator, getPath } from '@glimmer/global-context';
|
|
3
3
|
import { expect, isDict, EMPTY_ARRAY, isObject } from '@glimmer/util';
|
|
4
4
|
import { CONSTANT_TAG, validateTag, track, valueForTag, consumeTag, createTag, dirtyTag, INITIAL } from '@glimmer/validator';
|
|
5
5
|
|
|
@@ -55,9 +55,7 @@ function createUnboundRef(value, debugLabel) {
|
|
|
55
55
|
}
|
|
56
56
|
return ref;
|
|
57
57
|
}
|
|
58
|
-
function createComputeRef(compute) {
|
|
59
|
-
let update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
60
|
-
let debugLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
|
|
58
|
+
function createComputeRef(compute, update = null, debugLabel = 'unknown') {
|
|
61
59
|
const ref = new ReferenceImpl(COMPUTE);
|
|
62
60
|
ref.compute = compute;
|
|
63
61
|
ref.update = update;
|