v / vlib / v2 / types / module.v
26 lines · 23 sloc · 606 bytes · 03947c8bd69e101474701862d96c206cb020d182
Raw
1// Copyright (c) 2020-2024 Joe Conigliaro. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4module types
5
6pub struct Module {
7pub:
8 name string
9 path string
10 imports []Module
11 scope &Scope = new_scope(unsafe { nil })
12}
13
14pub fn new_module(name string, path string) &Module {
15 return &Module{
16 name: name
17 path: path
18 scope: new_scope(universe)
19 }
20}
21
22// lookup resolves a symbol from this module scope.
23pub fn (m &Module) lookup(name string) ?Object {
24 mut scope := unsafe { m.scope }
25 return scope.lookup_parent(name, 0)
26}
27