Skip to content

Commit

Permalink
Merge pull request #1047 from glimmerjs/cleanup-runtime-deps
Browse files Browse the repository at this point in the history
[CLEANUP][BREAKING] Remove runtime dep on opcode-compiler
  • Loading branch information
rwjblue authored Feb 18, 2020
2 parents 11cc83b + 6a9378d commit 61a1510
Show file tree
Hide file tree
Showing 29 changed files with 80 additions and 97 deletions.
14 changes: 7 additions & 7 deletions build/broccoli/strip-glimmer-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ function stripFlags(glimmerUtils) {
},
]);

glimmerUtils.push([
nuke,
{
source: '@glimmer/debug',
delegate: removeLogging,
},
]);
glimmerUtils.push([nuke, { source: '@glimmer/debug' }]);
glimmerUtils.push([nuke, { source: '@glimmer/vm/lib/-debug-strip' }]);
glimmerUtils.push([nuke, { source: '@glimmer/runtime/lib/compiled/opcodes/-debug-strip' }]);
Expand All @@ -64,13 +71,6 @@ function stripFlags(glimmerUtils) {
delegate: removeMetaData,
},
]);
glimmerUtils.push([
nuke,
{
source: '@glimmer/opcode-compiler',
delegate: removeLogging,
},
]);
}

function removeMetaData(bindingName, path, t) {
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/stack-check';
export * from './lib/metadata';
export { opcodeMetadata } from './lib/opcode-metadata';
export { debug, debugSlice, logOpcode } from './lib/debug';
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
Maybe,
TemplateCompilationContext,
} from '@glimmer/interfaces';
import { Register, $s0, $s1, $t0, $t1, $v0, $fp, $sp, $pc, $ra } from '@glimmer/vm';
import { LOCAL_SHOULD_LOG } from '@glimmer/local-debug-flags';
import { opcodeMetadata, Primitive } from '@glimmer/debug';
import { RuntimeOpImpl } from '@glimmer/program';
import { Register, $s0, $s1, $t0, $t1, $v0, $fp, $sp, $pc, $ra } from '@glimmer/vm';
import { decodeImmediate, isHandle, HandleConstants, decodeHandle } from '@glimmer/util';
import { opcodeMetadata } from './opcode-metadata';
import { Primitive } from './stack-check';

export interface DebugConstants {
getNumber(value: number): number;
Expand Down
3 changes: 1 addition & 2 deletions packages/@glimmer/integration-tests/lib/components/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
ComponentCapabilities,
} from '@glimmer/interfaces';
import { TestComponentDefinitionState } from './test-component';
import { unreachable, expect } from '@glimmer/util';
import { unreachable, expect, unwrapTemplate } from '@glimmer/util';
import { VersionedPathReference, UpdatableRootReference } from '@glimmer/reference';
import { Tag, CONSTANT_TAG } from '@glimmer/validator';
import { unwrapTemplate } from '@glimmer/opcode-compiler';

export interface BasicComponentFactory {
new (): BasicComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import {
Invocation,
Destroyable,
} from '@glimmer/interfaces';
import { keys, assign } from '@glimmer/util';
import { keys, assign, unwrapTemplate } from '@glimmer/util';
import { BASIC_CAPABILITIES } from './capabilities';
import { TestComponentDefinitionState } from './test-component';
import { TestComponentConstructor } from './types';
import { EmberishCurlyComponentFactory } from './emberish-curly';
import { unwrapTemplate } from '@glimmer/opcode-compiler';

export type Attrs = Dict;
export type AttrsDiff = { oldAttrs: Option<Attrs>; newAttrs: Attrs };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { assertElement, firstElementChild } from '../dom/simple-utils';
import { UpdatableRootReference } from '@glimmer/reference';
import { renderJitMain, clientBuilder } from '@glimmer/runtime';
import { SimpleElement } from '@simple-dom/interface';
import { assign } from '@glimmer/util';
import { unwrapTemplate, unwrapHandle } from '@glimmer/opcode-compiler';
import { assign, unwrapTemplate, unwrapHandle } from '@glimmer/util';

export class EmberishRootView {
private template: Template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TestComponentDefinitionState } from './test-component';
import { ComponentCapabilities, CompilableProgram, Option } from '@glimmer/interfaces';
import TestJitRuntimeResolver from '../modes/jit/resolver';
import { createTemplate } from '../compile';
import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { unwrapTemplate } from '@glimmer/util';

export class StaticTaglessComponentManager extends BasicComponentManager {
getCapabilities(state: TestComponentDefinitionState): ComponentCapabilities {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CompileTimeComponent,
} from '@glimmer/interfaces';
import { TestJitRegistry } from './registry';
import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { unwrapTemplate } from '@glimmer/util';
import TestJitRuntimeResolver from './resolver';

export default class JitCompileTimeLookup implements CompileTimeResolverDelegate {
Expand Down
5 changes: 3 additions & 2 deletions packages/@glimmer/integration-tests/lib/modes/jit/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ComponentManager,
ComponentCapabilities,
ComponentDefinition,
PartialDefinition,
} from '@glimmer/interfaces';
import {
EmberishCurlyComponent,
Expand All @@ -28,7 +29,7 @@ import {
TestModifierDefinitionState,
TestModifierManager,
} from '../../modifiers';
import { PartialDefinition } from '@glimmer/opcode-compiler';
import { PartialDefinitionImpl } from '@glimmer/opcode-compiler';
import TestJitRuntimeResolver from './resolver';
import { ComponentKind, ComponentTypes } from '../../components';
import { TestComponentDefinitionState } from '../../components/test-component';
Expand Down Expand Up @@ -186,7 +187,7 @@ export function registerPartial(
name: string,
source: string
): PartialDefinition {
let definition = new PartialDefinition(name, preprocess(source));
let definition = new PartialDefinitionImpl(name, preprocess(source));
registry.register('partial', name, definition);
return definition;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@glimmer/interfaces';
import { dict } from '@glimmer/util';
import { createTemplate } from '../../compile';
import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { unwrapTemplate } from '@glimmer/util';

export interface Lookup {
helper: GlimmerHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VersionedPathReference } from '@glimmer/reference';
import { ElementBuilder, RenderResult } from '@glimmer/interfaces';
import { preprocess } from '../../compile';
import { renderJitMain, renderSync } from '@glimmer/runtime';
import { unwrapTemplate, unwrapHandle } from '@glimmer/opcode-compiler';
import { unwrapTemplate, unwrapHandle } from '@glimmer/util';

export function renderTemplate(
src: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { precompile } from '@glimmer/compiler';
import { preprocess, DEFAULT_TEST_META } from '../..';
import { module } from '../support';
import { assign } from '@glimmer/util';
import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { assign, unwrapTemplate } from '@glimmer/util';

module('[glimmer-compiler] Compile options', ({ test }) => {
test('moduleName option is passed into meta', assert => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
SyntaxCompilationContext,
Dict,
} from '@glimmer/interfaces';
import { unwrapTemplate, unwrapHandle } from '@glimmer/opcode-compiler';
import EmberObject from '@glimmer/object';
import { CLASS_META, setProperty as set, UpdatableRootReference } from '@glimmer/object-reference';
import { bump } from '@glimmer/validator';
import { clientBuilder, renderJitMain } from '@glimmer/runtime';
import { assign, dict, unwrap } from '@glimmer/util';
import { assign, dict, unwrap, unwrapTemplate, unwrapHandle } from '@glimmer/util';
import { SimpleElement } from '@simple-dom/interface';
import { assert } from './support';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/integration-tests/test/partial-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TestContext,
} from '..';
import { SimpleNode } from '@simple-dom/interface';
import { unwrapTemplate, unwrapHandle } from '@glimmer/opcode-compiler';
import { unwrapTemplate, unwrapHandle } from '@glimmer/util';

let context: TestContext;
let result: RenderResult;
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/integration-tests/test/precompile-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { templateFactory, unwrapTemplate } from '@glimmer/opcode-compiler';
import { precompile } from '@glimmer/compiler';
import { SerializedTemplateWithLazyBlock, AnnotatedModuleLocator } from '@glimmer/interfaces';
import { assign } from '@glimmer/util';
import { assign, unwrapTemplate } from '@glimmer/util';
import { templateFactory } from '@glimmer/opcode-compiler';

let serializedTemplate: SerializedTemplateWithLazyBlock<AnnotatedModuleLocator>;
let serializedTemplateNoId: SerializedTemplateWithLazyBlock<AnnotatedModuleLocator>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
equalTokens,
registerModifier,
} from '..';
import { unwrapTemplate, unwrapHandle } from '@glimmer/opcode-compiler';
import { unwrapTemplate, unwrapHandle } from '@glimmer/util';

let context: TestContext;
let root: SimpleElement;
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/integration-tests/test/updating-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from '..';
import { Namespace, SimpleElement, SimpleNode } from '@simple-dom/interface';
import { assert, module, test } from './support';
import { unwrapHandle } from '@glimmer/opcode-compiler';
import { unwrapHandle } from '@glimmer/util';

const SVG_NAMESPACE = Namespace.SVG;
const XLINK_NAMESPACE = Namespace.XLink;
Expand Down
15 changes: 2 additions & 13 deletions packages/@glimmer/opcode-compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,9 @@ export { meta } from './lib/opcode-builder/helpers/shared';

export { StdLib } from './lib/opcode-builder/stdlib';

export { PartialDefinition } from './lib/partial-template';
export { PartialDefinitionImpl } from './lib/partial-template';

export {
default as templateFactory,
TemplateFactory,
Component,
unwrapTemplate,
unwrapHandle,
isOkHandle,
isErrHandle,
extractHandle,
} from './lib/template';

export { debug, debugSlice, logOpcode } from './lib/debug';
export { default as templateFactory, TemplateFactory, Component } from './lib/template';

export { WrappedBuilder } from './lib/wrapped-component';

Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/opcode-compiler/lib/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debugSlice } from './debug';
import { debugSlice } from '@glimmer/debug';
import {
CompilerBuffer,
CompileTimeHeap,
Expand All @@ -10,8 +10,8 @@ import {
HandleResult,
} from '@glimmer/interfaces';
import { LOCAL_SHOULD_LOG } from '@glimmer/local-debug-flags';
import { extractHandle } from '@glimmer/util';
import { namedBlocks, expectString } from './utils';
import { extractHandle } from './template';

export function compileInline(
sexp: Statements.Append,
Expand Down
5 changes: 3 additions & 2 deletions packages/@glimmer/opcode-compiler/lib/partial-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import {
Template,
SyntaxCompilationContext,
HandleResult,
PartialDefinition,
} from '@glimmer/interfaces';
import { unwrapTemplate } from './template';
import { unwrapTemplate } from '@glimmer/util';

export class PartialDefinition {
export class PartialDefinitionImpl implements PartialDefinition {
constructor(
public name: string, // for debugging
private template: Template
Expand Down
40 changes: 1 addition & 39 deletions packages/@glimmer/opcode-compiler/lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import {
SerializedTemplateWithLazyBlock,
Template,
TemplateOk,
HandleResult,
OkHandle,
ErrHandle,
} from '@glimmer/interfaces';
import { assign } from '@glimmer/util';
import { assign, unwrapTemplate } from '@glimmer/util';
import { compilable } from './compilable-template';
import { WrappedBuilder } from './wrapped-component';

Expand Down Expand Up @@ -127,38 +124,3 @@ export function Component(serialized: string, envMeta?: {}): CompilableProgram {
let template = unwrapTemplate(factory.create(envMeta));
return template.asLayout();
}

export function unwrapTemplate<M>(template: Template<M>): TemplateOk<M> {
if (template.result === 'error') {
throw new Error(
`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`
);
}

return template;
}

export function unwrapHandle(handle: HandleResult): number {
if (typeof handle === 'number') {
return handle;
} else {
let error = handle.errors[0];
throw new Error(`Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}`);
}
}

export function extractHandle(handle: HandleResult): number {
if (typeof handle === 'number') {
return handle;
} else {
return handle.handle;
}
}

export function isOkHandle(handle: HandleResult): handle is OkHandle {
return typeof handle === 'number';
}

export function isErrHandle(handle: HandleResult): handle is ErrHandle {
return typeof handle === 'number';
}
3 changes: 1 addition & 2 deletions packages/@glimmer/runtime/lib/compiled/opcodes/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
} from '@glimmer/interfaces';
import { VersionedPathReference, VersionedReference } from '@glimmer/reference';
import { CONSTANT_TAG, isConst, isConstTag, Tag } from '@glimmer/validator';
import { assert, dict, expect, Option, unreachable, symbol } from '@glimmer/util';
import { assert, dict, expect, Option, unreachable, symbol, unwrapTemplate } from '@glimmer/util';
import { $t0, $t1, $v0 } from '@glimmer/vm';
import {
Capability,
Expand Down Expand Up @@ -72,7 +72,6 @@ import {
import { ContentTypeReference } from './content';
import { UpdateDynamicAttributeOpcode } from './dom';
import { ConditionalReference, PrimitiveReference } from '../../references';
import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { DEBUG } from '@glimmer/env';

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/@glimmer/runtime/lib/compiled/opcodes/partial.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { VersionedPathReference } from '@glimmer/reference';
import { APPEND_OPCODES } from '../../opcodes';
import { PartialDefinition, unwrapHandle } from '@glimmer/opcode-compiler';
import { assert } from '@glimmer/util';
import { assert, unwrapHandle } from '@glimmer/util';
import { check } from '@glimmer/debug';
import { Op, Dict } from '@glimmer/interfaces';
import { Op, Dict, PartialDefinition } from '@glimmer/interfaces';
import { CheckReference } from './-debug-strip';
import { CONSTANTS } from '../../symbols';

Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/runtime/lib/opcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Tag } from '@glimmer/validator';
import { RuntimeOp, Op, JitOrAotBlock, Maybe, Dict } from '@glimmer/interfaces';
import { LOCAL_DEBUG, LOCAL_SHOULD_LOG } from '@glimmer/local-debug-flags';
// these import bindings will be stripped from build
import { debug, logOpcode } from '@glimmer/opcode-compiler';
import { debug, logOpcode } from '@glimmer/debug';
import { DESTRUCTOR_STACK, INNER_VM, CONSTANTS, STACKS } from './symbols';
import { InternalVM, InternalJitVM } from './vm/append';
import { CURSOR_STACK } from './vm/element-builder';
Expand Down
3 changes: 1 addition & 2 deletions packages/@glimmer/runtime/lib/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ElementBuilder,
} from '@glimmer/interfaces';
import { PathReference } from '@glimmer/reference';
import { expect } from '@glimmer/util';
import { expect, unwrapHandle } from '@glimmer/util';
import { capabilityFlagsFrom } from './capabilities';
import { hasStaticLayoutCapability } from './compiled/opcodes/component';
import { resolveComponent } from './component/resolve';
Expand All @@ -26,7 +26,6 @@ import { AotVM, InternalVM, JitVM } from './vm/append';
import { NewElementBuilder } from './vm/element-builder';
import { DefaultDynamicScope } from './dynamic-scope';
import { UNDEFINED_REFERENCE } from './references';
import { unwrapHandle } from '@glimmer/opcode-compiler';

class TemplateIteratorImpl<C extends JitOrAotBlock> implements TemplateIterator {
constructor(private vm: InternalVM<C>) {}
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/runtime/lib/vm/append.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import {
Register,
SyscallRegister,
} from '@glimmer/vm';
import { CheckNumber, check } from '@glimmer/debug';
import { unwrapHandle } from '@glimmer/util';
import { combineSlice } from '../utils/tags';
import { DidModifyOpcode, JumpIfNotModifiedOpcode, LabelOpcode } from '../compiled/opcodes/vm';
import { ScopeImpl } from '../environment';
Expand All @@ -68,8 +70,6 @@ import {
TryOpcode,
VMState,
} from './update';
import { CheckNumber, check } from '@glimmer/debug';
import { unwrapHandle } from '@glimmer/opcode-compiler';

/**
* This interface is used by internal opcodes, and is more stable than
Expand Down
1 change: 0 additions & 1 deletion packages/@glimmer/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dependencies": {
"@glimmer/env": "0.1.7",
"@glimmer/low-level": "^0.47.9",
"@glimmer/opcode-compiler": "^0.47.9",
"@glimmer/util": "^0.47.9",
"@glimmer/reference": "^0.47.9",
"@glimmer/validator": "^0.47.9",
Expand Down
Loading

0 comments on commit 61a1510

Please sign in to comment.