How to use the @glimmer/opcode-compiler.unwrapHandle function in @glimmer/opcode-compiler

To help you get started, we’ve selected a few @glimmer/opcode-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compiled / opcodes / partial.ts View on Github external
}

      if (evalScope) {
        for (let i = 0; i < partialSymbols.length; i++) {
          let name = partialSymbols[i];
          let symbol = i + 1;
          let value = evalScope[name];

          if (value !== undefined) partialScope.bind(symbol, value);
        }
      }

      partialScope.bindPartialMap(locals);

      vm.pushFrame(); // sp += 2
      vm.call(unwrapHandle(vmHandle!));
    }
  },
  'jit'
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / components / emberish-root-view.ts View on Github external
appendTo(selector: string) {
    let element = assertElement(document.querySelector(selector) as SimpleElement);
    let self = new UpdatableRootReference(this);
    let cursor = { element, nextSibling: null };

    let handle = unwrapTemplate(this.template)
      .asLayout()
      .compile(this.syntax);

    let templateIterator = renderJitMain(
      this.runtime,
      this.syntax,
      self,
      clientBuilder(this.runtime.env, cursor),
      unwrapHandle(handle)
    );
    let result;
    do {
      result = templateIterator.next();
    } while (!result.done);

    this.element = firstElementChild(element)!;
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / modes / jit / render.ts View on Github external
export function renderTemplate(
  src: string,
  { runtime, syntax }: JitTestDelegateContext,
  self: VersionedPathReference,
  builder: ElementBuilder
): RenderResult {
  let template = preprocess(src);
  let handle = unwrapTemplate(template)
    .asLayout()
    .compile(syntax);

  let iterator = renderJitMain(runtime, syntax, self, builder, unwrapHandle(handle));
  return renderSync(runtime.env, iterator);
}
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / render.ts View on Github external
const definition = expect(
    resolveComponent(vm.runtime.resolver, name),
    `could not find component "${name}"`
  );

  const { manager, state } = definition;

  const capabilities = capabilityFlagsFrom(manager.getCapabilities(state));

  let invocation: Invocation;

  if (hasStaticLayoutCapability(capabilities, manager)) {
    let layout = (manager as WithJitStaticLayout).getJitStaticLayout(state, vm.runtime.resolver);

    let handle = unwrapHandle(layout.compile(context));

    if (Array.isArray(handle)) {
      let error = handle[0];
      throw new Error(
        `Compile Error: ${error.problem} ${error.span.start}..${error.span.end} :: TODO (thread better)`
      );
    }

    invocation = { handle, symbolTable: layout.symbolTable };
  } else {
    throw new Error('Cannot invoke components with dynamic layouts as a root component.');
  }

  return renderInvocation(vm, invocation, definition, args);
}
github glimmerjs / glimmer.js / packages / @glimmer / application / src / loaders / runtime-compiler / loader.ts View on Github external
async getTemplateIterator(
    app: Application,
    env: Environment,
    builder: ElementBuilder,
    dynamicScope: DynamicScope,
    self: PathReference
  ): Promise {
    let resolver = this.getResolver(app);
    let context = this.getContext(resolver);
    let runtime = CustomJitRuntime(resolver, context, app.env);

    let mainLayout = unwrapTemplate(templateFactory(mainTemplate).create());
    let handle = unwrapHandle(mainLayout.asLayout().compile(context));

    return Promise.resolve(
      renderJitMain(
        runtime,
        context,
        self,
        builder,
        handle,
        dynamicScope
      )
    );
  }