本文整理汇总了TypeScript中@glimmer/util.assert函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assert函数的具体用法?TypeScript assert怎么用?TypeScript assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert函数的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');
});
示例2: getComponentSpec
private getComponentSpec(handle: number): ComponentSpec {
let spec = this.resolver.resolve<Option<ComponentSpec>>(handle);
assert(!!spec, `Couldn't find a template named ${name}`);
return spec!;
}
示例3: assert
APPEND_OPCODES.add(Op.HasBlockParams, (vm) => {
vm.stack.pop<VMHandle>();
let table = vm.stack.pop<Option<BlockSymbolTable>>();
assert(table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)), stackAssert('Option<BlockSymbolTable>', table));
let hasBlockParams = table && table.parameters.length;
vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE);
});
示例4: check
APPEND_OPCODES.add(Op.HasBlockParams, (vm) => {
check(vm.stack.pop(), CheckOption(CheckOr(CheckHandle, CheckCompilableBlock)));
let table = check(vm.stack.pop(), CheckOption(CheckBlockSymbolTable));
assert(table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)), stackAssert('Option<BlockSymbolTable>', table));
let hasBlockParams = table && table.parameters.length;
vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE);
});