当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript debug.expectStackChange函数代码示例

本文整理汇总了TypeScript中@glimmer/debug.expectStackChange函数的典型用法代码示例。如果您正苦于以下问题:TypeScript expectStackChange函数的具体用法?TypeScript expectStackChange怎么用?TypeScript expectStackChange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了expectStackChange函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: check

APPEND_OPCODES.add(Op.InvokePartial, (vm, { op1: _meta, op2: _symbols, op3: _evalInfo }) => {
  let { constants, constants: { resolver }, stack } = vm;

  let name = check(stack.pop(), CheckReference).value();
  assert(typeof name === 'string', `Could not find a partial named "${String(name)}"`);

  let meta = constants.getSerializable<TemplateMeta>(_meta);
  let outerSymbols = constants.getStringArray(_symbols);
  let evalInfo = constants.getArray(_evalInfo);

  let specifier = resolver.lookupPartial(name as string, meta);

  assert(specifier, `Could not find a partial named "${name}"`);

  let definition = resolver.resolve<PartialDefinition>(specifier!);

  let { symbolTable, handle } = definition.getPartial();

  {
    let partialSymbols = symbolTable.symbols;
    let outerScope = vm.scope();
    let partialScope = vm.pushRootScope(partialSymbols.length, false);
    partialScope.bindCallerScope(outerScope.getCallerScope());
    partialScope.bindEvalScope(outerScope.getEvalScope());
    partialScope.bindSelf(outerScope.getSelf());

    let locals = dict<VersionedPathReference<Opaque>>();

    for (let i = 0; i < evalInfo.length; i++) {
      let slot = evalInfo[i];
      let name = outerSymbols[slot - 1];
      let ref  = outerScope.getSymbol(slot);
      locals[name] = ref;
    }

    let evalScope = outerScope.getEvalScope()!;

    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(handle!);
  }

  expectStackChange(vm.stack, 1, 'InvokePartial');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:53,代码来源:partial.ts

示例2: check

APPEND_OPCODES.add(Op.Iterate, (vm, { op1: breaks }) => {
  let stack = vm.stack;
  let item = check(stack.peek(), CheckInstanceof(ReferenceIterator)).next();

  if (item) {
    let tryOpcode = vm.iterate(item.memo, item.value);
    vm.enterItem(item.key, tryOpcode);
  } else {
    vm.goto(breaks);
  }

  expectStackChange(vm.stack, item ? 2 : 0, 'Iterate');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:13,代码来源:lists.ts

示例3: expectStackChange

APPEND_OPCODES.add(Op.GetBlock, (vm, { op1: _block }) => {
  let { stack } = vm;
  let block = vm.scope().getBlock(_block);

  if (block) {
    stack.push(block[1]);
    stack.push(block[0]);
  } else {
    stack.push(null);
    stack.push(null);
  }

  expectStackChange(vm.stack, 2, 'GetBlock');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:14,代码来源:expressions.ts

示例4: check

APPEND_OPCODES.add(Op.DynamicContent, (vm, { op1: isTrusting }) => {
  let reference = check(vm.stack.pop(), CheckPathReference);
  let value = reference.value();
  let content: DynamicContentWrapper;

  if (isTrusting) {
    content = vm.elements().appendTrustingDynamicContent(value);
  } else {
    content = vm.elements().appendCautiousDynamicContent(value);
  }

  if (!isConst(reference)) {
    vm.updateWith(new UpdateDynamicContentOpcode(reference, content));
  }

  expectStackChange(vm.stack, -1, 'DynamicContent');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:17,代码来源:content.ts


注:本文中的@glimmer/debug.expectStackChange函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。