Skip to content

Commit

Permalink
Update to Glimmer VM 0.67.0, integrate opcode compiler refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Nov 24, 2020
1 parent e9c4bc7 commit c4b8281
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 269 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@
},
"devDependencies": {
"@babel/preset-env": "^7.9.5",
"@glimmer/compiler": "0.66.1",
"@glimmer/compiler": "0.67.0",
"@glimmer/env": "^0.1.7",
"@glimmer/global-context": "0.66.1",
"@glimmer/interfaces": "0.66.1",
"@glimmer/node": "0.66.1",
"@glimmer/opcode-compiler": "0.66.1",
"@glimmer/program": "0.66.1",
"@glimmer/reference": "0.66.1",
"@glimmer/runtime": "0.66.1",
"@glimmer/validator": "0.66.1",
"@glimmer/global-context": "0.67.0",
"@glimmer/interfaces": "0.67.0",
"@glimmer/node": "0.67.0",
"@glimmer/opcode-compiler": "0.67.0",
"@glimmer/program": "0.67.0",
"@glimmer/reference": "0.67.0",
"@glimmer/runtime": "0.67.0",
"@glimmer/validator": "0.67.0",
"@simple-dom/document": "^1.4.0",
"@types/qunit": "^2.9.1",
"@types/rsvp": "^4.0.3",
Expand Down
4 changes: 0 additions & 4 deletions packages/@ember/-internals/glimmer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ export {
} from './lib/template_registry';
export { setupEngineRegistry, setupApplicationRegistry } from './lib/setup-registry';
export { DOMChanges, NodeDOMTreeConstruction, DOMTreeConstruction } from './lib/dom';
export {
registerMacros as _registerMacros,
experimentalMacros as _experimentalMacros,
} from './lib/syntax';

// needed for test
// TODO just test these through public API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export default class CurlyComponentManager
return null;
}

return { positional: EMPTY_ARRAY as readonly Reference[], named };
return { positional: EMPTY_ARRAY as Reference[], named };
}

/*
Expand Down
18 changes: 7 additions & 11 deletions packages/@ember/-internals/glimmer/lib/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { backburner, getCurrentRunLoop } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import {
Bounds,
CompileTimeCompilationContext,
Cursor,
DebugRenderTree,
DynamicScope as GlimmerDynamicScope,
Expand All @@ -14,11 +15,10 @@ import {
Option,
RenderResult,
RuntimeContext,
SyntaxCompilationContext,
Template,
TemplateFactory,
} from '@glimmer/interfaces';
import { syntaxCompilationContext } from '@glimmer/opcode-compiler';
import { programCompilationContext } from '@glimmer/opcode-compiler';
import { artifacts } from '@glimmer/program';
import { createConstRef, Reference, UNDEFINED_REFERENCE, valueForRef } from '@glimmer/reference';
import {
Expand All @@ -32,7 +32,7 @@ import {
renderMain,
runtimeContext,
} from '@glimmer/runtime';
import { unwrapHandle, unwrapTemplate } from '@glimmer/util';
import { unwrapTemplate } from '@glimmer/util';
import { CURRENT_TAG, validateTag, valueForTag } from '@glimmer/validator';
import { SimpleDocument, SimpleElement, SimpleNode } from '@simple-dom/interface';
import RSVP from 'rsvp';
Expand All @@ -43,7 +43,6 @@ import { RootComponentDefinition } from './component-managers/root';
import { NodeDOMTreeConstruction } from './dom';
import { EmberEnvironmentDelegate } from './environment';
import RuntimeResolver from './resolver';
import { populateMacros } from './syntax';
import { Component } from './utils/curly-component-state-bucket';
import { OutletState } from './utils/outlet';
import OutletView from './views/outlet';
Expand Down Expand Up @@ -117,7 +116,7 @@ class RootState {
constructor(
public root: Component | OutletView,
public runtime: RuntimeContext,
context: SyntaxCompilationContext,
context: CompileTimeCompilationContext,
template: Template,
self: Reference<unknown>,
parentElement: SimpleElement,
Expand All @@ -135,14 +134,13 @@ class RootState {

this.render = errorLoopTransaction(() => {
let layout = unwrapTemplate(template).asLayout();
let handle = layout.compile(context);

let iterator = renderMain(
runtime,
context,
self,
builder(runtime.env, { element: parentElement, nextSibling: null }),
unwrapHandle(handle),
layout,
dynamicScope
);

Expand Down Expand Up @@ -281,7 +279,7 @@ export abstract class Renderer {
private _builder: IBuilder;
private _inRenderTransaction = false;

private _context: SyntaxCompilationContext;
private _context: CompileTimeCompilationContext;
private _runtime: RuntimeContext;

private _lastRevision = -1;
Expand Down Expand Up @@ -311,9 +309,7 @@ export abstract class Renderer {

let sharedArtifacts = artifacts();

let context = (this._context = syntaxCompilationContext(sharedArtifacts, compileTimeResolver));

populateMacros(context.macros);
this._context = programCompilationContext(sharedArtifacts, compileTimeResolver);

let runtimeEnvironmentDelegate = new EmberEnvironmentDelegate(owner, env.isInteractive);
this._runtime = runtimeContext(
Expand Down
85 changes: 0 additions & 85 deletions packages/@ember/-internals/glimmer/lib/syntax.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -460,40 +460,59 @@ moduleFor(
this.assertHTML('<div data-foo-bar="baz"></div>');
}

['@test simple helper not usable with a block']() {
['@test simple helper not usable with a block'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}
this.registerHelper('some-helper', () => {});

expectAssertion(() => {
assert.throws(() => {
this.render(`{{#some-helper}}{{/some-helper}}`);
}, /Helpers may not be used in the block form/);
}, /Attempted to resolve `some-helper`, which was expected to be a component, but nothing was found./);
}

['@test class-based helper not usable with a block']() {
['@test class-based helper not usable with a block'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', {
compute() {},
});

expectAssertion(() => {
assert.throws(() => {
this.render(`{{#some-helper}}{{/some-helper}}`);
}, /Helpers may not be used in the block form/);
}, /Attempted to resolve `some-helper`, which was expected to be a component, but nothing was found./);
}

['@test simple helper not usable within element']() {
['@test simple helper not usable within element'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', () => {});

this.assert.throws(() => {
assert.throws(() => {
this.render(`<div {{some-helper}}></div>`);
}, /Error: Compile Error: Unexpected Modifier some-helper @ 0..0/);
}, /Attempted to resolve `some-helper`, which was expected to be a modifier, but nothing was found./);
}

['@test class-based helper not usable within element']() {
['@test class-based helper not usable within element'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', {
compute() {},
});

this.assert.throws(() => {
assert.throws(() => {
this.render(`<div {{some-helper}}></div>`);
}, /Error: Compile Error: Unexpected Modifier some-helper @ 0..0/);
}, /Attempted to resolve `some-helper`, which was expected to be a modifier, but nothing was found./);
}

['@test class-based helper is torn down'](assert) {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ember/tests/component_registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ moduleFor(
async ['@test Using name of component that does not exist'](assert) {
this.addTemplate('application', `<div id='wrapper'>{{#no-good}} {{/no-good}}</div>`);

await assert.rejectsAssertion(this.visit('/'), /.* named "no-good" .*/);
await assert.rejectsAssertion(this.visit('/'), /Attempted to resolve `no-good`/);
}
}
);
Loading

0 comments on commit c4b8281

Please sign in to comment.