Skip to content

Commit

Permalink
Merge pull request #1349 from snewcomer/sn/more-partial-removal
Browse files Browse the repository at this point in the history
Follow up: more {{partial}} cleanup after removal
  • Loading branch information
rwjblue authored Oct 22, 2021
2 parents 7f31a20 + 96c0be9 commit 0ac3cdf
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 32 deletions.
3 changes: 0 additions & 3 deletions packages/@glimmer/interfaces/lib/template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface LayoutWithContext {
readonly owner: Owner | null;
readonly scope: (() => unknown[]) | undefined | null;
readonly isStrictMode: boolean;
readonly asPartial: boolean;
}

export interface BlockWithContext {
Expand All @@ -40,7 +39,6 @@ export interface TemplateOk {

// internal casts, these are lazily created and cached
asLayout(): CompilableProgram;
asPartial(): CompilableProgram;
asWrappedLayout(): CompilableProgram;
}

Expand Down Expand Up @@ -95,7 +93,6 @@ export interface NamedBlocks {
}

export interface ContainingMetadata {
asPartial: boolean;
evalSymbols: Option<string[]>;
upvars: Option<string[]>;
scopeValues: unknown[] | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ export function encodeOp(
freeVar
];

if (meta.asPartial === true) {
encoder.push(constants, Op.ResolveMaybeLocal, name);
} else {
let then = op[2];
let andThen = op[2];

then(name, meta.moduleName);
}
andThen(name, meta.moduleName);

break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export function meta(layout: LayoutWithContext): ContainingMetadata {
let [, symbols, , upvars] = layout.block;

return {
asPartial: layout.asPartial || false,
evalSymbols: evalSymbols(layout),
upvars: upvars,
scopeValues: layout.scope?.() ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export function compileStd(context: CompileTimeCompilationContext): StdLib {
}

const STDLIB_META = {
asPartial: false,
evalSymbols: null,
upvars: null,
moduleName: 'stdlib',
Expand Down
24 changes: 3 additions & 21 deletions packages/@glimmer/opcode-compiler/lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ class TemplateImpl implements TemplateWithIdAndReferrer {
readonly result = 'ok';

private layout: Option<CompilableProgram> = null;
private partial: Option<CompilableProgram> = null;
private wrappedLayout: Option<CompilableProgram> = null;

constructor(private parsedLayout: Omit<LayoutWithContext, 'asPartial'>) {}
constructor(private parsedLayout: LayoutWithContext) {}

get moduleName() {
return this.parsedLayout.moduleName;
Expand All @@ -128,30 +127,13 @@ class TemplateImpl implements TemplateWithIdAndReferrer {

asLayout(): CompilableProgram {
if (this.layout) return this.layout;
return (this.layout = compilable(
assign({}, this.parsedLayout, {
asPartial: false,
}),
this.moduleName
));
}

asPartial(): CompilableProgram {
if (this.partial) return this.partial;
return (this.partial = compilable(
assign({}, this.parsedLayout, {
asPartial: true,
}),
this.moduleName
));
return (this.layout = compilable(assign({}, this.parsedLayout), this.moduleName));
}

asWrappedLayout(): CompilableProgram {
if (this.wrappedLayout) return this.wrappedLayout;
return (this.wrappedLayout = new WrappedBuilder(
assign({}, this.parsedLayout, {
asPartial: false,
}),
assign({}, this.parsedLayout),
this.moduleName
));
}
Expand Down

0 comments on commit 0ac3cdf

Please sign in to comment.