Skip to content

Commit

Permalink
Merge branch 'mr/pmderodat/lkt' into 'master'
Browse files Browse the repository at this point in the history
nodes.lkt: avoid the "if a then b else {...}.do(...)" pattern

See merge request eng/libadalang/libadalang!1688
  • Loading branch information
pmderodat committed Jul 10, 2024
2 parents 9aa599e + d18aeb2 commit 44cda3c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ada/nodes.lkt
Original file line number Diff line number Diff line change
Expand Up @@ -8112,23 +8112,25 @@ class BaseSubpBody: Body {
s"__nextpart", node, dest_env=node.previous_part_env_name().do(
(name) => DesignatedEnv(
kind=DesignatedEnvKind.named_env, env_name=name, direct_env=null[LexicalEnv]
), default_val=# Due to overloading, it's not possible to find the previous
),
# Due to overloading, it's not possible to find the previous
# part of a non-library item subprogram at this stage if it
# has a top level env name (e.g. a subprogram declared in a
# package), since its body could be defined in another unit.
if node.has_top_level_env_name() then DesignatedEnv(
default_val=if node.has_top_level_env_name() then DesignatedEnv(
kind=DesignatedEnvKind.none, env_name=null[Symbol], direct_env=null[LexicalEnv]
) else {
bind env = node.default_initial_env();

self.body_scope(follow_private=false, force_decl=true)
}.do(
(non_null_env) => DesignatedEnv(
kind=DesignatedEnvKind.direct_env, env_name=null[Symbol], direct_env=non_null_env
), default_val=DesignatedEnv(
kind=DesignatedEnvKind.current_env, env_name=null[Symbol], direct_env=null[LexicalEnv]
self.body_scope(follow_private=false, force_decl=true).do(
(non_null_env) => DesignatedEnv(
kind=DesignatedEnvKind.direct_env, env_name=null[Symbol], direct_env=non_null_env
),
default_val=DesignatedEnv(
kind=DesignatedEnvKind.current_env, env_name=null[Symbol], direct_env=null[LexicalEnv]
)
)
)
}
)
)
do(node.populate_dependent_units())
Expand Down

0 comments on commit 44cda3c

Please sign in to comment.