• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Op.caseOp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseClass

/** Parse a [[Class]]. */
export default function parseClass(tokens: Tokens): Class {
	const [before, opBlock] = beforeAndOpBlock(tokens)
	const {opFields, opSuperClass, traits} = parseClassHeader(before)
	type Tuple = [Op<string>, Op<ClassTraitDo>,
		Array<MethodImplLike>, Op<Constructor>, Array<MethodImplLike>]
	const [opComment, opDo, statics, opConstructor, methods] = caseOp<Lines, Tuple>(
		opBlock,
		_ => {
			const [opComment, rest] = tryTakeComment(_)
			if (rest.isEmpty())
				return [opComment, null, [], null, []]
			const [opDo, rest2] = opTakeDo(rest)
			if (rest2.isEmpty())
				return [opComment, opDo, [], null, []]
			const [statics, rest3] = takeStatics(rest2)
			if (rest3.isEmpty())
				return [opComment, opDo, statics, null, []]
			const [opConstructor, rest4] = opTakeConstructor(rest3)
			return [opComment, opDo, statics, opConstructor, parseMethodImpls(rest4)]
		},
		() => [null, null, [], null, []])
	return new Class(
		tokens.loc,
		opFields, opSuperClass, traits, opComment, opDo, statics, opConstructor, methods)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:26,代码来源:parseClass.ts


示例2: verifyModuleLines

function verifyModuleLines(lines: Array<LineContent>, loc: Loc): void {
	results.moduleKind = caseOp(
		opBlockBuildKind(lines, loc),
		buildKind => {
			if (buildKind === Blocks.Obj) {
				for (const line of lines)
					if (line instanceof ObjEntry)
						results.objEntryExports.add(line)
				verifyLines(lines)
				return Modules.Exports
			} else {
				verifyBuiltLines(lines, loc)
				return buildKind === Blocks.Bag ? Modules.Bag : Modules.Map
			}
		},
		() => {
			if (isEmpty(lines))
				return Modules.Do
			else {
				const l = last(lines)
				const lastSK = getLineSK(l)
				if (lastSK === SK.Do) {
					verifyLines(lines)
					return Modules.Do
				} else {
					const newLocals = verifyLines(rtail(lines))
					plusLocals(newLocals, () => ensureValAndVerify(l))
					return Modules.Val
				}
			}
		})
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:32,代码来源:verifyModule.ts


示例3: ArrayExpression

		new ArrayExpression(value.args.map((arg: LocalDeclare) => {
			const name = new LiteralString(arg.name)
			return caseOp<Val, Expression>(
				arg.opType,
				_ => new ArrayExpression([name, transpileVal(_)]),
				() => name)
		})) :
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:7,代码来源:transpilePoly.ts


示例4: transpileFunNoLoc

export function transpileFunNoLoc(_: Fun): Expression {
	if (_ instanceof FunBlock)
		return transpileFunBlockNoLoc(_)

	else if (_ instanceof FunGetter)
		// _ => _.foo
		return focusFun(transpileMember(idFocus, _.name))

	else if (_ instanceof FunMember) {
		const {opObject, name} = _
		const nameAst = transpileMemberName(name)
		return caseOp(
			opObject,
			_ => msCall('methodBound', transpileVal(_), nameAst),
			() => msCall('methodUnbound', nameAst))

	} else if (_ instanceof FunOperator)
		return transpileFunOperatorNoLoc(_)

	else if (_ instanceof FunSimple)
		return focusFun(transpileVal(_.value))

	else if (_ instanceof FunUnary)
		return transpileFunUnaryNoLoc(_)

	else
		throw new Error(_.constructor.name)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:28,代码来源:transpileFun.ts


示例5: transpileSwitchVDNoLoc

function transpileSwitchVDNoLoc({switched, parts, opElse}: Switch, isDo: boolean): Statement {
	const partAsts = flatMap(parts, _ => transpileSwitchPart(_, isDo))
	partAsts.push(caseOp(
		opElse,
		_ => loc(_, new SwitchCase(null, transpileBlock(_).body)),
		() => switchCaseNoMatch))
	return new SwitchStatement(transpileVal(switched), partAsts)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:8,代码来源:transpileSwitch.ts


示例6: parseObjSimple

export default function parseObjSimple(tokens: Tokens): Val {
	const pairs = caseOp(
		tokens.opSplitMany(_ => isKeyword(Kw.ObjEntry, _)),
		_ => complexPairs(tokens.loc, _),
		// Parse 'pairs' like in `{a b}` (equivalent to `{a. a b. b}`),
		// where every pair is a single identifier.
		() => tokens.map(simplePair))
	return new ObjSimple(tokens.loc, pairs)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:9,代码来源:parseObjSimple.ts


示例7: parseIteratee

function parseIteratee(tokens: Tokens): Iteratee {
	const [element, bag]: any = caseOp<{before: Tokens, after: Tokens}, [LocalDeclare, Val]>(
		tokens.opSplitOnce(_ => isKeyword(Kw.Of, _)),
		({before, after}) => {
			check(before.size() === 1, before.loc, _ => _.todoForPattern)
			return [parseLocalDeclaresJustNames(before)[0], parseExpr(after)]
		},
		() => [LocalDeclare.focus(tokens.loc), parseExpr(tokens)])
	return new Iteratee(tokens.loc, element, bag)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:10,代码来源:parseFor.ts


示例8: transpileTraitNoLoc

export function transpileTraitNoLoc(_: Trait): Expression {
	const {superTraits, opDo, statics, methods} = _
	const name = new LiteralString(verifyResults.name(_))
	const supers = new ArrayExpression(superTraits.map(transpileVal))
	const trait = msCall('trait', name, supers, methodsObject(statics), methodsObject(methods))
	return caseOp(
		opDo,
		_ => transpileBlockVal(_.block, {lead: plainLet(idFocus, trait), follow: returnFocus}),
		() => trait)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:10,代码来源:transpileTrait.ts


示例9: verifyLoop

export default function verifyLoop(_: For | ForBag, sk: SK): void {
	const {opIteratee, block} = _
	function verifyBlock(): void {
		withLoop({loop: _, sk}, () => verifyBlockDo(block))
	}
	caseOp(
		opIteratee,
		_ => withVerifyIteratee(_, verifyBlock),
		verifyBlock)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:10,代码来源:verifyLoop.ts


示例10: accessBuiltin

	accessBuiltin(name: string, path: string): void {
		caseOp(
			this.builtinPathToNames.get(path),
			_ => {
				_.add(name)
			},
			() => {
				this.builtinPathToNames.set(path, new Set([name]))
			})
	}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:10,代码来源:VerifyResults.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Op.nonNull函数代码示例发布时间:2022-05-25
下一篇:
TypeScript onoff.Gpio类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap