Skip to content

Commit

Permalink
Follow up: more {{partial}} cleanup after removal
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Oct 18, 2021
1 parent 6f9b8b1 commit 1200963
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 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
21 changes: 3 additions & 18 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 @@ -129,29 +128,15 @@ 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,
}),
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 1200963

Please sign in to comment.