internal/core/runtime: refactor ExtractAttrsByKind
The current logic in ExtractAttrsByKind is targetted specifically at the
use case of searching for a specific kind of attribute, but it's useful
to be able to walk all extern attributes in one pass without necessarily
knowing which one to look for.
We refactor ExtractAttrsByKind to be iterator-oriented instead, rename
it to ExternAttrsForFile, and change interpreter/embed.EmbeddedPaths to
use it directly. Technically that's an API-breaking change, but given
that its signature was defined in terms of an internal type
(internal.Attr), it wasn't possible for external callers to use it
anyway, so this should not break any users.
As part of this change, we move towards a situation where the top level
`@extern` attribute can define parameters that apply to all the
corresponding extern attributes in that file. This will be useful in the
up-coming plugin work.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I2bf84caa05dcdbc9f97fdc9296efa3d22b41928d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235295
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>