コード例 #1
0
ファイル: pathctx.py プロジェクト: dungeon2567/edgedb
def register_set_in_scope(ir_set: irast.Set,
                          *,
                          path_scope: irast.ScopeTreeNode = None,
                          ctx: context.CompilerContext) -> None:
    if path_scope is None:
        path_scope = ctx.path_scope

    try:
        path_scope.attach_path(ir_set.path_id)
    except irast.InvalidScopeConfiguration as e:
        raise errors.EdgeQLSyntaxError(e.args[0],
                                       context=ir_set.context) from e
コード例 #2
0
ファイル: setgen.py プロジェクト: Nesterov-Konstantin/edgedb
def fuse_scope_branch(ir_set: irast.Set, parent: irast.ScopeTreeNode,
                      branch: irast.ScopeTreeNode, *,
                      ctx: context.ContextLevel) -> None:
    if parent.path_id is None:
        parent.attach_subtree(branch)
    else:
        if branch.path_id is None and len(branch.children) == 1:
            target_branch = next(iter(branch.children))
        else:
            target_branch = branch

        if parent.path_id == target_branch.path_id:
            new_root = irast.new_scope_tree()
            for child in tuple(target_branch.children):
                new_root.attach_child(child)

            parent.attach_subtree(new_root)
        else:
            parent.attach_subtree(branch)