當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript debug.check函數代碼示例

本文整理匯總了TypeScript中@glimmer/debug.check函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript check函數的具體用法?TypeScript check怎麽用?TypeScript check使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了check函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: check

APPEND_OPCODES.add(Op.SetBlock, (vm, { op1: symbol }) => {
  let handle = check(vm.stack.pop(), CheckOr(CheckOption(CheckHandle), CheckCompilableBlock));
  let table = check(vm.stack.pop(), CheckOption(CheckBlockSymbolTable));

  let block: Option<ScopeBlock> = table ? [handle!, table] : null;

  vm.scope().bindBlock(symbol, block);
});
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:8,代碼來源:expressions.ts

示例2: check

APPEND_OPCODES.add(Op.PutIterator, vm => {
  let stack = vm.stack;
  let listRef = check(stack.pop(), CheckPathReference);
  let key = check(stack.pop(), CheckPathReference);
  let iterable = vm.env.iterableFor(listRef, check(key.value(), CheckString));
  let iterator = new ReferenceIterator(iterable);

  stack.push(iterator);
  stack.push(new IterablePresenceReference(iterator.artifacts));
});
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:10,代碼來源:lists.ts

示例3: Array

APPEND_OPCODES.add(Op.Concat, (vm, { op1: count }) => {
  let out: Array<VersionedPathReference<Opaque>> = new Array(count);

  for (let i = count; i > 0; i--) {
    let offset = i - 1;
    out[offset] = check(vm.stack.pop(), CheckPathReference);
  }

  vm.stack.push(new ConcatReference(out));
});
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:10,代碼來源:expressions.ts

示例4: 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

示例5: clearsArgs

function clearsArgs(options: ClearsArgs): DebugMetadata<number> {
  return {
    name: options.name,
    ops: options.ops || [],
    operands: options.operands || 0,

    before(_opcode: Opaque, vm: VM): number {
      return check(vm.stack.peek(options.argsPosition || 0), CheckInterface({ length: CheckNumber })).length;
    },

    stackChange({ state: args }: { state: number }): number {
      return -args - 1 + (options.netPushes || 0) - (options.netPops || 0);
    }
  };
}
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:15,代碼來源:-debug-strip.ts

示例6: 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.check函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。