From ca443d01d22409da0c1001557e0852017654045e Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 25 Aug 2016 01:10:52 -0400 Subject: [PATCH] Update Glimmer to 0.11.0. * Threads `SymbolTable` throughout the system instead of `blockMeta`. * Change a few argument signatures for Glimmer syntax's (moving from options hash to positional, etc). --- package.json | 2 +- packages/ember-glimmer/lib/environment.js | 30 +++++++++---------- .../ember-glimmer/lib/helpers/component.js | 14 ++++----- .../lib/syntax/curly-component.js | 5 ++-- .../lib/syntax/dynamic-component.js | 26 ++++++++-------- packages/ember-glimmer/lib/syntax/outlet.js | 5 ++-- packages/ember-glimmer/lib/syntax/render.js | 5 ++-- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index cf43d194093..d516cea51cc 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "git-repo-info": "^1.1.4", "git-repo-version": "^0.3.1", "github": "^0.2.3", - "glimmer-engine": "0.10.2", + "glimmer-engine": "0.11.0", "glob": "^5.0.13", "htmlbars": "0.14.24", "mocha": "^2.4.5", diff --git a/packages/ember-glimmer/lib/environment.js b/packages/ember-glimmer/lib/environment.js index ca45e4cab1c..6b0148b22f7 100644 --- a/packages/ember-glimmer/lib/environment.js +++ b/packages/ember-glimmer/lib/environment.js @@ -193,7 +193,7 @@ export default class Environment extends GlimmerEnvironment { // isn't going to return any syntax and the Glimmer engine knows how to handle // this case. - refineStatement(statement, blockMeta) { + refineStatement(statement, symbolTable) { // 1. resolve any native syntax – if, unless, with, each, and partial let nativeSyntax = super.refineStatement(statement); @@ -219,7 +219,7 @@ export default class Environment extends GlimmerEnvironment { // 2. built-in syntax if (key === 'component') { - return DynamicComponentSyntax.create({ args, templates, blockMeta }); + return DynamicComponentSyntax.create({ args, templates, symbolTable }); } else if (key === 'render') { return new RenderSyntax({ args }); } else if (key === 'outlet') { @@ -230,9 +230,9 @@ export default class Environment extends GlimmerEnvironment { let definition = null; if (internalKey) { - definition = this.getComponentDefinition([internalKey], blockMeta); + definition = this.getComponentDefinition([internalKey], symbolTable); } else if (key.indexOf('-') >= 0) { - definition = this.getComponentDefinition(path, blockMeta); + definition = this.getComponentDefinition(path, symbolTable); } if (definition) { @@ -241,10 +241,10 @@ export default class Environment extends GlimmerEnvironment { let generateBuiltInSyntax = builtInDynamicComponents[key]; if (generateBuiltInSyntax) { - return generateBuiltInSyntax(statement, (path) => this.getComponentDefinition([path], blockMeta)); + return generateBuiltInSyntax(statement, (path) => this.getComponentDefinition([path], symbolTable)); } - assert(`A helper named "${key}" could not be found`, !isBlock || this.hasHelper(key, blockMeta)); + assert(`A helper named "${key}" could not be found`, !isBlock || this.hasHelper(key, symbolTable)); } if ((!isSimple && appendType === 'unknown') || appendType === 'self-get') { @@ -252,21 +252,21 @@ export default class Environment extends GlimmerEnvironment { } if (!isSimple && path) { - return DynamicComponentSyntax.fromPath({ path, args, templates, blockMeta }); + return DynamicComponentSyntax.fromPath({ path, args, templates, symbolTable }); } - assert(`Helpers may not be used in the block form, for example {{#${key}}}{{/${key}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${key})}}{{/if}}.`, !isBlock || !this.hasHelper(key, blockMeta)); + assert(`Helpers may not be used in the block form, for example {{#${key}}}{{/${key}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${key})}}{{/if}}.`, !isBlock || !this.hasHelper(key, symbolTable)); - assert(`Helpers may not be used in the element form.`, !nativeSyntax && key && this.hasHelper(key, blockMeta) ? !isModifier : true); + assert(`Helpers may not be used in the element form.`, !nativeSyntax && key && this.hasHelper(key, symbolTable) ? !isModifier : true); } hasComponentDefinition() { return false; } - getComponentDefinition(path, blockMeta) { + getComponentDefinition(path, symbolTable) { let name = path[0]; - let source = blockMeta && `template:${blockMeta.moduleName}`; + let source = symbolTable && `template:${symbolTable.getMeta().moduleName}`; return this._definitionCache.get({ name, source }); } @@ -299,15 +299,15 @@ export default class Environment extends GlimmerEnvironment { } } - hasHelper(name, blockMeta) { - let options = blockMeta && { source: `template:${blockMeta.moduleName}` } || {}; + hasHelper(name, symbolTable) { + let options = symbolTable && { source: `template:${symbolTable.getMeta().moduleName}` } || {}; return !!builtInHelpers[name[0]] || this.owner.hasRegistration(`helper:${name}`, options) || this.owner.hasRegistration(`helper:${name}`); } - lookupHelper(name, blockMeta) { - let options = blockMeta && { source: `template:${blockMeta.moduleName}` } || {}; + lookupHelper(name, symbolTable) { + let options = symbolTable && { source: `template:${symbolTable.getMeta().moduleName}` } || {}; let helper = builtInHelpers[name[0]] || this.owner.lookup(`helper:${name}`, options) || this.owner.lookup(`helper:${name}`); diff --git a/packages/ember-glimmer/lib/helpers/component.js b/packages/ember-glimmer/lib/helpers/component.js index 33fb32b71c6..6ef22fb2bc7 100644 --- a/packages/ember-glimmer/lib/helpers/component.js +++ b/packages/ember-glimmer/lib/helpers/component.js @@ -5,16 +5,16 @@ import { assert } from 'ember-metal/debug'; import assign from 'ember-metal/assign'; export class ClosureComponentReference extends CachedReference { - static create(args, blockMeta, env) { - return new ClosureComponentReference(args, blockMeta, env); + static create(args, symbolTable, env) { + return new ClosureComponentReference(args, symbolTable, env); } - constructor(args, blockMeta, env) { + constructor(args, symbolTable, env) { super(); this.defRef = args.positional.at(0); this.env = env; this.tag = args.positional.at(0).tag; - this.blockMeta = blockMeta; + this.symbolTable = symbolTable; this.args = args; this.lastDefinition = undefined; this.lastName = undefined; @@ -24,7 +24,7 @@ export class ClosureComponentReference extends CachedReference { // TODO: Figure out how to extract this because it's nearly identical to // DynamicComponentReference::compute(). The only differences besides // currying are in the assertion messages. - let { args, defRef, env, blockMeta, lastDefinition, lastName } = this; + let { args, defRef, env, symbolTable, lastDefinition, lastName } = this; let nameOrDef = defRef.value(); let definition = null; @@ -35,7 +35,7 @@ export class ClosureComponentReference extends CachedReference { this.lastName = nameOrDef; if (typeof nameOrDef === 'string') { - definition = env.getComponentDefinition([nameOrDef], blockMeta); + definition = env.getComponentDefinition([nameOrDef], symbolTable); assert(`The component helper cannot be used without a valid component name. You used "${nameOrDef}" via (component "${nameOrDef}")`, definition); } else if (isComponentDefinition(nameOrDef)) { definition = nameOrDef; @@ -127,7 +127,7 @@ export default { isInternalHelper: true, toReference(args, env) { - // TODO: Need to figure out what to do about blockMeta here. + // TODO: Need to figure out what to do about symbolTable here. return ClosureComponentReference.create(args, null, env); } }; diff --git a/packages/ember-glimmer/lib/syntax/curly-component.js b/packages/ember-glimmer/lib/syntax/curly-component.js index d95c6335f4b..fc7e7fb2968 100644 --- a/packages/ember-glimmer/lib/syntax/curly-component.js +++ b/packages/ember-glimmer/lib/syntax/curly-component.js @@ -104,16 +104,17 @@ function applyAttributeBindings(element, attributeBindings, component, operation } export class CurlyComponentSyntax extends StatementSyntax { - constructor({ args, definition, templates }) { + constructor({ args, definition, templates, symbolTable }) { super(); this.args = args; this.definition = definition; this.templates = templates; + this.symbolTable = symbolTable; this.shadow = null; } compile(builder) { - builder.component.static(this); + builder.component.static(this.definition, this.args, this.templates, this.symbolTable, this.shadow); } } diff --git a/packages/ember-glimmer/lib/syntax/dynamic-component.js b/packages/ember-glimmer/lib/syntax/dynamic-component.js index 3208e79e00f..7832eb67690 100644 --- a/packages/ember-glimmer/lib/syntax/dynamic-component.js +++ b/packages/ember-glimmer/lib/syntax/dynamic-component.js @@ -12,59 +12,59 @@ function dynamicComponentFor(vm) { let env = vm.env; let args = vm.getArgs(); let nameRef = args.positional.at(0); - let { blockMeta } = this; + let { symbolTable } = this; - return new DynamicComponentReference({ nameRef, env, blockMeta }); + return new DynamicComponentReference({ nameRef, env, symbolTable }); } export class DynamicComponentSyntax extends StatementSyntax { // for {{component componentName}} - static create({ args, templates, blockMeta }) { + static create({ args, templates, symbolTable }) { let definitionArgs = ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); let invocationArgs = ArgsSyntax.build(args.positional.slice(1), args.named); - return new this({ definitionArgs, args: invocationArgs, templates, blockMeta }); + return new this({ definitionArgs, args: invocationArgs, templates, symbolTable }); } // Transforms {{foo.bar with=args}} or {{#foo.bar with=args}}{{/foo.bar}} // into {{component foo.bar with=args}} or // {{#component foo.bar with=args}}{{/component}} // with all of it's arguments - static fromPath({ path, args, templates, blockMeta }) { + static fromPath({ path, args, templates, symbolTable }) { let positional = ArgsSyntax.fromPositionalArgs(PositionalArgsSyntax.build([GetSyntax.build(path.join('.'))])); - return new this({ definitionArgs: positional, args, templates, blockMeta }); + return new this({ definitionArgs: positional, args, templates, symbolTable }); } - constructor({ definitionArgs, args, templates, blockMeta }) { + constructor({ definitionArgs, args, templates, symbolTable }) { super(); this.definition = dynamicComponentFor.bind(this); this.definitionArgs = definitionArgs; this.args = args; this.templates = templates; + this.symbolTable = symbolTable; this.shadow = null; - this.blockMeta = blockMeta; } compile(builder) { - builder.component.dynamic(this); + builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow); } } class DynamicComponentReference { - constructor({ nameRef, env, blockMeta, args }) { + constructor({ nameRef, env, symbolTable, args }) { this.tag = nameRef.tag; this.nameRef = nameRef; this.env = env; - this.blockMeta = blockMeta; + this.symbolTable = symbolTable; this.args = args; } value() { - let { env, nameRef, blockMeta } = this; + let { env, nameRef, symbolTable } = this; let nameOrDef = nameRef.value(); if (typeof nameOrDef === 'string') { - let definition = env.getComponentDefinition([nameOrDef], blockMeta); + let definition = env.getComponentDefinition([nameOrDef], symbolTable); assert(`Could not find component named "${nameOrDef}" (no component or template with that name was found)`, definition); diff --git a/packages/ember-glimmer/lib/syntax/outlet.js b/packages/ember-glimmer/lib/syntax/outlet.js index 2fff61600ba..fa27dc0c002 100644 --- a/packages/ember-glimmer/lib/syntax/outlet.js +++ b/packages/ember-glimmer/lib/syntax/outlet.js @@ -16,17 +16,18 @@ function outletComponentFor(vm) { } export class OutletSyntax extends StatementSyntax { - constructor({ args }) { + constructor({ args, symbolTable }) { super(); this.definitionArgs = args; this.definition = outletComponentFor; this.args = ArgsSyntax.empty(); + this.symbolTable = symbolTable; this.templates = null; this.shadow = null; } compile(builder) { - builder.component.dynamic(this); + builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow); } } diff --git a/packages/ember-glimmer/lib/syntax/render.js b/packages/ember-glimmer/lib/syntax/render.js index 38e0565d53a..a6937cef82f 100644 --- a/packages/ember-glimmer/lib/syntax/render.js +++ b/packages/ember-glimmer/lib/syntax/render.js @@ -41,17 +41,18 @@ function makeComponentDefinition(vm) { } export class RenderSyntax extends StatementSyntax { - constructor({ args }) { + constructor({ args, symbolTable }) { super(); this.definitionArgs = args; this.definition = makeComponentDefinition; this.args = ArgsSyntax.fromPositionalArgs(args.positional.slice(1, 2)); this.templates = null; + this.symbolTable = symbolTable; this.shadow = null; } compile(builder) { - builder.component.dynamic(this); + builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow); } }