當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。