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


TypeScript Op.orThrow函数代码示例

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


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

示例1: verifyPoly

export default function verifyPoly({value}: Poly): void {
	if (value instanceof FunBlock)
		// value always has opDeclareThis
		makeUseOptional(orThrow(value.opDeclareThis))
	value.args.forEach(makeUseOptional)
	opEach(value.opRestArg, makeUseOptional)
	verifyMethodValue(value)
	// name set by AssignSingle
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:9,代码来源:verifyPoly.ts

示例2: verifySuperCall

export function verifySuperCall(_: SuperCall, sk: SK): void {
	const {loc, args} = _
	const meth = orThrow(method, () => fail(loc, _ => _.superNeedsMethod))
	results.superCallToMethod.set(_, meth)

	if (meth instanceof Constructor) {
		check(sk === SK.Do, loc, _ => _.superMustBeStatement)
		results.constructorToSuper.set(meth, _)
	}

	verifyEachVal(args)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:12,代码来源:verifyClass.ts

示例3: verifyLocalAccess

export function verifyLocalAccess(_: LocalAccess): void {
		const {loc, name} = _
		const declare = locals.get(name)
		if (declare === undefined) {
			const builtinPath = orThrow(
				compileOptions.opBuiltinPath(name),
				() => missingLocalFail(loc, name))
			results.accessBuiltin(name, builtinPath)
		} else {
			results.localAccessToDeclare.set(_, declare)
			setDeclareAccessed(declare, _)
		}
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:13,代码来源:verifyLocals.ts

示例4: verifyConstructor

function verifyConstructor(_: Constructor, classHasSuper: boolean): void {
	const {loc, fun, memberArgs} = _

	// Constructor function always has opDeclareThis.
	makeUseOptional(orThrow(fun.opDeclareThis))
	withMethod(_, () => verifyVal(fun))

	const superCall = results.constructorToSuper.get(_)

	if (classHasSuper)
		check(superCall !== undefined, loc, _ => _.superNeeded)
	else
		check(superCall === undefined, () => superCall.loc, _ => _.superForbidden)

	for (const arg of memberArgs)
		setDeclareAccessed(arg, _)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:17,代码来源:verifyClass.ts

示例5: verifyBreak

export function verifyBreak(_: Break): void {
	const {opValue, loc} = _
	verifyOpVal(opValue)
	const {loop, sk: loopSK} = orThrow(opLoop, () => fail(loc, _ => _.misplacedBreak))

	if (loop instanceof For)
		if (loopSK === SK.Do)
			check(opValue === null, loc, _ => _.breakCantHaveValue)
		else
			check(opValue !== null, loc, _ => _.breakNeedsValue)
	else {
		// (ForAsync isn't really a loop)
		assert(loop instanceof ForBag)
		check(opValue === null, this.loc, _ => _.breakValInForBag)
	}

	if (isInSwitch) {
		results.loopsNeedingLabel.add(loop)
		results.breaksInSwitch.add(_)
	}
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:21,代码来源:verifyLoop.ts

示例6: doit

		doit(() => {
			// fun always has opDeclareThis
			makeUseOptional(orThrow(fun.opDeclareThis))
			verifyFunBlock(fun)
		})
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:5,代码来源:verifyClassTraitCommon.ts

示例7: beforeAndBlock

export function beforeAndBlock(tokens: Tokens): [Tokens, Lines] {
	const [before, opBlock] = beforeAndOpBlock(tokens)
	const block = orThrow(opBlock, () => fail(tokens.loc, _ => _.expectedBlock))
	return [before, block]
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:5,代码来源:parseBlock.ts


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