hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 4d790c7248e1561c6bb03ba3930f9a2673b34211
parent 768442a4cd7a56bdf30a86416e8346d2c73ee153
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat,  6 Mar 2021 11:15:35 -0500

hare::module: implement lookup

Diffstat:
Mhare/module/scan.ha | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -66,7 +66,17 @@ export fn scan(ctx: *context, path: path::path) (version | error) = { // Looks up a module by its identifier from HAREPATH, and returns a [version] // which includes all eligible build inputs. export fn lookup(ctx: *context, name: ast::ident) (version | error) = { - abort(); + let ipath = ident_path(name); + defer ast::ident_free(name); + for (let i = len(ctx.paths); i > 0; i -= 1) { + let cand = path::join(ctx.paths[i - 1], ipath); + defer path::path_free(cand); + match (scan(ctx, cand)) { + v: version => return v, + e: error => void, + }; + }; + return module_not_found; }; // TODO: Filter inputs by build tags