本文整理汇总了C#中EcmaScript.NET.Node.hasChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Node.hasChildren方法的具体用法?C# Node.hasChildren怎么用?C# Node.hasChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcmaScript.NET.Node
的用法示例。
在下文中一共展示了Node.hasChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTryCatchFinally
/// <summary> Try/Catch/Finally
///
/// The IRFactory tries to express as much as possible in the tree;
/// the responsibilities remaining for Codegen are to add the Java
/// handlers: (Either (but not both) of TARGET and FINALLY might not
/// be defined)
/// - a catch handler for javascript exceptions that unwraps the
/// exception onto the stack and GOTOes to the catch target
/// - a finally handler
/// ... and a goto to GOTO around these handlers.
/// </summary>
internal Node CreateTryCatchFinally(Node tryBlock, Node catchBlocks, Node finallyBlock, int lineno)
{
bool hasFinally = (finallyBlock != null) && (finallyBlock.Type != Token.BLOCK || finallyBlock.hasChildren ());
// short circuit
if (tryBlock.Type == Token.BLOCK && !tryBlock.hasChildren () && !hasFinally) {
return tryBlock;
}
bool hasCatch = catchBlocks.hasChildren ();
// short circuit
if (!hasFinally && !hasCatch) {
// bc finally might be an empty block...
return tryBlock;
}
Node handlerBlock = new Node (Token.LOCAL_BLOCK);
Node.Jump pn = new Node.Jump (Token.TRY, tryBlock, lineno);
pn.putProp (Node.LOCAL_BLOCK_PROP, handlerBlock);
if (hasCatch) {
// jump around catch code
Node endCatch = Node.newTarget ();
pn.addChildToBack (makeJump (Token.GOTO, endCatch));
// make a TARGET for the catch that the tcf node knows about
Node catchTarget = Node.newTarget ();
pn.target = catchTarget;
// mark it
pn.addChildToBack (catchTarget);
//
// Given
//
// try {
// tryBlock;
// } catch (e if condition1) {
// something1;
// ...
//
// } catch (e if conditionN) {
// somethingN;
// } catch (e) {
// somethingDefault;
// }
//
// rewrite as
//
// try {
// tryBlock;
// goto after_catch:
// } catch (x) {
// with (newCatchScope(e, x)) {
// if (condition1) {
// something1;
// goto after_catch;
// }
// }
// ...
// with (newCatchScope(e, x)) {
// if (conditionN) {
// somethingN;
// goto after_catch;
// }
// }
// with (newCatchScope(e, x)) {
// somethingDefault;
// goto after_catch;
// }
// }
// after_catch:
//
// If there is no default catch, then the last with block
// arround "somethingDefault;" is replaced by "rethrow;"
// It is assumed that catch handler generation will store
// exeception object in handlerBlock register
// Block with local for exception scope objects
Node catchScopeBlock = new Node (Token.LOCAL_BLOCK);
// expects catchblocks children to be (cond block) pairs.
Node cb = catchBlocks.FirstChild;
bool hasDefault = false;
int scopeIndex = 0;
while (cb != null) {
int catchLineNo = cb.Lineno;
//.........这里部分代码省略.........