Skip to content

Commit

Permalink
Merge pull request emberjs#14134 from emberjs/update-glimmer-threadin…
Browse files Browse the repository at this point in the history
…g-symbol-table

Update Glimmer to 0.11.0.
  • Loading branch information
rwjblue authored Aug 26, 2016
2 parents fa82fe7 + ca443d0 commit b769492
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 15 additions & 15 deletions packages/ember-glimmer/lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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') {
Expand All @@ -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) {
Expand All @@ -241,32 +241,32 @@ 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') {
return statement.original.deopt();
}

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 });
}

Expand Down Expand Up @@ -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}`);
Expand Down
14 changes: 7 additions & 7 deletions packages/ember-glimmer/lib/helpers/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
};
5 changes: 3 additions & 2 deletions packages/ember-glimmer/lib/syntax/curly-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
26 changes: 13 additions & 13 deletions packages/ember-glimmer/lib/syntax/dynamic-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions packages/ember-glimmer/lib/syntax/outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/ember-glimmer/lib/syntax/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b769492

Please sign in to comment.